From d4455fdb92236c95722c1b1cc21fd8cbad8cc66e Mon Sep 17 00:00:00 2001 From: Vincent Auger Date: Thu, 5 Dec 2024 16:24:45 -0400 Subject: [PATCH] feat: filter caption --- resources/src/locales/en.json | 3 ++- resources/src/locales/fr.json | 3 ++- resources/src/models/Author/views/AuthorsView.vue | 8 ++++++++ .../models/Organization/components/OrganizationSelect.vue | 4 ++++ .../src/models/Publication/views/PublicationsView.vue | 4 ++-- resources/src/stores/LocaleStore.ts | 5 +++++ 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/resources/src/locales/en.json b/resources/src/locales/en.json index 6f707736..3c8e287c 100644 --- a/resources/src/locales/en.json +++ b/resources/src/locales/en.json @@ -278,7 +278,8 @@ "unauthenticated-orcid-id": "Unauthenticated ORCID iD", "authors": "Authors", "upload-a-new-version-of-the-publication": "Upload a new version of the publication", - "upload-the-publication": "Upload the publication" + "upload-the-publication": "Upload the publication", + "from": "from" }, "create-author-dialog": { "title": "Create a new author" diff --git a/resources/src/locales/fr.json b/resources/src/locales/fr.json index b1d41fe2..2cb09fc4 100644 --- a/resources/src/locales/fr.json +++ b/resources/src/locales/fr.json @@ -278,7 +278,8 @@ "unauthenticated-orcid-id": "ORCID iD Non authentifié", "authors": "Auteurs", "upload-a-new-version-of-the-publication": "Télécharger une nouvelle version de la publication", - "upload-the-publication": "Téléchargez la publication" + "upload-the-publication": "Téléchargez la publication", + "from": "de" }, "create-author-dialog": { "title": "Créer un nouvel auteur" diff --git a/resources/src/models/Author/views/AuthorsView.vue b/resources/src/models/Author/views/AuthorsView.vue index 8b57cda4..b6eb6244 100644 --- a/resources/src/models/Author/views/AuthorsView.vue +++ b/resources/src/models/Author/views/AuthorsView.vue @@ -19,9 +19,11 @@ const currentPage = ref(1) const search = ref(null) const showFilters = ref(false) const organizationId = ref(null) +const organizationSelect = ref | null>(null) // i18n const { t } = useI18n() +const localeStore = useLocaleStore() // Main filter options const mainFilterOptions = computed(() => { @@ -76,6 +78,11 @@ const mainFilter = computed(() => { const filterCaption = computed(() => { let caption = '' + if (organizationId.value) { + const { name_en, name_fr } = organizationSelect?.value?.selectedOrganization?.data || {} + const name = localeStore.isFr() ? name_fr : name_en + caption += `${t('common.from')} ${name || name_en || 'NA'}` + } if (caption.length > 0) caption = `${t('common.authors')} ${caption.slice(0, -1)}` else caption = t('common.no-filters-applied') @@ -210,6 +217,7 @@ interface MainFilterOption { > props.modelValue, (value) => { if (value === null) { selectedOrganization.value = null diff --git a/resources/src/models/Publication/views/PublicationsView.vue b/resources/src/models/Publication/views/PublicationsView.vue index a0a95a50..4ee1c7c7 100644 --- a/resources/src/models/Publication/views/PublicationsView.vue +++ b/resources/src/models/Publication/views/PublicationsView.vue @@ -83,11 +83,11 @@ const filterCaption = computed(() => { let caption = '' if (journalId.value) { const { title } = journalSelect?.value?.selectedJournal?.data || {} - caption += `${t('common.in')} ${title} ` + caption += `${t('common.in')} ${title || 'NA'} ` } if (authorId.value) { const { first_name, last_name } = authorSelect?.value?.selectedAuthor?.data || {} - caption += `${t('common.by')} ${first_name} ${last_name} ` + caption += `${t('common.by')} ${first_name || 'NA'} ${last_name || 'NA'} ` } if (caption.length > 0) caption = `${t('common.publications')} ${caption.slice(0, -1)}` diff --git a/resources/src/stores/LocaleStore.ts b/resources/src/stores/LocaleStore.ts index e66f34b5..f8213632 100644 --- a/resources/src/stores/LocaleStore.ts +++ b/resources/src/stores/LocaleStore.ts @@ -35,10 +35,15 @@ export const useLocaleStore = defineStore('LocaleStore', () => { }) } + function isFr(): boolean { + return locale.value === 'fr' + } + return { toggleLocale, otherLocale, locale, + isFr, persistentLocale, } })