mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-09 15:10:54 +00:00
Data output table (#9984)
* Allow DataOutput to be deleted individually via API * Add row actoins for data-export table * Filter table by user * Bump API version
This commit is contained in:
@ -1,12 +1,16 @@
|
|||||||
"""InvenTree API version information."""
|
"""InvenTree API version information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 364
|
INVENTREE_API_VERSION = 365
|
||||||
|
|
||||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
INVENTREE_API_TEXT = """
|
||||||
|
|
||||||
|
v365 -> 2025-07-09 : https://github.com/inventree/InvenTree/pull/9984
|
||||||
|
- Allow filtering of DataOutput API by "user" field
|
||||||
|
- Allow individual deletion of DataOutput objects via the API
|
||||||
|
|
||||||
v364 -> 2025-07-06 : https://github.com/inventree/InvenTree/pull/9962
|
v364 -> 2025-07-06 : https://github.com/inventree/InvenTree/pull/9962
|
||||||
- Fix permissions for the DataImportSession API endpoints
|
- Fix permissions for the DataImportSession API endpoints
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ from djmoney.contrib.exchange.models import ExchangeBackend, Rate
|
|||||||
from drf_spectacular.utils import OpenApiResponse, extend_schema
|
from drf_spectacular.utils import OpenApiResponse, extend_schema
|
||||||
from error_report.models import Error
|
from error_report.models import Error
|
||||||
from pint._typing import UnitLike
|
from pint._typing import UnitLike
|
||||||
from rest_framework import serializers
|
from rest_framework import generics, serializers
|
||||||
from rest_framework.exceptions import NotAcceptable, NotFound, PermissionDenied
|
from rest_framework.exceptions import NotAcceptable, NotFound, PermissionDenied
|
||||||
from rest_framework.permissions import IsAdminUser, IsAuthenticated
|
from rest_framework.permissions import IsAdminUser, IsAuthenticated
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
@ -852,9 +852,10 @@ class DataOutputList(DataOutputEndpointMixin, BulkDeleteMixin, ListAPI):
|
|||||||
|
|
||||||
filter_backends = SEARCH_ORDER_FILTER
|
filter_backends = SEARCH_ORDER_FILTER
|
||||||
ordering_fields = ['pk', 'user', 'plugin', 'output_type', 'created']
|
ordering_fields = ['pk', 'user', 'plugin', 'output_type', 'created']
|
||||||
|
filterset_fields = ['user']
|
||||||
|
|
||||||
|
|
||||||
class DataOutputDetail(DataOutputEndpointMixin, RetrieveAPI):
|
class DataOutputDetail(DataOutputEndpointMixin, generics.DestroyAPIView, RetrieveAPI):
|
||||||
"""Detail view for a DataOutput object."""
|
"""Detail view for a DataOutput object."""
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||||
import { apiUrl } from '@lib/functions/Api';
|
import { apiUrl } from '@lib/functions/Api';
|
||||||
|
import type { TableFilter } from '@lib/types/Filters';
|
||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { useMemo } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import { AttachmentLink } from '../../components/items/AttachmentLink';
|
import { AttachmentLink } from '../../components/items/AttachmentLink';
|
||||||
import { RenderUser } from '../../components/render/User';
|
import { RenderUser } from '../../components/render/User';
|
||||||
|
import { useDeleteApiFormModal } from '../../hooks/UseForm';
|
||||||
import { useTable } from '../../hooks/UseTable';
|
import { useTable } from '../../hooks/UseTable';
|
||||||
import type { TableColumn } from '../Column';
|
import type { TableColumn } from '../Column';
|
||||||
import { DateColumn } from '../ColumnRenderers';
|
import { DateColumn } from '../ColumnRenderers';
|
||||||
|
import { UserFilter } from '../Filter';
|
||||||
import { InvenTreeTable } from '../InvenTreeTable';
|
import { InvenTreeTable } from '../InvenTreeTable';
|
||||||
|
import { type RowAction, RowDeleteAction } from '../RowActions';
|
||||||
|
|
||||||
export default function ExportSessionTable() {
|
export default function ExportSessionTable() {
|
||||||
const table = useTable('exportsession');
|
const table = useTable('exportsession');
|
||||||
@ -43,8 +47,33 @@ export default function ExportSessionTable() {
|
|||||||
];
|
];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const tableFilters: TableFilter[] = useMemo(() => {
|
||||||
|
return [UserFilter({})];
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const [selectedRow, setSeletectedRow] = useState<any>({});
|
||||||
|
|
||||||
|
const deleteRow = useDeleteApiFormModal({
|
||||||
|
url: ApiEndpoints.data_output,
|
||||||
|
pk: selectedRow.pk,
|
||||||
|
title: t`Delete Output`,
|
||||||
|
onFormSuccess: () => table.refreshTable()
|
||||||
|
});
|
||||||
|
|
||||||
|
const rowActions = useCallback((record: any): RowAction[] => {
|
||||||
|
return [
|
||||||
|
RowDeleteAction({
|
||||||
|
onClick: () => {
|
||||||
|
setSeletectedRow(record);
|
||||||
|
deleteRow.open();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{deleteRow.modal}
|
||||||
<InvenTreeTable
|
<InvenTreeTable
|
||||||
url={apiUrl(ApiEndpoints.data_output)}
|
url={apiUrl(ApiEndpoints.data_output)}
|
||||||
tableState={table}
|
tableState={table}
|
||||||
@ -52,7 +81,9 @@ export default function ExportSessionTable() {
|
|||||||
props={{
|
props={{
|
||||||
enableBulkDelete: true,
|
enableBulkDelete: true,
|
||||||
enableSelection: true,
|
enableSelection: true,
|
||||||
enableSearch: false
|
enableSearch: false,
|
||||||
|
rowActions: rowActions,
|
||||||
|
tableFilters: tableFilters
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
Reference in New Issue
Block a user