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
This commit is contained in:
@@ -256,7 +256,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
|
|||||||
</FormRow>
|
</FormRow>
|
||||||
<FormRow header={t("jobs.forms.other")}>
|
<FormRow header={t("jobs.forms.other")}>
|
||||||
<Form.Item label={t("jobs.fields.category")} name="category">
|
<Form.Item label={t("jobs.fields.category")} name="category">
|
||||||
<Select disabled={jobRO}>
|
<Select disabled={jobRO} allowClear>
|
||||||
{bodyshop.md_categories.map((s) => (
|
{bodyshop.md_categories.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import JobAuditTrail from "../../components/job-audit-trail/job-audit-trail.comp
|
|||||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||||
import JobsDocumentsLocalGallery from "../../components/jobs-documents-local-gallery/jobs-documents-local-gallery.container";
|
import JobsDocumentsLocalGallery from "../../components/jobs-documents-local-gallery/jobs-documents-local-gallery.container";
|
||||||
|
import UndefinedToNull from "../../utils/undefinedtonull";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -96,7 +97,7 @@ export function JobsDetailPage({
|
|||||||
variables: {
|
variables: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
job: {
|
job: {
|
||||||
...values,
|
...UndefinedToNull(values, ["alt_transport", "category", "referral_source"]),
|
||||||
parts_tax_rates: {
|
parts_tax_rates: {
|
||||||
...job.parts_tax_rates,
|
...job.parts_tax_rates,
|
||||||
...values.parts_tax_rates,
|
...values.parts_tax_rates,
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
export default function UndefinedToNull(obj) {
|
export default function UndefinedToNull(obj, keys) {
|
||||||
Object.keys(obj).forEach((key) => {
|
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;
|
if (obj[key] === undefined) obj[key] = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user