From: Lucas Di Pentima Date: Thu, 30 Jan 2020 21:05:45 +0000 (-0300) Subject: 15781: Adds support for multi-value property additions on collections. X-Git-Tag: 2.1.0~39^2~13 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/0cc06c813afc8373f3c6675c3519960382a7067f 15781: Adds support for multi-value property additions on collections. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- 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;