From 0cc06c813afc8373f3c6675c3519960382a7067f Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 30 Jan 2020 18:05:45 -0300 Subject: [PATCH] 15781: Adds support for multi-value property additions on collections. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../collection-panel-action.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts index 122fc5e3..f4244389 100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@ -45,12 +45,22 @@ export const createCollectionTag = (data: TagProperty) => const uuid = item ? item.uuid : ''; try { if (item) { + const key = data.keyID || data.key; + const value = data.valueID || data.value; + if (item.properties[key]) { + if (Array.isArray(item.properties[key])) { + item.properties[key] = [...item.properties[key], value]; + // Remove potential duplicates + item.properties[key] = Array.from(new Set(item.properties[key])); + } else { + item.properties[key] = [item.properties[key], value]; + } + } else { + item.properties[key] = value; + } const updatedCollection = await services.collectionService.update( uuid, { - properties: { - ...JSON.parse(JSON.stringify(item.properties)), - [data.keyID || data.key]: data.valueID || data.value - } + properties: {...JSON.parse(JSON.stringify(item.properties))} } ); item.properties = updatedCollection.properties; -- 2.30.2