mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-30 00:21:34 +00:00
Stock filters (#10083)
* Stock filters - Add "supplier" filter - Add "manufacturer" filter * Fix docstring
This commit is contained in:
@@ -33,6 +33,7 @@ export type TableFilterType = 'boolean' | 'choice' | 'date' | 'text' | 'api';
|
||||
* displayValue: The current display value of the filter
|
||||
* active: Whether the filter is active (false = hidden, not used)
|
||||
* apiUrl: The API URL to use for fetching dynamic filter options
|
||||
* apiFilter: Optional filters to apply when fetching options from the API
|
||||
* model: The model type to use for fetching dynamic filter options
|
||||
* modelRenderer: A function to render a simple text version of the model type
|
||||
*/
|
||||
@@ -48,6 +49,7 @@ export type TableFilter = {
|
||||
displayValue?: any;
|
||||
active?: boolean;
|
||||
apiUrl?: string;
|
||||
apiFilter?: Record<string, any>;
|
||||
model?: ModelType;
|
||||
modelRenderer?: (instance: any) => string;
|
||||
};
|
||||
|
@@ -333,6 +333,32 @@ export function UserFilter({
|
||||
};
|
||||
}
|
||||
|
||||
export function ManufacturerFilter(): TableFilter {
|
||||
return {
|
||||
name: 'manufacturer',
|
||||
label: t`Manufacturer`,
|
||||
description: t`Filter by manufacturer`,
|
||||
type: 'api',
|
||||
apiUrl: apiUrl(ApiEndpoints.company_list),
|
||||
model: ModelType.company,
|
||||
modelRenderer: (instance: any) => instance.name,
|
||||
apiFilter: { is_manufacturer: true }
|
||||
};
|
||||
}
|
||||
|
||||
export function SupplierFilter(): TableFilter {
|
||||
return {
|
||||
name: 'supplier',
|
||||
label: t`Supplier`,
|
||||
description: t`Filter by supplier`,
|
||||
type: 'api',
|
||||
apiUrl: apiUrl(ApiEndpoints.company_list),
|
||||
model: ModelType.company,
|
||||
modelRenderer: (instance: any) => instance.name,
|
||||
apiFilter: { is_supplier: true }
|
||||
};
|
||||
}
|
||||
|
||||
export function CreatedByFilter(): TableFilter {
|
||||
return UserFilter({
|
||||
name: 'created_by',
|
||||
|
@@ -98,6 +98,7 @@ function FilterElement({
|
||||
fieldDefinition={{
|
||||
field_type: 'related field',
|
||||
api_url: filterProps.apiUrl,
|
||||
filters: filterProps.apiFilter,
|
||||
placeholder: t`Select filter value`,
|
||||
model: filterProps.model,
|
||||
label: t`Select filter value`,
|
||||
|
@@ -34,10 +34,12 @@ import {
|
||||
HasBatchCodeFilter,
|
||||
IncludeVariantsFilter,
|
||||
IsSerializedFilter,
|
||||
ManufacturerFilter,
|
||||
SerialFilter,
|
||||
SerialGTEFilter,
|
||||
SerialLTEFilter,
|
||||
StatusFilterOptions
|
||||
StatusFilterOptions,
|
||||
SupplierFilter
|
||||
} from '../Filter';
|
||||
import { InvenTreeTable } from '../InvenTreeTable';
|
||||
import { TableHoverCard } from '../TableHoverCard';
|
||||
@@ -358,6 +360,8 @@ function stockItemTableFilters({
|
||||
description: t`Show items which are in production`
|
||||
},
|
||||
IncludeVariantsFilter(),
|
||||
SupplierFilter(),
|
||||
ManufacturerFilter(),
|
||||
{
|
||||
name: 'consumed',
|
||||
label: t`Consumed`,
|
||||
|
Reference in New Issue
Block a user