From a0dd06716970f47c3fbb7eb2491e0faa0740c2d8 Mon Sep 17 00:00:00 2001 From: Petar Hristov <hristov@itc.rwth-aachen.de> Date: Mon, 27 Jan 2025 10:26:46 +0000 Subject: [PATCH 1/3] Fix: Ensure valid locale for disciplineLabel across components --- .../project/pages/components/FormMetadata.vue | 5 +++++ .../DataPublicationProjectData.vue | 14 +++++++++----- .../data-publication/DataPublicationSummary.vue | 4 ++++ .../create-resource/ResourceMetadata.vue | 4 ++++ src/modules/user/pages/UserProfile.vue | 10 ++++++---- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/modules/project/pages/components/FormMetadata.vue b/src/modules/project/pages/components/FormMetadata.vue index 843bb683..ad1607e4 100644 --- a/src/modules/project/pages/components/FormMetadata.vue +++ b/src/modules/project/pages/components/FormMetadata.vue @@ -401,6 +401,7 @@ import type { } from "@coscine/api-client/dist/types/Coscine.Api"; import { useI18n } from "vue-i18n"; +import { on } from "events"; const i18n = useI18n(); const projectForManipulation = defineModel< @@ -511,6 +512,10 @@ const visibilities = computed(() => projectStore.visibilities ?? []); const disciplines = computed(() => projectStore.disciplines ?? []); const disciplineLabel = computed(() => { let locale = i18n.locale.value; + // Ensure that the value of locale is a valid locale, otherwie the property for disciplineLabel will be inaccurate + if (i18n.availableLocales.includes(locale) === false) { + locale = i18n.fallbackLocale.value.toString(); + } locale = locale.charAt(0).toUpperCase() + locale.slice(1); return `displayName${locale}`; }); diff --git a/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue b/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue index 8a704e6e..25af124a 100644 --- a/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue +++ b/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue @@ -285,6 +285,10 @@ export default defineComponent({ }, disciplineLabel(): string { let locale = this.$i18n.locale; + // Ensure that the value of locale is a valid locale, otherwie the property for disciplineLabel will be inaccurate + if (this.$i18n.availableLocales.includes(locale) === false) { + locale = this.$i18n.fallbackLocale.toString(); + } locale = locale.charAt(0).toUpperCase() + locale.slice(1); return `displayName${locale}`; }, @@ -368,7 +372,7 @@ export default defineComponent({ if (newValue !== oldValue) { await this.projectStore.retrievePublicationOrganizations(newValue); this.selectedService = this.publicationServices.find( - (s) => s.uri === this.modelValue.publicationServiceRorId, + (s) => s.uri === this.modelValue.publicationServiceRorId ); this.selectedServiceText = this.publicationServices[0].publicationAdvisoryService?.description ?? @@ -389,7 +393,7 @@ export default defineComponent({ // A publication advisory service has been selected. Set selection in dropdown. if (this.modelValue.publicationServiceRorId) { this.selectedService = this.publicationServices.find( - (s) => s.uri === this.modelValue.publicationServiceRorId, + (s) => s.uri === this.modelValue.publicationServiceRorId ); } // Should there be only one option inside the publication services list, select it @@ -402,7 +406,7 @@ export default defineComponent({ if (this.modelValue.resourceIds.length > 0) { this.selectedResources = this.resources.filter((r) => - this.modelValue.resourceIds.some((id) => id === r.id), + this.modelValue.resourceIds.some((id) => id === r.id) ); } }, @@ -414,7 +418,7 @@ export default defineComponent({ // Load Publication Services if not present if (this.projectStore.publicationAdvisoryServices === null) { await this.projectStore.retrievePublicationOrganizations( - this.currentLanguage, + this.currentLanguage ); } }, @@ -433,7 +437,7 @@ export default defineComponent({ this.isLoadingPublicationServices = true; await this.projectStore.retrievePublicationOrganizations( this.currentLanguage, - search, + search ); this.isLoadingPublicationServices = false; }, 1000); diff --git a/src/modules/project/pages/components/data-publication/DataPublicationSummary.vue b/src/modules/project/pages/components/data-publication/DataPublicationSummary.vue index 09fd7f04..25d8b0c4 100644 --- a/src/modules/project/pages/components/data-publication/DataPublicationSummary.vue +++ b/src/modules/project/pages/components/data-publication/DataPublicationSummary.vue @@ -180,6 +180,10 @@ export default defineComponent({ }, disciplineLabel(): string { let locale = this.$i18n.locale; + // Ensure that the value of locale is a valid locale, otherwie the property for disciplineLabel will be inaccurate + if (this.$i18n.availableLocales.includes(locale) === false) { + locale = this.$i18n.fallbackLocale.toString(); + } locale = locale.charAt(0).toUpperCase() + locale.slice(1); return `displayName${locale}`; }, diff --git a/src/modules/resource/components/create-resource/ResourceMetadata.vue b/src/modules/resource/components/create-resource/ResourceMetadata.vue index 10cd4b67..1289b5ac 100644 --- a/src/modules/resource/components/create-resource/ResourceMetadata.vue +++ b/src/modules/resource/components/create-resource/ResourceMetadata.vue @@ -376,6 +376,10 @@ const disciplines = computed(() => { }); const disciplineLabel = computed(() => { let locale = i18n.locale.value; + // Ensure that the value of locale is a valid locale, otherwie the property for disciplineLabel will be inaccurate + if (i18n.availableLocales.includes(locale) === false) { + locale = i18n.fallbackLocale.value.toString(); + } locale = locale.charAt(0).toUpperCase() + locale.slice(1); return `displayName${locale}`; }); diff --git a/src/modules/user/pages/UserProfile.vue b/src/modules/user/pages/UserProfile.vue index d2b80684..09c1d1bc 100644 --- a/src/modules/user/pages/UserProfile.vue +++ b/src/modules/user/pages/UserProfile.vue @@ -476,11 +476,13 @@ export default defineComponent({ }, computed: { disciplineLabel(): string { - if (this.$i18n.locale === "en") { - return "displayNameEn"; - } else { - return "displayNameDe"; + let locale = this.$i18n.locale; + // Ensure that the value of locale is a valid locale, otherwie the property for disciplineLabel will be inaccurate + if (this.$i18n.availableLocales.includes(locale) === false) { + locale = this.$i18n.fallbackLocale.toString(); } + locale = locale.charAt(0).toUpperCase() + locale.slice(1); + return `displayName${locale}`; }, disciplines(): DisciplineDto[] { return this.userStore.userProfile.disciplines -- GitLab From 97eb05faae878211a7e4fe6925888d5c60ef63c4 Mon Sep 17 00:00:00 2001 From: Petar Hristov <hristov@itc.rwth-aachen.de> Date: Mon, 27 Jan 2025 10:28:24 +0000 Subject: [PATCH 2/3] Fix: Add missing commas in DataPublicationProjectData.vue for improved syntax --- .../data-publication/DataPublicationProjectData.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue b/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue index 25af124a..e59258b7 100644 --- a/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue +++ b/src/modules/project/pages/components/data-publication/DataPublicationProjectData.vue @@ -372,7 +372,7 @@ export default defineComponent({ if (newValue !== oldValue) { await this.projectStore.retrievePublicationOrganizations(newValue); this.selectedService = this.publicationServices.find( - (s) => s.uri === this.modelValue.publicationServiceRorId + (s) => s.uri === this.modelValue.publicationServiceRorId, ); this.selectedServiceText = this.publicationServices[0].publicationAdvisoryService?.description ?? @@ -393,7 +393,7 @@ export default defineComponent({ // A publication advisory service has been selected. Set selection in dropdown. if (this.modelValue.publicationServiceRorId) { this.selectedService = this.publicationServices.find( - (s) => s.uri === this.modelValue.publicationServiceRorId + (s) => s.uri === this.modelValue.publicationServiceRorId, ); } // Should there be only one option inside the publication services list, select it @@ -406,7 +406,7 @@ export default defineComponent({ if (this.modelValue.resourceIds.length > 0) { this.selectedResources = this.resources.filter((r) => - this.modelValue.resourceIds.some((id) => id === r.id) + this.modelValue.resourceIds.some((id) => id === r.id), ); } }, @@ -418,7 +418,7 @@ export default defineComponent({ // Load Publication Services if not present if (this.projectStore.publicationAdvisoryServices === null) { await this.projectStore.retrievePublicationOrganizations( - this.currentLanguage + this.currentLanguage, ); } }, @@ -437,7 +437,7 @@ export default defineComponent({ this.isLoadingPublicationServices = true; await this.projectStore.retrievePublicationOrganizations( this.currentLanguage, - search + search, ); this.isLoadingPublicationServices = false; }, 1000); -- GitLab From d166324be2f6f2a0240cc714fcacec78c5550873 Mon Sep 17 00:00:00 2001 From: Petar Hristov <hristov@itc.rwth-aachen.de> Date: Mon, 27 Jan 2025 10:29:18 +0000 Subject: [PATCH 3/3] Fix: Remove unused import from FormMetadata.vue to clean up code --- src/modules/project/pages/components/FormMetadata.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/project/pages/components/FormMetadata.vue b/src/modules/project/pages/components/FormMetadata.vue index ad1607e4..e0f8c8b2 100644 --- a/src/modules/project/pages/components/FormMetadata.vue +++ b/src/modules/project/pages/components/FormMetadata.vue @@ -401,7 +401,6 @@ import type { } from "@coscine/api-client/dist/types/Coscine.Api"; import { useI18n } from "vue-i18n"; -import { on } from "events"; const i18n = useI18n(); const projectForManipulation = defineModel< -- GitLab