mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-20 03:03:30 +00:00
- Closes https://github.com/inventree/InvenTree/issues/10909
- Use global setting values as defaults
(cherry picked from commit 3a18934b83)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
committed by
GitHub
parent
66b71c1f2e
commit
afc1dad8a7
@@ -20,8 +20,12 @@ export function usePartFields({
|
|||||||
}): ApiFormFieldSet {
|
}): ApiFormFieldSet {
|
||||||
const settings = useGlobalSettingsState();
|
const settings = useGlobalSettingsState();
|
||||||
|
|
||||||
const [virtual, setVirtual] = useState<boolean>(false);
|
const globalSettings = useGlobalSettingsState();
|
||||||
const [purchaseable, setPurchaseable] = useState<boolean>(false);
|
|
||||||
|
const [virtual, setVirtual] = useState<boolean | undefined>(undefined);
|
||||||
|
const [purchaseable, setPurchaseable] = useState<boolean | undefined>(
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const fields: ApiFormFieldSet = {
|
const fields: ApiFormFieldSet = {
|
||||||
@@ -60,19 +64,33 @@ export function usePartFields({
|
|||||||
is_active: true
|
is_active: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
component: {},
|
component: {
|
||||||
assembly: {},
|
default: globalSettings.isSet('PART_COMPONENT')
|
||||||
is_template: {},
|
},
|
||||||
testable: {},
|
assembly: {
|
||||||
trackable: {},
|
default: globalSettings.isSet('PART_ASSEMBLY')
|
||||||
|
},
|
||||||
|
is_template: {
|
||||||
|
default: globalSettings.isSet('PART_TEMPLATE')
|
||||||
|
},
|
||||||
|
testable: {
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
trackable: {
|
||||||
|
default: globalSettings.isSet('PART_TRACKABLE')
|
||||||
|
},
|
||||||
purchaseable: {
|
purchaseable: {
|
||||||
value: purchaseable,
|
value: purchaseable,
|
||||||
|
default: globalSettings.isSet('PART_PURCHASEABLE'),
|
||||||
onValueChange: (value: boolean) => {
|
onValueChange: (value: boolean) => {
|
||||||
setPurchaseable(value);
|
setPurchaseable(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
salable: {},
|
salable: {
|
||||||
|
default: globalSettings.isSet('PART_SALABLE')
|
||||||
|
},
|
||||||
virtual: {
|
virtual: {
|
||||||
|
default: globalSettings.isSet('PART_VIRTUAL'),
|
||||||
value: virtual,
|
value: virtual,
|
||||||
onValueChange: (value: boolean) => {
|
onValueChange: (value: boolean) => {
|
||||||
setVirtual(value);
|
setVirtual(value);
|
||||||
@@ -93,7 +111,7 @@ export function usePartFields({
|
|||||||
if (create) {
|
if (create) {
|
||||||
fields.copy_category_parameters = {};
|
fields.copy_category_parameters = {};
|
||||||
|
|
||||||
if (!virtual) {
|
if (virtual != false) {
|
||||||
fields.initial_stock = {
|
fields.initial_stock = {
|
||||||
icon: <IconPackages />,
|
icon: <IconPackages />,
|
||||||
children: {
|
children: {
|
||||||
@@ -176,7 +194,14 @@ export function usePartFields({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}, [virtual, purchaseable, create, duplicatePartInstance, settings]);
|
}, [
|
||||||
|
virtual,
|
||||||
|
purchaseable,
|
||||||
|
create,
|
||||||
|
globalSettings,
|
||||||
|
duplicatePartInstance,
|
||||||
|
settings
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user