From ae4cff98e7b8b01b82cdc4dacc7888dbf8973d31 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Thu, 16 Feb 2023 17:26:57 -0800 Subject: [PATCH] IO-2175 Category Dropdown Clear Allow for clear and correct for Select allowClear sending undefined and convert that to null. Overload UndefinedtoNull to have an array of keys --- .../jobs-detail-general/jobs-detail-general.component.jsx | 2 +- client/src/pages/jobs-detail/jobs-detail.page.component.jsx | 3 ++- client/src/utils/undefinedtonull.js | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx b/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx index 0e59129c8..90c659aac 100644 --- a/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx +++ b/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx @@ -256,7 +256,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) { - {bodyshop.md_categories.map((s) => ( {s} diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index f2614e9c9..5533666a1 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -51,6 +51,7 @@ import JobAuditTrail from "../../components/job-audit-trail/job-audit-trail.comp import AuditTrailMapping from "../../utils/AuditTrailMappings"; import { insertAuditTrail } from "../../redux/application/application.actions"; import JobsDocumentsLocalGallery from "../../components/jobs-documents-local-gallery/jobs-documents-local-gallery.container"; +import UndefinedToNull from "../../utils/undefinedtonull"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -96,7 +97,7 @@ export function JobsDetailPage({ variables: { jobId: job.id, job: { - ...values, + ...UndefinedToNull(values, ["alt_transport", "category", "referral_source"]), parts_tax_rates: { ...job.parts_tax_rates, ...values.parts_tax_rates, diff --git a/client/src/utils/undefinedtonull.js b/client/src/utils/undefinedtonull.js index 841701c8c..7da68e931 100644 --- a/client/src/utils/undefinedtonull.js +++ b/client/src/utils/undefinedtonull.js @@ -1,6 +1,10 @@ -export default function UndefinedToNull(obj) { +export default function UndefinedToNull(obj, keys) { Object.keys(obj).forEach((key) => { + if (keys && keys.indexOf(key) >= 0) { + if (obj[key] === undefined) obj[key] = null; + } else { if (obj[key] === undefined) obj[key] = null; + } }); return obj; }