Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PUI] Order Parts Wizard #8602

Merged
merged 41 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7b9e96d
Add generic <WizardDrawer />
SchrodingersGat Nov 30, 2024
0b32e9b
Add a wizard hook
SchrodingersGat Nov 30, 2024
da4da7b
Slight refactor
SchrodingersGat Nov 30, 2024
23c4529
Simple placeholder table
SchrodingersGat Nov 30, 2024
2579186
Only purchaseable parts
SchrodingersGat Nov 30, 2024
deda3b4
Add callback to remove selected part
SchrodingersGat Nov 30, 2024
43cddb2
Add step enum
SchrodingersGat Nov 30, 2024
642fc34
Improve wizard
SchrodingersGat Nov 30, 2024
bd4848b
Render supplier image
SchrodingersGat Nov 30, 2024
fda94f8
Add validation checks for wizard
SchrodingersGat Nov 30, 2024
f4d2cb1
Further wizard improvements
SchrodingersGat Nov 30, 2024
bc0f1a7
add error support
SchrodingersGat Nov 30, 2024
c3547aa
Improvements
SchrodingersGat Nov 30, 2024
918eb2b
Refactoring
SchrodingersGat Nov 30, 2024
11a95ee
Add error checking
SchrodingersGat Dec 1, 2024
7ece254
Order from part detail page
SchrodingersGat Dec 1, 2024
2bc96b8
Implement from SalesOrder view
SchrodingersGat Dec 1, 2024
16b0f3e
Implement from build line table
SchrodingersGat Dec 1, 2024
99115b4
Implement from StockItem table
SchrodingersGat Dec 1, 2024
b3fef59
Add to StockDetail page
SchrodingersGat Dec 1, 2024
ae0f7d0
Merge remote-tracking branch 'origin/master' into order-wizard
SchrodingersGat Dec 1, 2024
e3ac842
Cleanup PartTable
SchrodingersGat Dec 1, 2024
bbb37d4
Refactor to use DataTable interface
SchrodingersGat Dec 1, 2024
a5aee9d
Merge remote-tracking branch 'origin/master' into order-wizard
SchrodingersGat Dec 2, 2024
abee5c5
Simplify wizard into single step
SchrodingersGat Dec 2, 2024
60bae83
Refactoring
SchrodingersGat Dec 2, 2024
adde3f9
Allow creation of new supplier part
SchrodingersGat Dec 2, 2024
02f5e6b
Merge branch 'master' into order-wizard
SchrodingersGat Dec 2, 2024
3b0273c
Merge branch 'master' into order-wizard
SchrodingersGat Dec 3, 2024
0b768ab
Merge branch 'master' into order-wizard
SchrodingersGat Dec 9, 2024
f9bb351
Merge branch 'order-wizard' of github.com:SchrodingersGat/InvenTree i…
SchrodingersGat Dec 9, 2024
f585155
Merge branch 'master' into order-wizard
SchrodingersGat Dec 10, 2024
53358b1
Merge branch 'master' into order-wizard
SchrodingersGat Dec 10, 2024
feb43a0
Merge branch 'master' into order-wizard
SchrodingersGat Dec 11, 2024
b968143
Merge remote-tracking branch 'origin/master' into order-wizard
SchrodingersGat Dec 14, 2024
13ed740
Merge branch 'master' into order-wizard
SchrodingersGat Dec 14, 2024
2c97c6d
Cleanup
SchrodingersGat Dec 14, 2024
aa82fea
Refactor <PartDetail>
SchrodingersGat Dec 15, 2024
3ae4f1e
Fix static hook issue
SchrodingersGat Dec 15, 2024
e4413c7
Fix infinite useEffect
SchrodingersGat Dec 15, 2024
216bd26
Playwright tests
SchrodingersGat Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow creation of new supplier part
SchrodingersGat committed Dec 2, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit adde3f95bc711b4e1812d10523e993d5255890fe
24 changes: 23 additions & 1 deletion src/frontend/src/components/wizards/OrderPartsWizard.tsx
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import { DataTable } from 'mantine-datatable';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { useSupplierPartFields } from '../../forms/CompanyForms';
import { usePurchaseOrderFields } from '../../forms/PurchaseOrderForms';
import { useCreateApiFormModal } from '../../hooks/UseForm';
import useWizard from '../../hooks/UseWizard';
@@ -72,6 +73,20 @@ function SelectPartsStep({
}
});

const supplierPartFields = useSupplierPartFields({
partId: selectedRecord?.part.pk
});

const newSupplierPart = useCreateApiFormModal({
url: apiUrl(ApiEndpoints.supplier_part_list),
title: t`New Supplier Part`,
fields: supplierPartFields,
successMessage: t`Supplier part created`,
onFormSuccess: (response: any) => {
onSelectSupplierPart(selectedRecord?.part.pk, response);
}
});

const addToOrderFields: ApiFormFieldSet = useMemo(() => {
return {
order: {
@@ -92,6 +107,11 @@ function SelectPartsStep({
url: apiUrl(ApiEndpoints.purchase_order_line_list),
title: t`Add to Purchase Order`,
fields: addToOrderFields,
initialData: {
order: selectedRecord?.purchase_order?.pk,
part: selectedRecord?.supplier_part?.pk,
quantity: selectedRecord?.quantity
},
onFormSuccess: (response: any) => {
// Remove the row from the list
onRemovePart(selectedRecord?.part);
@@ -155,7 +175,8 @@ function SelectPartsStep({
tooltip={t`New supplier part`}
tooltipAlignment='top'
onClick={() => {
// TODO: Open the new supplier part modal
setSelectedRecord(record);
newSupplierPart.open();
}}
/>
</Group>
@@ -231,6 +252,7 @@ function SelectPartsStep({
<>
<DataTable idAccessor='part.pk' columns={columns} records={records} />
{newPurchaseOrder.modal}
{newSupplierPart.modal}
{addToOrder.modal}
</>
);
11 changes: 9 additions & 2 deletions src/frontend/src/forms/CompanyForms.tsx
Original file line number Diff line number Diff line change
@@ -18,11 +18,18 @@ import type {
/**
* Field set for SupplierPart instance
*/
export function useSupplierPartFields() {
export function useSupplierPartFields({
partId
}: {
partId?: number;
}) {
return useMemo(() => {
const fields: ApiFormFieldSet = {
part: {
value: partId,
disabled: !!partId,
filters: {
part: partId,
purchaseable: true,
active: true
}
@@ -63,7 +70,7 @@ export function useSupplierPartFields() {
};

return fields;
}, []);
}, [partId]);
}

export function useManufacturerPartFields() {
2 changes: 1 addition & 1 deletion src/frontend/src/pages/company/SupplierPartDetail.tsx
Original file line number Diff line number Diff line change
@@ -303,7 +303,7 @@ export default function SupplierPartDetail() {
];
}, [user, supplierPart]);

const supplierPartFields = useSupplierPartFields();
const supplierPartFields = useSupplierPartFields({});

const editSupplierPart = useEditApiFormModal({
url: ApiEndpoints.supplier_part_list,
6 changes: 4 additions & 2 deletions src/frontend/src/tables/purchasing/SupplierPartTable.tsx
Original file line number Diff line number Diff line change
@@ -158,7 +158,9 @@ export function SupplierPartTable({
];
}, [params]);

const supplierPartFields = useSupplierPartFields();
const supplierPartFields = useSupplierPartFields({
partId: params?.part
});

const addSupplierPart = useCreateApiFormModal({
url: ApiEndpoints.supplier_part_list,
@@ -203,7 +205,7 @@ export function SupplierPartTable({
];
}, []);

const editSupplierPartFields = useSupplierPartFields();
const editSupplierPartFields = useSupplierPartFields({});

const [selectedSupplierPart, setSelectedSupplierPart] = useState<number>(0);

Loading