mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-18 15:12:23 +00:00
Plugin stock forms (#10584)
* Expose stock adjustment forms to plugins * Update changelog * Expand type exports * Update CHANGELOG.md
This commit is contained in:
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added much more detailed status information for machines to the API endpoint (including backend and frontend changes) in [#10381](https://github.com/inventree/InvenTree/pull/10381)
|
||||
- Added ability to partially complete and partially scrap build outputs in [#10499](https://github.com/inventree/InvenTree/pull/10499)
|
||||
- Added support for Redis ACL user-based authentication in [#10551](https://github.com/inventree/InvenTree/pull/10551)
|
||||
- Expose stock adjustment forms to the UI plugin context in [#10584](https://github.com/inventree/InvenTree/pull/10584)
|
||||
|
||||
### Changed
|
||||
|
||||
|
@@ -2,6 +2,14 @@
|
||||
|
||||
This file contains historical changelog information for the InvenTree UI components library.
|
||||
|
||||
### 0.7.0 - October 2025
|
||||
|
||||
Exposes stock adjustment forms to plugins, allowing plugins to adjust stock adjustments using the common InvenTree UI form components.
|
||||
|
||||
### 0.6.0 - September 2025
|
||||
|
||||
Updated underlying Mantine library versions.
|
||||
|
||||
### 0.5.0 - August 2025
|
||||
|
||||
This release updates the base `react` major version from `18.3.1` to `19.1.1`. This change may introduce breaking changes for plugins that rely on the InvenTree UI components library (plugin developers should test their plugins against this new version).
|
||||
|
@@ -12,7 +12,12 @@ export { ModelType } from './enums/ModelType';
|
||||
export type { ModelDict } from './enums/ModelInformation';
|
||||
export { UserRoles, UserPermissions } from './enums/Roles';
|
||||
|
||||
export type { InvenTreePluginContext } from './types/Plugins';
|
||||
export type {
|
||||
InvenTreePluginContext,
|
||||
InvenTreeFormsContext,
|
||||
PluginVersion,
|
||||
StockAdjustmentFormsContext
|
||||
} from './types/Plugins';
|
||||
export type { RowAction, RowViewProps } from './types/Tables';
|
||||
|
||||
export type {
|
||||
@@ -25,6 +30,11 @@ export type {
|
||||
BulkEditApiFormModalProps
|
||||
} from './types/Forms';
|
||||
|
||||
export type {
|
||||
UseModalProps,
|
||||
UseModalReturn
|
||||
} from './types/Modals';
|
||||
|
||||
// Common utility functions
|
||||
export { apiUrl } from './functions/Api';
|
||||
export {
|
||||
|
@@ -191,3 +191,11 @@ export interface ApiFormModalProps extends ApiFormProps {
|
||||
export interface BulkEditApiFormModalProps extends ApiFormModalProps {
|
||||
items: number[];
|
||||
}
|
||||
|
||||
export type StockOperationProps = {
|
||||
items?: any[];
|
||||
pk?: number;
|
||||
filters?: any;
|
||||
model: ModelType.stockitem | 'location' | ModelType.part;
|
||||
refresh: () => void;
|
||||
};
|
||||
|
@@ -5,7 +5,11 @@ import type { AxiosInstance } from 'axios';
|
||||
import type { NavigateFunction } from 'react-router-dom';
|
||||
import type { ModelDict } from '../enums/ModelInformation';
|
||||
import type { ModelType } from '../enums/ModelType';
|
||||
import type { ApiFormModalProps, BulkEditApiFormModalProps } from './Forms';
|
||||
import type {
|
||||
ApiFormModalProps,
|
||||
BulkEditApiFormModalProps,
|
||||
StockOperationProps
|
||||
} from './Forms';
|
||||
import type { UseModalReturn } from './Modals';
|
||||
import type { RenderInstanceProps } from './Rendering';
|
||||
import type { SettingsStateProps } from './Settings';
|
||||
@@ -24,11 +28,24 @@ export interface PluginVersion {
|
||||
mantine: string;
|
||||
}
|
||||
|
||||
export type StockAdjustmentFormsContext = {
|
||||
addStock: (props: StockOperationProps) => UseModalReturn;
|
||||
assignStock: (props: StockOperationProps) => UseModalReturn;
|
||||
changeStatus: (props: StockOperationProps) => UseModalReturn;
|
||||
countStock: (props: StockOperationProps) => UseModalReturn;
|
||||
deleteStock: (props: StockOperationProps) => UseModalReturn;
|
||||
mergeStock: (props: StockOperationProps) => UseModalReturn;
|
||||
removeStock: (props: StockOperationProps) => UseModalReturn;
|
||||
transferStock: (props: StockOperationProps) => UseModalReturn;
|
||||
returnStock: (props: StockOperationProps) => UseModalReturn;
|
||||
};
|
||||
|
||||
export type InvenTreeFormsContext = {
|
||||
bulkEdit: (props: BulkEditApiFormModalProps) => UseModalReturn;
|
||||
create: (props: ApiFormModalProps) => UseModalReturn;
|
||||
delete: (props: ApiFormModalProps) => UseModalReturn;
|
||||
edit: (props: ApiFormModalProps) => UseModalReturn;
|
||||
stockActions: StockAdjustmentFormsContext;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@inventreedb/ui",
|
||||
"description": "UI components for the InvenTree project",
|
||||
"version": "0.6.0",
|
||||
"version": "0.7.0",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
@@ -18,6 +18,17 @@ import {
|
||||
type InvenTreePluginContext
|
||||
} from '@lib/types/Plugins';
|
||||
import { i18n } from '@lingui/core';
|
||||
import {
|
||||
useAddStockItem,
|
||||
useAssignStockItem,
|
||||
useChangeStockStatus,
|
||||
useCountStockItem,
|
||||
useDeleteStockItem,
|
||||
useMergeStockItem,
|
||||
useRemoveStockItem,
|
||||
useReturnStockItem,
|
||||
useTransferStockItem
|
||||
} from '../../forms/StockForms';
|
||||
import {
|
||||
useBulkEditApiFormModal,
|
||||
useCreateApiFormModal,
|
||||
@@ -60,7 +71,18 @@ export const useInvenTreeContext = () => {
|
||||
bulkEdit: useBulkEditApiFormModal,
|
||||
create: useCreateApiFormModal,
|
||||
delete: useDeleteApiFormModal,
|
||||
edit: useEditApiFormModal
|
||||
edit: useEditApiFormModal,
|
||||
stockActions: {
|
||||
addStock: useAddStockItem,
|
||||
assignStock: useAssignStockItem,
|
||||
changeStatus: useChangeStockStatus,
|
||||
countStock: useCountStockItem,
|
||||
deleteStock: useDeleteStockItem,
|
||||
mergeStock: useMergeStockItem,
|
||||
removeStock: useRemoveStockItem,
|
||||
transferStock: useTransferStockItem,
|
||||
returnStock: useReturnStockItem
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [
|
||||
|
@@ -37,7 +37,8 @@ import type {
|
||||
ApiFormAdjustFilterType,
|
||||
ApiFormFieldChoice,
|
||||
ApiFormFieldSet,
|
||||
ApiFormModalProps
|
||||
ApiFormModalProps,
|
||||
StockOperationProps
|
||||
} from '@lib/types/Forms';
|
||||
import {
|
||||
TableFieldExtraRow,
|
||||
@@ -1172,14 +1173,6 @@ function useStockOperationModal({
|
||||
});
|
||||
}
|
||||
|
||||
export type StockOperationProps = {
|
||||
items?: any[];
|
||||
pk?: number;
|
||||
filters?: any;
|
||||
model: ModelType.stockitem | 'location' | ModelType.part;
|
||||
refresh: () => void;
|
||||
};
|
||||
|
||||
export function useAddStockItem(props: StockOperationProps) {
|
||||
return useStockOperationModal({
|
||||
...props,
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { UserRoles } from '@lib/index';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import type { UseModalReturn } from '@lib/types/Modals';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { type ReactNode, useMemo } from 'react';
|
||||
import type { ActionDropdownItem } from '../components/items/ActionDropdown';
|
||||
import { ActionDropdown } from '../components/items/ActionDropdown';
|
||||
import {
|
||||
type StockOperationProps,
|
||||
useAddStockItem,
|
||||
useAssignStockItem,
|
||||
useChangeStockStatus,
|
||||
@@ -54,8 +54,8 @@ export function useStockAdjustActions(
|
||||
// The available modals for stock adjustment actions
|
||||
const addStock = useAddStockItem(props.formProps);
|
||||
const assignStock = useAssignStockItem(props.formProps);
|
||||
const countStock = useCountStockItem(props.formProps);
|
||||
const changeStatus = useChangeStockStatus(props.formProps);
|
||||
const countStock = useCountStockItem(props.formProps);
|
||||
const deleteStock = useDeleteStockItem(props.formProps);
|
||||
const mergeStock = useMergeStockItem(props.formProps);
|
||||
const removeStock = useRemoveStockItem(props.formProps);
|
||||
|
@@ -47,7 +47,7 @@ import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||
import { ActionButton } from '@lib/index';
|
||||
import type { ApiFormFieldSet } from '@lib/types/Forms';
|
||||
import type { ApiFormFieldSet, StockOperationProps } from '@lib/types/Forms';
|
||||
import AdminButton from '../../components/buttons/AdminButton';
|
||||
import { PrintingActions } from '../../components/buttons/PrintingActions';
|
||||
import StarredToggleButton from '../../components/buttons/StarredToggleButton';
|
||||
@@ -80,10 +80,7 @@ import OrderPartsWizard from '../../components/wizards/OrderPartsWizard';
|
||||
import { useApi } from '../../contexts/ApiContext';
|
||||
import { formatDecimal, formatPriceRange } from '../../defaults/formatters';
|
||||
import { usePartFields } from '../../forms/PartForms';
|
||||
import {
|
||||
type StockOperationProps,
|
||||
useFindSerialNumberForm
|
||||
} from '../../forms/StockForms';
|
||||
import { useFindSerialNumberForm } from '../../forms/StockForms';
|
||||
import {
|
||||
useApiFormModal,
|
||||
useCreateApiFormModal,
|
||||
|
@@ -3,6 +3,7 @@ import { ModelType } from '@lib/enums/ModelType';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { Group, Skeleton, Stack, Text } from '@mantine/core';
|
||||
import { IconInfoCircle, IconPackages, IconSitemap } from '@tabler/icons-react';
|
||||
@@ -30,10 +31,7 @@ import { PageDetail } from '../../components/nav/PageDetail';
|
||||
import type { PanelType } from '../../components/panels/Panel';
|
||||
import { PanelGroup } from '../../components/panels/PanelGroup';
|
||||
import LocateItemButton from '../../components/plugins/LocateItemButton';
|
||||
import {
|
||||
type StockOperationProps,
|
||||
stockLocationFields
|
||||
} from '../../forms/StockForms';
|
||||
import { stockLocationFields } from '../../forms/StockForms';
|
||||
import { InvenTreeIcon } from '../../functions/icons';
|
||||
import {
|
||||
useDeleteApiFormModal,
|
||||
|
@@ -33,6 +33,7 @@ import { ModelType } from '@lib/enums/ModelType';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { useBarcodeScanDialog } from '../../components/barcodes/BarcodeScanDialog';
|
||||
import AdminButton from '../../components/buttons/AdminButton';
|
||||
@@ -66,7 +67,6 @@ import OrderPartsWizard from '../../components/wizards/OrderPartsWizard';
|
||||
import { useApi } from '../../contexts/ApiContext';
|
||||
import { formatCurrency, formatDecimal } from '../../defaults/formatters';
|
||||
import {
|
||||
type StockOperationProps,
|
||||
useFindSerialNumberForm,
|
||||
useStockFields,
|
||||
useStockItemSerializeFields
|
||||
|
@@ -12,10 +12,10 @@ import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { ActionButton } from '@lib/index';
|
||||
import type { TableFilter } from '@lib/types/Filters';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import type { TableColumn } from '@lib/types/Tables';
|
||||
import { IconCircleDashedCheck } from '@tabler/icons-react';
|
||||
import { useConsumeBuildItemsForm } from '../../forms/BuildForms';
|
||||
import type { StockOperationProps } from '../../forms/StockForms';
|
||||
import {
|
||||
useDeleteApiFormModal,
|
||||
useEditApiFormModal
|
||||
|
@@ -33,6 +33,7 @@ import { ModelType } from '@lib/enums/ModelType';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import type { TableFilter } from '@lib/types/Filters';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import type { TableColumn } from '@lib/types/Tables';
|
||||
import { StylishText } from '../../components/items/StylishText';
|
||||
import { useApi } from '../../contexts/ApiContext';
|
||||
@@ -43,7 +44,6 @@ import {
|
||||
useScrapBuildOutputsForm
|
||||
} from '../../forms/BuildForms';
|
||||
import {
|
||||
type StockOperationProps,
|
||||
useStockFields,
|
||||
useStockItemSerializeFields
|
||||
} from '../../forms/StockForms';
|
||||
|
@@ -12,11 +12,11 @@ import { ModelType } from '@lib/enums/ModelType';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import type { TableFilter } from '@lib/types/Filters';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import type { TableColumn } from '@lib/types/Tables';
|
||||
import { IconTruckDelivery } from '@tabler/icons-react';
|
||||
import { formatDate } from '../../defaults/formatters';
|
||||
import { useSalesOrderAllocationFields } from '../../forms/SalesOrderForms';
|
||||
import type { StockOperationProps } from '../../forms/StockForms';
|
||||
import {
|
||||
useBulkEditApiFormModal,
|
||||
useDeleteApiFormModal,
|
||||
|
@@ -11,6 +11,7 @@ import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||
import type { TableFilter } from '@lib/types/Filters';
|
||||
import type { StockOperationProps } from '@lib/types/Forms';
|
||||
import type { TableColumn } from '@lib/types/Tables';
|
||||
import OrderPartsWizard from '../../components/wizards/OrderPartsWizard';
|
||||
import {
|
||||
@@ -18,10 +19,7 @@ import {
|
||||
formatDecimal,
|
||||
formatPriceRange
|
||||
} from '../../defaults/formatters';
|
||||
import {
|
||||
type StockOperationProps,
|
||||
useStockFields
|
||||
} from '../../forms/StockForms';
|
||||
import { useStockFields } from '../../forms/StockForms';
|
||||
import { InvenTreeIcon } from '../../functions/icons';
|
||||
import { useCreateApiFormModal } from '../../hooks/UseForm';
|
||||
import { useStockAdjustActions } from '../../hooks/UseStockAdjustActions';
|
||||
|
Reference in New Issue
Block a user