mirror of
https://github.com/inventree/InvenTree.git
synced 2026-07-04 06:00:38 +00:00
Allow stock adjustment from "category" detail view (#12256)
This commit is contained in:
@@ -16,6 +16,7 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||
import { ModelType } from '@lib/enums/ModelType';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import type { PanelType } from '@lib/types/Panel';
|
||||
import { useLocalStorage } from '@mantine/hooks';
|
||||
import AdminButton from '../../components/buttons/AdminButton';
|
||||
@@ -43,6 +44,7 @@ import {
|
||||
useEditApiFormModal
|
||||
} from '../../hooks/UseForm';
|
||||
import { useInstance } from '../../hooks/UseInstance';
|
||||
import { useStockAdjustActions } from '../../hooks/UseStockAdjustActions';
|
||||
import { useUserSettingsState } from '../../states/SettingsStates';
|
||||
import { useUserState } from '../../states/UserState';
|
||||
import ParametricPartTable from '../../tables/part/ParametricPartTable';
|
||||
@@ -82,6 +84,28 @@ export default function CategoryDetail() {
|
||||
}
|
||||
});
|
||||
|
||||
const stockOperationProps: StockOperationProps = useMemo(() => {
|
||||
return {
|
||||
refresh: refreshInstance,
|
||||
filters: {
|
||||
category: category.pk,
|
||||
in_stock: true
|
||||
}
|
||||
};
|
||||
}, [category]);
|
||||
|
||||
const stockAdjustActions = useStockAdjustActions({
|
||||
formProps: stockOperationProps,
|
||||
enabled: true,
|
||||
add: false,
|
||||
remove: false,
|
||||
changeStatus: false,
|
||||
changeBatch: false,
|
||||
delete: false,
|
||||
merge: false,
|
||||
assign: false
|
||||
});
|
||||
|
||||
const detailsPanel = useMemo(() => {
|
||||
if (id && instanceQuery.isFetching) {
|
||||
return <Skeleton />;
|
||||
@@ -241,6 +265,7 @@ export default function CategoryDetail() {
|
||||
refreshInstance();
|
||||
}}
|
||||
/>,
|
||||
stockAdjustActions.dropdown,
|
||||
<OptionsActionDropdown
|
||||
key='category-actions'
|
||||
tooltip={t`Category Actions`}
|
||||
@@ -258,7 +283,7 @@ export default function CategoryDetail() {
|
||||
]}
|
||||
/>
|
||||
];
|
||||
}, [id, user, category.pk, category.starred]);
|
||||
}, [id, user, category.pk, category.starred, stockAdjustActions.dropdown]);
|
||||
|
||||
const [partsView, setPartsView] = useLocalStorage<string>({
|
||||
key: 'category-parts-view',
|
||||
@@ -367,6 +392,7 @@ export default function CategoryDetail() {
|
||||
<>
|
||||
{editCategory.modal}
|
||||
{deleteCategory.modal}
|
||||
{stockAdjustActions.modals.map((modal) => modal.modal)}
|
||||
<InstanceDetail
|
||||
query={instanceQuery}
|
||||
requiredRole={UserRoles.part_category}
|
||||
|
||||
Reference in New Issue
Block a user