From 4a18204b2d02945a4f828f8f180bf6a333e6f8d9 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 3 Feb 2020 18:02:59 -0300 Subject: [PATCH] 15781: Allows multi-value properties on the search bar/editor. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/store/search-bar/search-bar-actions.ts | 13 ++++++++++--- .../search-bar-advanced-properties-view.tsx | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts index c12fcbe4..4af132ea 100644 --- a/src/store/search-bar/search-bar-actions.ts +++ b/src/store/search-bar/search-bar-actions.ts @@ -232,9 +232,16 @@ const buildQueryFromKeyMap = (data: any, keyMap: string[][], mode: 'rebuild' | ' const v = data[key]; if (data.hasOwnProperty(key)) { - const pattern = v === false - ? `${field.replace(':', '\\:\\s*')}\\s*` - : `${field.replace(':', '\\:\\s*')}\\:\\s*"[\\w|\\#|\\-|\\/]*"\\s*`; + let pattern: string; + if (v === false) { + pattern = `${field.replace(':', '\\:\\s*')}\\s*`; + } else if (key.startsWith('prop-')) { + // On properties, only remove key:value duplicates, allowing + // multiple properties with the same key. + pattern = `${field.replace(':', '\\:\\s*')}\\:\\s*${v}\\s*`; + } else { + pattern = `${field.replace(':', '\\:\\s*')}\\:\\s*[\\w|\\#|\\-|\\/]*\\s*`; + } value = value.replace(new RegExp(pattern), ''); } diff --git a/src/views-components/search-bar/search-bar-advanced-properties-view.tsx b/src/views-components/search-bar/search-bar-advanced-properties-view.tsx index eb049b76..8add4b02 100644 --- a/src/views-components/search-bar/search-bar-advanced-properties-view.tsx +++ b/src/views-components/search-bar/search-bar-advanced-properties-view.tsx @@ -67,7 +67,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ setProp: (propertyValue: PropertyValue, properties: PropertyValue[]) => { dispatch(changeAdvancedFormProperty( 'properties', - [...properties.filter(e => e.keyID! !== propertyValue.keyID!), propertyValue] + [...properties, propertyValue] )); dispatch(resetAdvancedFormProperty('key')); dispatch(resetAdvancedFormProperty('value')); -- 2.30.2