mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-10 05:40:55 +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
|
filter_backends = SEARCH_ORDER_FILTER
|
||||||
ordering_fields = ['key']
|
ordering_fields = ['key']
|
||||||
search_fields = ['key', 'name', 'label', 'reference_status']
|
search_fields = ['key', 'name', 'label', 'reference_status']
|
||||||
|
filterset_fields = ['model', 'reference_status']
|
||||||
|
|
||||||
|
|
||||||
class CustomStateDetail(RetrieveUpdateDestroyAPI):
|
class CustomStateDetail(RetrieveUpdateDestroyAPI):
|
||||||
|
@@ -36,7 +36,7 @@ export const useGlobalStatusState = create<ServerStateProps>()(
|
|||||||
const newStatusLookup: StatusLookup = {} as StatusLookup;
|
const newStatusLookup: StatusLookup = {} as StatusLookup;
|
||||||
for (const key in response.data) {
|
for (const key in response.data) {
|
||||||
newStatusLookup[statusCodeList[key] || key] = {
|
newStatusLookup[statusCodeList[key] || key] = {
|
||||||
statusClass: key,
|
status_class: key,
|
||||||
values: response.data[key].values
|
values: response.data[key].values
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ import { apiUrl } from '../../states/ApiState';
|
|||||||
import { useGlobalStatusState } from '../../states/StatusState';
|
import { useGlobalStatusState } from '../../states/StatusState';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
import type { TableColumn } from '../Column';
|
import type { TableColumn } from '../Column';
|
||||||
|
import type { TableFilter } from '../Filter';
|
||||||
import { InvenTreeTable } from '../InvenTreeTable';
|
import { InvenTreeTable } from '../InvenTreeTable';
|
||||||
import { type RowAction, RowDeleteAction, RowEditAction } from '../RowActions';
|
import { type RowAction, RowDeleteAction, RowEditAction } from '../RowActions';
|
||||||
|
|
||||||
@@ -43,13 +44,29 @@ export default function CustomStateTable() {
|
|||||||
(value: StatusCodeInterface) => value.key === key
|
(value: StatusCodeInterface) => value.key === key
|
||||||
);
|
);
|
||||||
|
|
||||||
return value?.label ?? '';
|
return value?.label ?? value?.name ?? '';
|
||||||
},
|
},
|
||||||
[statusCodes]
|
[statusCodes]
|
||||||
);
|
);
|
||||||
|
|
||||||
const user = useUserState();
|
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(() => {
|
const columns: TableColumn[] = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -173,6 +190,7 @@ export default function CustomStateTable() {
|
|||||||
props={{
|
props={{
|
||||||
rowActions: rowActions,
|
rowActions: rowActions,
|
||||||
tableActions: tableActions,
|
tableActions: tableActions,
|
||||||
|
tableFilters: tableFilters,
|
||||||
enableDownload: true
|
enableDownload: true
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Reference in New Issue
Block a user