From 0185a0ab93ed6373781c35fef02f0ee7cf8bb2a4 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 16 Sep 2020 14:34:43 -0700 Subject: [PATCH] Added validation on jobline upsert modal. BOD-399 --- bodyshop_translations.babel | 21 ++++++++ .../job-lines-upsert-modal.component.jsx | 52 ++++++++++++++++++- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 5 files changed, 74 insertions(+), 2 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 4af7c7cef..b6f4a1cc7 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -11440,6 +11440,27 @@ validations + + hrsrequirediflbrtyp + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + zeropriceexistingpart false diff --git a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx index 3d20c7b33..a6a60d98a 100644 --- a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx +++ b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx @@ -137,12 +137,50 @@ export default function JobLinesUpsertModalComponent({ > - + ({ + validator(rule, value) { + if (!!getFieldValue("mod_lbr_ty") === !!value) { + return Promise.resolve(); + } + return Promise.reject( + t("joblines.validation.hrsrequirediflbrtyp") + ); + }, + }), + ]} + > - + ({ + validator(rule, value) { + if (!!getFieldValue("part_type") === !!value) { + return Promise.resolve(); + } + return Promise.reject( + t("joblines.validation.requiredifparttype") + ); + }, + }), + ]} + > @@ -162,6 +200,16 @@ export default function JobLinesUpsertModalComponent({ ); }, }), + ({ getFieldValue }) => ({ + validator(rule, value) { + if (!!getFieldValue("part_type") === !!value) { + return Promise.resolve(); + } + return Promise.reject( + t("joblines.validation.requiredifparttype") + ); + }, + }), ]} > diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index a1cfe9305..74d4b1ce4 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -750,6 +750,7 @@ "updated": "Job line updated successfully." }, "validations": { + "hrsrequirediflbrtyp": "Labor hours are required if a labor type is selected. Clear the labor type if there are no labor hours.", "zeropriceexistingpart": "This line cannot have any price since it uses an existing part." } }, diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index a5cfad2b6..964141798 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -750,6 +750,7 @@ "updated": "" }, "validations": { + "hrsrequirediflbrtyp": "", "zeropriceexistingpart": "" } }, diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 04af64f27..69332c681 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -750,6 +750,7 @@ "updated": "" }, "validations": { + "hrsrequirediflbrtyp": "", "zeropriceexistingpart": "" } },