mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-07 12:22:11 +00:00
Enable filtering by reference status type
This commit is contained in:
@@ -137,6 +137,7 @@ class CustomStateList(DataExportViewMixin, ListCreateAPI):
|
||||
filter_backends = SEARCH_ORDER_FILTER
|
||||
ordering_fields = ['key']
|
||||
search_fields = ['key', 'name', 'label', 'reference_status']
|
||||
filterset_fields = ['model', 'reference_status']
|
||||
|
||||
|
||||
class CustomStateDetail(RetrieveUpdateDestroyAPI):
|
||||
|
@@ -36,7 +36,7 @@ export const useGlobalStatusState = create<ServerStateProps>()(
|
||||
const newStatusLookup: StatusLookup = {} as StatusLookup;
|
||||
for (const key in response.data) {
|
||||
newStatusLookup[statusCodeList[key] || key] = {
|
||||
statusClass: key,
|
||||
status_class: key,
|
||||
values: response.data[key].values
|
||||
};
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import { apiUrl } from '../../states/ApiState';
|
||||
import { useGlobalStatusState } from '../../states/StatusState';
|
||||
import { useUserState } from '../../states/UserState';
|
||||
import type { TableColumn } from '../Column';
|
||||
import type { TableFilter } from '../Filter';
|
||||
import { InvenTreeTable } from '../InvenTreeTable';
|
||||
import { type RowAction, RowDeleteAction, RowEditAction } from '../RowActions';
|
||||
|
||||
@@ -43,13 +44,29 @@ export default function CustomStateTable() {
|
||||
(value: StatusCodeInterface) => value.key === key
|
||||
);
|
||||
|
||||
return value?.label ?? '';
|
||||
return value?.label ?? value?.name ?? '';
|
||||
},
|
||||
[statusCodes]
|
||||
);
|
||||
|
||||
const user = useUserState();
|
||||
|
||||
const tableFilters: TableFilter[] = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
name: 'reference_status',
|
||||
label: t`Status Group`,
|
||||
field_type: 'choice',
|
||||
choices: Object.values(statusCodes.status ?? {}).map(
|
||||
(value: StatusCodeListInterface) => ({
|
||||
label: value.status_class,
|
||||
value: value.status_class
|
||||
})
|
||||
)
|
||||
}
|
||||
];
|
||||
}, [statusCodes]);
|
||||
|
||||
const columns: TableColumn[] = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
@@ -173,6 +190,7 @@ export default function CustomStateTable() {
|
||||
props={{
|
||||
rowActions: rowActions,
|
||||
tableActions: tableActions,
|
||||
tableFilters: tableFilters,
|
||||
enableDownload: true
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user