2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-11-14 03:46:44 +00:00

[PUI] Allocation Tables (#7836)

* Skeleton panel and placeholder tables

* Implement build order allocation table

* Refactor and repurpose existing table

* Add allocations table to stock item page

* Skeleton for <SalesOrderAllocationTable />

* Implement sales order allocation table(s)
This commit is contained in:
Oliver
2024-08-08 15:43:11 +10:00
committed by GitHub
parent dce6cf6b01
commit 90a918e6d2
9 changed files with 335 additions and 30 deletions

View File

@@ -12,7 +12,12 @@ import { useTable } from '../../hooks/UseTable';
import { apiUrl } from '../../states/ApiState';
import { useUserState } from '../../states/UserState';
import { TableColumn } from '../Column';
import { LocationColumn, PartColumn } from '../ColumnRenderers';
import {
LocationColumn,
PartColumn,
ReferenceColumn,
StatusColumn
} from '../ColumnRenderers';
import { TableFilter } from '../Filter';
import { InvenTreeTable } from '../InvenTreeTable';
import { RowDeleteAction, RowEditAction } from '../RowActions';
@@ -21,12 +26,26 @@ import { RowDeleteAction, RowEditAction } from '../RowActions';
* Render a table of allocated stock for a build.
*/
export default function BuildAllocatedStockTable({
buildId
buildId,
stockId,
partId,
showBuildInfo,
showPartInfo,
allowEdit,
modelTarget,
modelField
}: {
buildId: number;
buildId?: number;
stockId?: number;
partId?: number;
showPartInfo?: boolean;
showBuildInfo?: boolean;
allowEdit?: boolean;
modelTarget?: ModelType;
modelField?: string;
}) {
const user = useUserState();
const table = useTable('build-allocated-stock');
const table = useTable('buildallocatedstock');
const tableFilters: TableFilter[] = useMemo(() => {
return [
@@ -40,14 +59,33 @@ export default function BuildAllocatedStockTable({
const tableColumns: TableColumn[] = useMemo(() => {
return [
ReferenceColumn({
accessor: 'build_detail.reference',
title: t`Build Order`,
switchable: false,
hidden: showBuildInfo != true
}),
{
accessor: 'build_detail.title',
title: t`Description`,
hidden: showBuildInfo != true
},
StatusColumn({
accessor: 'build_detail.status',
model: ModelType.build,
title: t`Order Status`,
hidden: showBuildInfo != true
}),
{
accessor: 'part',
hidden: !showPartInfo,
title: t`Part`,
sortable: true,
switchable: false,
render: (record: any) => PartColumn(record.part_detail)
},
{
hidden: !showPartInfo,
accessor: 'bom_reference',
title: t`Reference`,
sortable: true,
@@ -149,18 +187,21 @@ export default function BuildAllocatedStockTable({
props={{
params: {
build: buildId,
part_detail: true,
part: partId,
stock_item: stockId,
build_detail: showBuildInfo ?? false,
part_detail: showPartInfo ?? false,
location_detail: true,
stock_detail: true,
supplier_detail: true
},
enableBulkDelete: user.hasDeleteRole(UserRoles.build),
enableBulkDelete: allowEdit && user.hasDeleteRole(UserRoles.build),
enableDownload: true,
enableSelection: true,
enableSelection: allowEdit && user.hasDeleteRole(UserRoles.build),
rowActions: rowActions,
tableFilters: tableFilters,
modelField: 'stock_item',
modelType: ModelType.stockitem
modelField: modelField ?? 'stock_item',
modelType: modelTarget ?? ModelType.stockitem
}}
/>
</>