diff --git a/src/components/DatasetEditorForm.vue b/src/components/DatasetEditorForm.vue index d0482c1..05faf24 100644 --- a/src/components/DatasetEditorForm.vue +++ b/src/components/DatasetEditorForm.vue @@ -114,9 +114,19 @@ - + + + + + + + + - - - - @@ -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)); } @@ -1035,6 +1038,18 @@ export default defineComponent({ model.value.identification.centreID = value.toLowerCase(); }; + + const convertToLowercaseLocalID = (value) => { + if (!value) { + localID.value = ''; + return; + } + localID.value = value + .trim() + .toLowerCase() + .replace(/\s+/g, '-'); + }; + // Has the user filled the dialog window? const initialDialogFilled = computed(() => { return model.value.identification.centreID && selectedTemplate.value; @@ -1528,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]; @@ -1602,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 + '/'; } @@ -2361,7 +2378,8 @@ export default defineComponent({ updateIdentifierFromLocalID, extractLocalID, localID, - isEditing + isEditing, + convertToLowercaseLocalID } } });