Skip to content

Commit

Permalink
THE-1364 traductions ordre de tri des resultats theses
Browse files Browse the repository at this point in the history
  • Loading branch information
clementdelafontaine committed Oct 14, 2024
1 parent d6faf2a commit a32bfa0
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 18 deletions.
62 changes: 46 additions & 16 deletions components/common/results/SortingSelect.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<v-select class="select-box" v-model="tri" return-object :items=items item-title="nom" item-value="cle"
density="compact" flat single-line variant="solo" menu-icon="mdi-chevron-down" :aria-label="$t('results.ariaSortBy')">
<v-select class="select-box" v-model="tri" return-object :items="items" item-title="nom" item-value="cle" density="compact" flat single-line variant="solo" menu-icon="mdi-chevron-down" :aria-label="$t('results.ariaSortBy')">
<template v-slot:menu-icon>
<v-icon>
mdi-chevron-down
Expand All @@ -10,27 +9,55 @@
</template>

<script setup>
import { onMounted, ref, watch } from "vue";
import { onMounted, ref, watch, computed } from "vue";
import { useI18n } from "vue-i18n";
const currentRoute = useRoute();
const { t } = useI18n();
const { t, locale } = useI18n();
const emit = defineEmits(['updatePageNumberFromSortingSelect', 'search']);
const { setSorting, getItemsTri, getCurrentSorting, getTriMap } = useStrategyAPI();
const items = ref();
const tri = ref();
const items = ref([]);
const tri = ref("");
let noDoubleUpdates = false;
onMounted(() => {
items.value = getItemsTri();
tri.value = getCurrentSortName();
updateDataTri();
});
/**
* Fonctions
*/
function updateDataTri() {
items.value = getTranslatedItemsTri();
tri.value = getTranslatedCurrentSortName();
}
/**
* Retourne les éléments de tri traduits
* @returns {Array}
*/
function getTranslatedItemsTri() {
return getItemsTri().map(item => ({
...item,
nom: t(item.nom)
}));
}
/**
* Retourne le tri appliqaué traduit
* @returns {Array}
*/
function getTranslatedCurrentSortName() {
let obj = getCurrentSortName();
return {
...obj,
cle: obj.cle,
nom: t(obj.nom)
}
}
/**
* Récupère les clés/valeurs du tri pour le domaine actuel
* @returns {{nom: (*|string), cle: (*|string)}}
Expand All @@ -46,30 +73,33 @@ function getCurrentSortName() {
* Watchers
*/
// Surveiller les changements de tri
watch(tri, async (newSortingArray, previousSortingArray) => {
if (typeof previousSortingArray !== 'undefined' && !noDoubleUpdates) { // Pas de mise à jour de la page à la première initialisation
if (typeof previousSortingArray !== 'undefined' && !noDoubleUpdates) {
setSorting(newSortingArray.cle);
emit("updatePageNumberFromSortingSelect", 1);
emit("search");
}
noDoubleUpdates = false;
});
// Mise à jour des valeurs de tri
// Surveiller les changements de domaine dans la route
watch(() => currentRoute.query.domaine, () => {
setSorting('pertinence');
items.value = getItemsTri();
tri.value = getCurrentSortName();
items.value = getTranslatedItemsTri();
tri.value = getTranslatedCurrentSortName();
});
// Surveiller les changements de tri dans la route
watch(() => currentRoute.query.tri, () => {
noDoubleUpdates = true;
items.value = getItemsTri();
tri.value = getCurrentSortName();
items.value = getTranslatedItemsTri();
tri.value = getTranslatedCurrentSortName();
});
watch(locale, (newLocale) => {
updateDataTri();
});
</script>

Expand Down
7 changes: 7 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@
"Soutenues": "Defended",
"Accessibles en ligne": "Available online",
"list": "List of ",
"Pertinence": "Relevance",
"Date croissante": "Ascending date",
"Date décroissante": "Descending date",
"Auteurs A-Z": "Authors A-Z",
"Auteurs Z-A": "Authors Z-A",
"Discipline A-Z": "Discipline A-Z",
"Discipline Z-A": "Discipline Z-A",
"loading": "Search in progress...",
"personnes": {
"searchBar": {
Expand Down
7 changes: 7 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@
"Soutenues": "Defendidas",
"Accessibles en ligne": "Disponibles en línea",
"list": "Lista de ",
"Pertinence": "Relevancia",
"Date croissante": "Fecha ascendente",
"Date décroissante": "Fecha descendente",
"Auteurs A-Z": "Autores A-Z",
"Auteurs Z-A": "Autores Z-A",
"Discipline A-Z": "Disciplina A-Z",
"Discipline Z-A": "Disciplina Z-A",
"loading": "Buscando...",
"personnes": {
"searchBar": {
Expand Down
11 changes: 9 additions & 2 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,20 @@
"Écoles doctorales": "Écoles doctorales",
"Domaines thématiques": "Domaines thématiques",
"Disciplines": "Disciplines",
"Langues": "Langues",
"En préparation": "En préparation"
"Langues": "Langues"
}
},
"En préparation": "En préparation",
"Soutenues": "Soutenues",
"Accessibles en ligne": "Accessibles en ligne",
"list": "Liste des ",
"Pertinence": "Pertinence",
"Date croissante": "Date croissante",
"Date décroissante": "Date décroissante",
"Auteurs A-Z": "Auteurs A-Z",
"Auteurs Z-A": "Auteurs Z-A",
"Discipline A-Z": "Discipline A-Z",
"Discipline Z-A": "Discipline Z-A",
"loading": "Recherche en cours...",
"personnes": {
"searchBar": {
Expand Down

0 comments on commit a32bfa0

Please sign in to comment.