From fb20c7ebe2644e67880a89ac9a18262d48d732d7 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Mon, 8 Jul 2024 10:43:08 +0200 Subject: [PATCH] feat(js,import): remove onClick from label text and add return null for builUri Signed-off-by: David Wallace --- .../components/import/common/ImportSelectCheckbox.js | 4 ++-- rdmo/management/assets/js/reducers/importsReducer.js | 10 ++++++++-- rdmo/management/assets/js/utils/elements.js | 11 +++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/rdmo/management/assets/js/components/import/common/ImportSelectCheckbox.js b/rdmo/management/assets/js/components/import/common/ImportSelectCheckbox.js index 34e2cc029c..365ea0eedc 100644 --- a/rdmo/management/assets/js/components/import/common/ImportSelectCheckbox.js +++ b/rdmo/management/assets/js/components/import/common/ImportSelectCheckbox.js @@ -15,9 +15,9 @@ const ImportSelectCheckbox = ({ element, toggleImport, updateShowField }) => { - + - + )} diff --git a/rdmo/management/assets/js/reducers/importsReducer.js b/rdmo/management/assets/js/reducers/importsReducer.js index 775cb28d97..28810fddaf 100644 --- a/rdmo/management/assets/js/reducers/importsReducer.js +++ b/rdmo/management/assets/js/reducers/importsReducer.js @@ -51,7 +51,10 @@ export default function importsReducer(state = initialState, action) { if (elements[index].model === 'domain.attribute') { elements[index].path = buildPathForAttribute(elements[index].key, elements[index].parent ? elements[index].parent.uri : null) } - elements[index].uri = buildUri(elements[index]) + const newUri = buildUri(elements[index]) + if (!isNil(newUri)) { + elements[index].uri = newUri + } return {...state, elements} } else { return state @@ -87,7 +90,10 @@ export default function importsReducer(state = initialState, action) { element.uri_prefix = action.uriPrefix // compute a new uri and store it in the elementMap - element.uri = elementsMap[element.uri] = buildUri(element) + const newUri = buildUri(element) + if (!isNil(newUri)) { + element.uri = elementsMap[element.uri] = newUri + } return element }) diff --git a/rdmo/management/assets/js/utils/elements.js b/rdmo/management/assets/js/utils/elements.js index 5abdaa934a..f9be3aa889 100644 --- a/rdmo/management/assets/js/utils/elements.js +++ b/rdmo/management/assets/js/utils/elements.js @@ -162,13 +162,20 @@ function findDescendants(element, elementType) { } const buildUri = (element) => { - let uri = element.uri_prefix + '/' + elementModules[element.model] + '/' + if (isUndefined(element.uri_prefix) || isUndefined(element.model)) { + return null + } + + let uri = `${element.uri_prefix}/${elementModules[element.model]}/` + if (!isUndefined(element.uri_path) && !isNil(element.uri_path)) { uri += element.uri_path } else if (!isUndefined(element.path) && !isNil(element.path)) { uri += element.path - } else { + } else if (!isUndefined(element.key) && !isNil(element.key)) { uri += element.key + } else { + return null } return uri