mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-16 17:28:11 +00:00
Add parametric tables for company views
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
IconBuildingStore,
|
IconBuildingStore,
|
||||||
IconBuildingWarehouse,
|
IconBuildingWarehouse,
|
||||||
IconCalendar,
|
IconCalendar,
|
||||||
|
IconListDetails,
|
||||||
IconPackageExport,
|
IconPackageExport,
|
||||||
IconShoppingCart,
|
IconShoppingCart,
|
||||||
IconTable
|
IconTable
|
||||||
@@ -21,6 +22,7 @@ import { PanelGroup } from '../../components/panels/PanelGroup';
|
|||||||
import SegmentedControlPanel from '../../components/panels/SegmentedControlPanel';
|
import SegmentedControlPanel from '../../components/panels/SegmentedControlPanel';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
import { CompanyTable } from '../../tables/company/CompanyTable';
|
import { CompanyTable } from '../../tables/company/CompanyTable';
|
||||||
|
import ParametricCompanyTable from '../../tables/company/ParametericCompanyTable';
|
||||||
import { ManufacturerPartTable } from '../../tables/purchasing/ManufacturerPartTable';
|
import { ManufacturerPartTable } from '../../tables/purchasing/ManufacturerPartTable';
|
||||||
import { PurchaseOrderTable } from '../../tables/purchasing/PurchaseOrderTable';
|
import { PurchaseOrderTable } from '../../tables/purchasing/PurchaseOrderTable';
|
||||||
import { SupplierPartTable } from '../../tables/purchasing/SupplierPartTable';
|
import { SupplierPartTable } from '../../tables/purchasing/SupplierPartTable';
|
||||||
@@ -33,6 +35,16 @@ export default function PurchasingIndex() {
|
|||||||
defaultValue: 'table'
|
defaultValue: 'table'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [supplierView, setSupplierView] = useLocalStorage<string>({
|
||||||
|
key: 'supplier-view',
|
||||||
|
defaultValue: 'table'
|
||||||
|
});
|
||||||
|
|
||||||
|
const [manufacturerView, setManufacturerView] = useLocalStorage<string>({
|
||||||
|
key: 'manufacturer-view',
|
||||||
|
defaultValue: 'table'
|
||||||
|
});
|
||||||
|
|
||||||
const panels = useMemo(() => {
|
const panels = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
SegmentedControlPanel({
|
SegmentedControlPanel({
|
||||||
@@ -63,34 +75,68 @@ export default function PurchasingIndex() {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
{
|
SegmentedControlPanel({
|
||||||
name: 'suppliers',
|
name: 'suppliers',
|
||||||
label: t`Suppliers`,
|
label: t`Suppliers`,
|
||||||
icon: <IconBuildingStore />,
|
icon: <IconBuildingStore />,
|
||||||
content: (
|
selection: supplierView,
|
||||||
<CompanyTable
|
onChange: setSupplierView,
|
||||||
path='purchasing/supplier'
|
options: [
|
||||||
params={{ is_supplier: true }}
|
{
|
||||||
/>
|
value: 'table',
|
||||||
)
|
label: t`Table View`,
|
||||||
},
|
icon: <IconTable />,
|
||||||
|
content: (
|
||||||
|
<CompanyTable
|
||||||
|
path='purchasing/supplier'
|
||||||
|
params={{ is_supplier: true }}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'parametric',
|
||||||
|
label: t`Parametric View`,
|
||||||
|
icon: <IconListDetails />,
|
||||||
|
content: (
|
||||||
|
<ParametricCompanyTable queryParams={{ is_supplier: true }} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
name: 'supplier-parts',
|
name: 'supplier-parts',
|
||||||
label: t`Supplier Parts`,
|
label: t`Supplier Parts`,
|
||||||
icon: <IconPackageExport />,
|
icon: <IconPackageExport />,
|
||||||
content: <SupplierPartTable />
|
content: <SupplierPartTable />
|
||||||
},
|
},
|
||||||
{
|
SegmentedControlPanel({
|
||||||
name: 'manufacturer',
|
name: 'manufacturer',
|
||||||
label: t`Manufacturers`,
|
label: t`Manufacturers`,
|
||||||
icon: <IconBuildingFactory2 />,
|
icon: <IconBuildingFactory2 />,
|
||||||
content: (
|
selection: manufacturerView,
|
||||||
<CompanyTable
|
onChange: setManufacturerView,
|
||||||
path='purchasing/manufacturer'
|
options: [
|
||||||
params={{ is_manufacturer: true }}
|
{
|
||||||
/>
|
value: 'table',
|
||||||
)
|
label: t`Table View`,
|
||||||
},
|
icon: <IconTable />,
|
||||||
|
content: (
|
||||||
|
<CompanyTable
|
||||||
|
path='purchasing/manufacturer'
|
||||||
|
params={{ is_manufacturer: true }}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'parametric',
|
||||||
|
label: t`Parametric View`,
|
||||||
|
icon: <IconListDetails />,
|
||||||
|
content: (
|
||||||
|
<ParametricCompanyTable queryParams={{ is_manufacturer: true }} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
name: 'manufacturer-parts',
|
name: 'manufacturer-parts',
|
||||||
label: t`Manufacturer Parts`,
|
label: t`Manufacturer Parts`,
|
||||||
@@ -98,7 +144,7 @@ export default function PurchasingIndex() {
|
|||||||
content: <ManufacturerPartTable />
|
content: <ManufacturerPartTable />
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}, [user, purchaseOrderView]);
|
}, [user, manufacturerView, purchaseOrderView, supplierView]);
|
||||||
|
|
||||||
if (!user.isLoggedIn() || !user.hasViewRole(UserRoles.purchase_order)) {
|
if (!user.isLoggedIn() || !user.hasViewRole(UserRoles.purchase_order)) {
|
||||||
return <PermissionDenied />;
|
return <PermissionDenied />;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
IconBuildingStore,
|
IconBuildingStore,
|
||||||
IconCalendar,
|
IconCalendar,
|
||||||
IconCubeSend,
|
IconCubeSend,
|
||||||
|
IconListDetails,
|
||||||
IconTable,
|
IconTable,
|
||||||
IconTruckDelivery,
|
IconTruckDelivery,
|
||||||
IconTruckReturn
|
IconTruckReturn
|
||||||
@@ -20,6 +21,7 @@ import { PanelGroup } from '../../components/panels/PanelGroup';
|
|||||||
import SegmentedControlPanel from '../../components/panels/SegmentedControlPanel';
|
import SegmentedControlPanel from '../../components/panels/SegmentedControlPanel';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
import { CompanyTable } from '../../tables/company/CompanyTable';
|
import { CompanyTable } from '../../tables/company/CompanyTable';
|
||||||
|
import ParametricCompanyTable from '../../tables/company/ParametericCompanyTable';
|
||||||
import { ReturnOrderTable } from '../../tables/sales/ReturnOrderTable';
|
import { ReturnOrderTable } from '../../tables/sales/ReturnOrderTable';
|
||||||
import SalesOrderShipmentTable from '../../tables/sales/SalesOrderShipmentTable';
|
import SalesOrderShipmentTable from '../../tables/sales/SalesOrderShipmentTable';
|
||||||
import { SalesOrderTable } from '../../tables/sales/SalesOrderTable';
|
import { SalesOrderTable } from '../../tables/sales/SalesOrderTable';
|
||||||
@@ -27,13 +29,18 @@ import { SalesOrderTable } from '../../tables/sales/SalesOrderTable';
|
|||||||
export default function SalesIndex() {
|
export default function SalesIndex() {
|
||||||
const user = useUserState();
|
const user = useUserState();
|
||||||
|
|
||||||
|
const [customersView, setCustomersView] = useLocalStorage<string>({
|
||||||
|
key: 'customer-view',
|
||||||
|
defaultValue: 'table'
|
||||||
|
});
|
||||||
|
|
||||||
const [salesOrderView, setSalesOrderView] = useLocalStorage<string>({
|
const [salesOrderView, setSalesOrderView] = useLocalStorage<string>({
|
||||||
key: 'salesOrderView',
|
key: 'sales-order-view',
|
||||||
defaultValue: 'table'
|
defaultValue: 'table'
|
||||||
});
|
});
|
||||||
|
|
||||||
const [returnOrderView, setReturnOrderView] = useLocalStorage<string>({
|
const [returnOrderView, setReturnOrderView] = useLocalStorage<string>({
|
||||||
key: 'returnOrderView',
|
key: 'return-order-view',
|
||||||
defaultValue: 'table'
|
defaultValue: 'table'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,16 +114,36 @@ export default function SalesIndex() {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
{
|
SegmentedControlPanel({
|
||||||
name: 'customers',
|
name: 'customers',
|
||||||
label: t`Customers`,
|
label: t`Customers`,
|
||||||
icon: <IconBuildingStore />,
|
icon: <IconBuildingStore />,
|
||||||
content: (
|
selection: customersView,
|
||||||
<CompanyTable path='sales/customer' params={{ is_customer: true }} />
|
onChange: setCustomersView,
|
||||||
)
|
options: [
|
||||||
}
|
{
|
||||||
|
value: 'table',
|
||||||
|
label: t`Table View`,
|
||||||
|
icon: <IconTable />,
|
||||||
|
content: (
|
||||||
|
<CompanyTable
|
||||||
|
path='sales/customer'
|
||||||
|
params={{ is_customer: true }}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'parametric',
|
||||||
|
label: t`Parametric View`,
|
||||||
|
icon: <IconListDetails />,
|
||||||
|
content: (
|
||||||
|
<ParametricCompanyTable queryParams={{ is_customer: true }} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
];
|
];
|
||||||
}, [user, salesOrderView, returnOrderView]);
|
}, [user, customersView, salesOrderView, returnOrderView]);
|
||||||
|
|
||||||
if (!user.isLoggedIn() || !user.hasViewRole(UserRoles.sales_order)) {
|
if (!user.isLoggedIn() || !user.hasViewRole(UserRoles.sales_order)) {
|
||||||
return <PermissionDenied />;
|
return <PermissionDenied />;
|
||||||
|
|||||||
39
src/frontend/src/tables/company/ParametericCompanyTable.tsx
Normal file
39
src/frontend/src/tables/company/ParametericCompanyTable.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||||
|
import { ModelType } from '@lib/enums/ModelType';
|
||||||
|
import type { TableColumn } from '@lib/types/Tables';
|
||||||
|
import { t } from '@lingui/core/macro';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import { CompanyColumn, DescriptionColumn } from '../ColumnRenderers';
|
||||||
|
import ParametricDataTable from '../general/ParametricDataTable';
|
||||||
|
|
||||||
|
export default function ParametricCompanyTable({
|
||||||
|
queryParams
|
||||||
|
}: {
|
||||||
|
queryParams?: any;
|
||||||
|
}) {
|
||||||
|
const customColumns: TableColumn[] = useMemo(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
accessor: 'name',
|
||||||
|
title: t`Company`,
|
||||||
|
sortable: true,
|
||||||
|
switchable: false,
|
||||||
|
render: (record: any) => {
|
||||||
|
return <CompanyColumn company={record} />;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DescriptionColumn({})
|
||||||
|
];
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ParametricDataTable
|
||||||
|
modelType={ModelType.company}
|
||||||
|
endpoint={ApiEndpoints.company_list}
|
||||||
|
customColumns={customColumns}
|
||||||
|
queryParams={{
|
||||||
|
...queryParams
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -124,7 +124,8 @@ export default function ParametricDataTable({
|
|||||||
.get(apiUrl(ApiEndpoints.parameter_template_list), {
|
.get(apiUrl(ApiEndpoints.parameter_template_list), {
|
||||||
params: {
|
params: {
|
||||||
active: true,
|
active: true,
|
||||||
for_model: modelType
|
for_model: modelType,
|
||||||
|
exists_for_model: modelType
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((response) => response.data);
|
.then((response) => response.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user