2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

[PUI] Update table filters (#7544)

* Update part table filters

* Update stock location table filters

* Update part category table filters
This commit is contained in:
Oliver 2024-07-02 11:32:41 +10:00 committed by GitHub
parent ee7a9626e8
commit ade6cfb878
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 58 additions and 11 deletions

View File

@ -286,6 +286,11 @@ export function BomTable({
label: t`Inherited`, label: t`Inherited`,
description: t`Show inherited items` description: t`Show inherited items`
}, },
{
name: 'allow_variants',
label: t`Allow Variants`,
description: t`Show items which allow variant substitution`
},
{ {
name: 'optional', name: 'optional',
label: t`Optional`, label: t`Optional`,

View File

@ -64,6 +64,11 @@ export function PartCategoryTable({ parentId }: { parentId?: any }) {
name: 'structural', name: 'structural',
label: t`Structural`, label: t`Structural`,
description: t`Show structural categories` description: t`Show structural categories`
},
{
name: 'starred',
label: t`Subscribed`,
description: t`Show categories to which the user is subscribed`
} }
]; ];
}, []); }, []);

View File

@ -238,14 +238,37 @@ function partTableFilters(): TableFilter[] {
{ value: 'true', label: t`Virtual` }, { value: 'true', label: t`Virtual` },
{ value: 'false', label: t`Not Virtual` } { value: 'false', label: t`Not Virtual` }
] ]
},
{
name: 'is_template',
label: t`Is Template`,
description: t`Filter by parts which are templates`,
type: 'boolean'
},
{
name: 'has_pricing',
label: t`Has Pricing`,
description: t`Filter by parts which have pricing information`,
type: 'boolean'
},
{
name: 'unallocated_stock',
label: t`Available Stock`,
description: t`Filter by parts which have available stock`,
type: 'boolean'
},
{
name: 'starred',
label: t`Subscribed`,
description: t`Filter by parts to which the user is subscribed`,
type: 'boolean'
},
{
name: 'stocktake',
label: t`Has Stocktake`,
description: t`Filter by parts which have stocktake information`,
type: 'boolean'
} }
// unallocated_stock
// starred
// stocktake
// is_template
// virtual
// has_pricing
// TODO: Any others from table_filters.js?
]; ];
} }

View File

@ -6,6 +6,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles'; import { UserRoles } from '../../enums/Roles';
import { stockLocationFields } from '../../forms/StockForms'; import { stockLocationFields } from '../../forms/StockForms';
import { useFilters } from '../../hooks/UseFilter';
import { import {
useCreateApiFormModal, useCreateApiFormModal,
useEditApiFormModal useEditApiFormModal
@ -26,6 +27,14 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
const table = useTable('stocklocation'); const table = useTable('stocklocation');
const user = useUserState(); const user = useUserState();
const locationTypeFilters = useFilters({
url: apiUrl(ApiEndpoints.stock_location_type_list),
transform: (item) => ({
value: item.pk,
label: item.name
})
});
const tableFilters: TableFilter[] = useMemo(() => { const tableFilters: TableFilter[] = useMemo(() => {
return [ return [
{ {
@ -35,21 +44,26 @@ export function StockLocationTable({ parentId }: { parentId?: any }) {
}, },
{ {
name: 'structural', name: 'structural',
label: t`structural`, label: t`Structural`,
description: t`Show structural locations` description: t`Show structural locations`
}, },
{ {
name: 'external', name: 'external',
label: t`external`, label: t`External`,
description: t`Show external locations` description: t`Show external locations`
}, },
{ {
name: 'has_location_type', name: 'has_location_type',
label: t`Has location type` label: t`Has location type`
},
{
name: 'location_type',
label: t`Location Type`,
description: t`Filter by location type`,
choices: locationTypeFilters.choices
} }
// TODO: location_type
]; ];
}, []); }, [locationTypeFilters.choices]);
const tableColumns: TableColumn[] = useMemo(() => { const tableColumns: TableColumn[] = useMemo(() => {
return [ return [