diff --git a/src/client/cypress/e2e/mainPage/bulkedit.cy.js b/src/client/cypress/e2e/mainPage/bulkedit.cy.js index 56e453d8c..2907dd7c8 100644 --- a/src/client/cypress/e2e/mainPage/bulkedit.cy.js +++ b/src/client/cypress/e2e/mainPage/bulkedit.cy.js @@ -131,8 +131,8 @@ describe("Test the borehole bulk edit feature.", () => { cy.get(".MuiAccordionSummary-expandIconWrapper").click({ multiple: true, force: true }); setInput("custom.project_name", "new name"); setSelect("workgroup", 1); - setSelect("restriction", 3); - setSelect("national_interest", 1); + setSelect("restriction", 2); + setSelect("national_interest", 0); let visibleCount = 0; diff --git a/src/client/src/components/form/formSelect.tsx b/src/client/src/components/form/formSelect.tsx index 29d574d90..adc08b835 100644 --- a/src/client/src/components/form/formSelect.tsx +++ b/src/client/src/components/form/formSelect.tsx @@ -16,6 +16,7 @@ export interface FormSelectProps { sx?: SxProps; className?: string; onUpdate?: (value: number | boolean | null) => void; + canReset?: boolean; } export interface FormSelectValue { @@ -41,12 +42,13 @@ export const FormSelect: FC = ({ sx, className, onUpdate, + canReset = true, // option to disable reset in dropdown without using the required rule and error display }) => { const { t } = useTranslation(); const { control } = useFormContext(); const menuItems: FormSelectMenuItem[] = []; - if (!required) { + if (!required && canReset) { menuItems.push({ key: 0, value: undefined, label: t("reset"), italic: true }); } diff --git a/src/client/src/components/legacyComponents/bulkedit/bulkEditForm.tsx b/src/client/src/components/legacyComponents/bulkedit/bulkEditForm.tsx index 361364ce6..2d25c89c2 100644 --- a/src/client/src/components/legacyComponents/bulkedit/bulkEditForm.tsx +++ b/src/client/src/components/legacyComponents/bulkedit/bulkEditForm.tsx @@ -100,9 +100,6 @@ export const BulkEditForm = ({ selected, loadBoreholes }: BulkEditFormProps) => (field: BulkEditFormField, newValue: BulkEditFormValue) => { const fieldName = field.api ?? field.fieldName; let updatedValue: BulkEditFormValue = newValue; - if (field.type === FormValueType.Boolean) { - updatedValue = newValue === 1 ? true : newValue === 0 ? false : undefined; - } if (field.type === FormValueType.Number) { updatedValue = parseFloat(newValue as string); } @@ -131,9 +128,10 @@ export const BulkEditForm = ({ selected, loadBoreholes }: BulkEditFormProps) => const entryIndex = fieldsToUpdate.findIndex(([key]) => key === fieldName); if (entryIndex !== -1) { setFieldsToUpdate([...fieldsToUpdate.filter(f => f[0] !== fieldName)]); - formMethods.resetField(fieldName); if (fieldName === "workgroup") { setWorkgroupId(null); + } else { + formMethods.resetField(fieldName); } } }; @@ -155,6 +153,7 @@ export const BulkEditForm = ({ selected, loadBoreholes }: BulkEditFormProps) => if (field.type === FormValueType.Domain) { return ( if (field.type === FormValueType.Boolean) { return ( {