Skip to content

Commit

Permalink
feat: filter caption
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentauger committed Dec 5, 2024
1 parent 49592eb commit d4455fd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion resources/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions resources/src/models/Author/views/AuthorsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ const currentPage = ref(1)
const search = ref<string | null>(null)
const showFilters = ref(false)
const organizationId = ref<number | null>(null)
const organizationSelect = ref<InstanceType<typeof OrganizationSelect> | null>(null)
// i18n
const { t } = useI18n()
const localeStore = useLocaleStore()
// Main filter options
const mainFilterOptions = computed<MainFilterOption[]>(() => {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -210,6 +217,7 @@ interface MainFilterOption {
>
<q-card-section class="column q-gutter-md">
<OrganizationSelect
ref="organizationSelect"
v-model="organizationId"
:label="$t('common.organization')"
:disable="mainFilter?.id === 2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const organizationsLoading = ref(false)
const showCreateOrganizationDialog = ref(false)
const defaultOrganiztionId = Number(import.meta.env.VITE_OSP_DEFAULT_ORG_ID) || 1
defineExpose({
selectedOrganization,
})
watch(() => props.modelValue, (value) => {
if (value === null) {
selectedOrganization.value = null
Expand Down
4 changes: 2 additions & 2 deletions resources/src/models/Publication/views/PublicationsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
Expand Down
5 changes: 5 additions & 0 deletions resources/src/stores/LocaleStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ export const useLocaleStore = defineStore('LocaleStore', () => {
})
}

function isFr(): boolean {
return locale.value === 'fr'
}

return {
toggleLocale,
otherLocale,
locale,
isFr,
persistentLocale,
}
})
Expand Down

0 comments on commit d4455fd

Please sign in to comment.