15781: Allows multi-value properties on the search bar/editor.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 3 Feb 2020 21:02:59 +0000 (18:02 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 3 Feb 2020 21:02:59 +0000 (18:02 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/store/search-bar/search-bar-actions.ts
src/views-components/search-bar/search-bar-advanced-properties-view.tsx

index c12fcbe49cd10a6e56d9f2d7802cf44daed7afd3..4af132ea9c6efa5d3c3a4594fbaeb0e08190af6f 100644 (file)
@@ -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), '');
         }
 
index eb049b7625262dfe5caee013d21681f8df3bc0ae..8add4b025b4dfb29e7f8a957287bf91a442360f1 100644 (file)
@@ -67,7 +67,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
     setProp: (propertyValue: PropertyValue, properties: PropertyValue[]) => {
         dispatch<any>(changeAdvancedFormProperty(
             'properties',
-            [...properties.filter(e => e.keyID! !== propertyValue.keyID!), propertyValue]
+            [...properties, propertyValue]
         ));
         dispatch<any>(resetAdvancedFormProperty('key'));
         dispatch<any>(resetAdvancedFormProperty('value'));