From e739a638f12c3f7c192612ed665340686b0aa80f Mon Sep 17 00:00:00 2001 From: Mathieu Lessard Date: Tue, 16 Apr 2024 14:43:38 -0700 Subject: [PATCH] Corrected validation now that select fields are comboboxes --- contenthub/hydration/hydration-utils.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/contenthub/hydration/hydration-utils.js b/contenthub/hydration/hydration-utils.js index 982cd1de..61471d8c 100644 --- a/contenthub/hydration/hydration-utils.js +++ b/contenthub/hydration/hydration-utils.js @@ -24,7 +24,7 @@ export function formIsComplete(metadataSchema, formValues) { const incomplete = metadataSchema.find((schema) => { if(!schema.required) return; if(schema.requires) return; - return Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === ''; + return !(schema.mapToProperty in formValues) || Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === ''; }); if(incomplete) return false; @@ -197,15 +197,12 @@ export function getMetadataSchema(facetOptions){ placeholder: 'Select one', element: 'text', getSuggestions: async (value) => { - return [ - {id: '', name: 'N/A'}, - ...facetOptions['gmo-campaignName'].filter( - (option) => { - const name = option.name.toLowerCase(); - return value.toLowerCase().split(' ').every((val) => name.includes(val)); - } - ) - ] + return facetOptions['gmo-campaignName'].filter( + (option) => { + const name = option.name.toLowerCase(); + return value.toLowerCase().split(' ').every((val) => name.includes(val)); + } + ) }, }, {