From d99efdc4e2de8b3ef7e93f5a4aa036e39dc6be62 Mon Sep 17 00:00:00 2001 From: PEIWEN JIN Date: Wed, 8 Jan 2025 16:55:02 +0100 Subject: [PATCH 1/2] add function of automatically convert to lowercase of local ID --- src/components/DatasetEditorForm.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/DatasetEditorForm.vue b/src/components/DatasetEditorForm.vue index d0482c1..d89a2da 100644 --- a/src/components/DatasetEditorForm.vue +++ b/src/components/DatasetEditorForm.vue @@ -113,8 +113,8 @@ - - + + @@ -1035,6 +1035,11 @@ export default defineComponent({ model.value.identification.centreID = value.toLowerCase(); }; + + const convertToLowercaseLocalID = (value) => { + localID.value = value.toLowerCase(); + }; + // Has the user filled the dialog window? const initialDialogFilled = computed(() => { return model.value.identification.centreID && selectedTemplate.value; @@ -2361,7 +2366,8 @@ export default defineComponent({ updateIdentifierFromLocalID, extractLocalID, localID, - isEditing + isEditing, + convertToLowercaseLocalID } } }); From 4091001b772e707896d1372fc79659853d5c5b72 Mon Sep 17 00:00:00 2001 From: PEIWEN JIN Date: Fri, 10 Jan 2025 13:24:54 +0100 Subject: [PATCH 2/2] fix bugs about whitespace and symbol and optimize display textbox --- src/components/DatasetEditorForm.vue | 36 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/components/DatasetEditorForm.vue b/src/components/DatasetEditorForm.vue index d89a2da..05faf24 100644 --- a/src/components/DatasetEditorForm.vue +++ b/src/components/DatasetEditorForm.vue @@ -113,10 +113,20 @@ - + + + + + + + + - - - - @@ -155,7 +158,7 @@ - + @@ -824,7 +827,7 @@ export default defineComponent({ const random6ASCIICharacters = () => { let result = ''; - const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; for (let i = 0; i < 6; i++) { result += characters.charAt(Math.floor(Math.random() * characters.length)); } @@ -1037,8 +1040,15 @@ export default defineComponent({ const convertToLowercaseLocalID = (value) => { - localID.value = value.toLowerCase(); - }; + if (!value) { + localID.value = ''; + return; + } + localID.value = value + .trim() + .toLowerCase() + .replace(/\s+/g, '-'); + }; // Has the user filled the dialog window? const initialDialogFilled = computed(() => { @@ -1533,6 +1543,7 @@ export default defineComponent({ // Metadata Editor parts model.value.identification.title = template.title.replace('$CENTRE_ID', model.value.identification.centreID); model.value.identification.identifier = createAndCheckIdentifier(template.identifier); + localID.value = extractLocalID(model.value.identification.identifier); // Converts the theme structure into a list of the theme labels model.value.identification.concepts = template.themes.flatMap(theme => theme.concepts.map(concept => concept.label)); model.value.identification.conceptScheme = template.themes.map(theme => theme.scheme)[0]; @@ -1607,6 +1618,7 @@ export default defineComponent({ let policy = model.value.identification.wmoDataPolicy; let centreID = model.value.identification.centreID; model.value.identification.identifier = 'urn:wmo:md:' + centreID + ':' + randomCode; + localID.value = extractLocalID(model.value.identification.identifier); model.value.identification.topicHierarchy = centreID + '/data/' + policy + '/'; }