Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite-6-upgrade #860

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"cy:run": "cypress run"
},
"dependencies": {
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@intlify/unplugin-vue-i18n": "^6.0.0",
"@quasar/extras": "^1.16.15",
"@vitejs/plugin-vue": "^5.2.1",
"@vueuse/core": "^12.0.0",
Expand All @@ -19,7 +19,7 @@
"sass-embedded": "^1.82.0",
"vite-plugin-manifest-sri": "^0.2.0",
"vue": "^3.5.13",
"vue-i18n": "^9.14.2",
"vue-i18n": "^10.0",
"vue-router": "^4.5.0"
},
"devDependencies": {
Expand All @@ -36,7 +36,7 @@
"prettier": "^3.4.2",
"typescript": "^5.7.2",
"unplugin-auto-import": "^0.18.6",
"vite": "^5.4.11",
"vite": "^6.0.3",
"vue-tsc": "^2.1.10"
}
}
419 changes: 243 additions & 176 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@
"cant-download": "You are not authorized to download this file.",
"publication-previous-version": "This is a previous version of the publication",
"unauthenticated-orcid-id": "Unauthenticated ORCID iD",
"authors": "Authors"
"authors": "Authors",
"upload-a-new-version-of-the-publication": "Upload a new version of the publication",
"upload-the-publication": "Upload the publication",
"from": "from"
},
"create-author-dialog": {
"title": "Create a new author"
Expand Down
5 changes: 4 additions & 1 deletion resources/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@
"cant-download": "Vous n'êtes pas autorisé à télécharger ce fichier.",
"publication-previous-version": "Ceci est une version précédente de la publication",
"unauthenticated-orcid-id": "ORCID iD Non authentifié",
"authors": "Auteurs"
"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",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ watch(publicationFile, () => {
use-chips
:label="
publicationResourceList?.data
? 'Upload a new version of the publication'
: 'Upload the publication'
? t('common.upload-a-new-version-of-the-publication')
: t('common.upload-the-publication')
"
:hint="t('mrf.upload-hint', { max: maxFileSizeMB })"
accept="application/pdf"
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
20 changes: 13 additions & 7 deletions resources/src/stores/LocaleStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { i18n } from '@/plugins/i18n'
// locale store is used to store the current locale
import { Lang } from 'quasar'
import { useQuasar } from 'quasar'

export type Locale = 'en' | 'fr'

Expand All @@ -13,9 +13,15 @@ export const useLocaleStore = defineStore('LocaleStore', () => {
'../../../node_modules/quasar/lang/(fr|en-US).js',
)

const $q = useQuasar()
// sync initial states i18n, quasar and persistent locale
setQuasarLocale()

// what is the other locale?
const otherLocale = computed(() => {
return locale.value === 'en' ? 'fr' : 'en'
})

function toggleLocale() {
locale.value = otherLocale.value
persistentLocale.value = locale.value
Expand All @@ -24,20 +30,20 @@ export const useLocaleStore = defineStore('LocaleStore', () => {

function setQuasarLocale() {
const l = locale.value === 'fr' ? 'fr' : 'en-US'
langs[`../../../node_modules/quasar/lang/${l}.js`]().then((lang) => {
Lang.set(lang.default)
langs[`../../../node_modules/quasar/lang/${l}.js`]().then((lang: any) => {
$q.lang.set(lang.default)
})
}

// what is the other locale?
const otherLocale = computed(() => {
return locale.value === 'en' ? 'fr' : 'en'
})
function isFr(): boolean {
return locale.value === 'fr'
}

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