feat: refs #6480 locale
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-04-18 15:25:32 +02:00
parent 246944d2a4
commit dfdfb6ec93
5 changed files with 22 additions and 28 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, onBeforeMount } from 'vue'; import { onBeforeMount } from 'vue';
import { useRoute, onBeforeRouteUpdate } from 'vue-router'; import { useRoute, onBeforeRouteUpdate } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
@ -10,10 +10,9 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue';
import LeftMenu from 'components/LeftMenu.vue'; import LeftMenu from 'components/LeftMenu.vue';
const props = defineProps({ const props = defineProps({
dataKey: { type: String, default: null }, dataKey: { type: String, required: true },
baseUrl: { type: String, default: null }, baseUrl: { type: String, required: true },
model: { type: String, default: null }, filter: { type: Object, default: undefined },
filter: { type: Object, default: null },
descriptor: { type: Object, required: true }, descriptor: { type: Object, required: true },
searchbarDataKey: { type: String, required: true }, searchbarDataKey: { type: String, required: true },
searchbarUrl: { type: String, required: true }, searchbarUrl: { type: String, required: true },
@ -24,28 +23,27 @@ const props = defineProps({
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
const route = useRoute(); const route = useRoute();
const url = computed(() => `${props.baseUrl}/${route.params.id}`);
let arrayData;
if (props.dataKey) { const arrayData = useArrayData(props.dataKey, {
arrayData = useArrayData(props.dataKey, { url, filter: props.filter }); url: `${props.baseUrl}/${route.params.id}`,
filter: props.filter,
});
onBeforeMount(async () => await arrayData.fetch({ append: false })); onBeforeMount(async () => await arrayData.fetch({ append: false }));
onBeforeRouteUpdate(async (to, from) => { onBeforeRouteUpdate(async (to, from) => {
if (!to.params.id !== from.params.id) { if (to.params.id !== from.params.id) {
arrayData.store.url = url; arrayData.store.url = `${props.baseUrl}/${route.params.id}`;
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
} }
}); });
}
</script> </script>
<template> <template>
<Teleport to="#searchbar" v-if="stateStore.isHeaderMounted()"> <Teleport to="#searchbar" v-if="stateStore.isHeaderMounted()">
<VnSearchbar <VnSearchbar
:data-key="props.searchbarDataKey" :data-key="props.searchbarDataKey"
:url="props.searchbarUrl" :url="props.searchbarUrl"
:label="t(`${props.model}.searchbar.${props.searchbarLabel}`)" :label="t(props.searchbarLabel)"
:info="t(props.searchbarInfo)" :info="t(props.searchbarInfo)"
/> />
</Teleport> </Teleport>

View File

@ -31,8 +31,3 @@ const filter = {
searchbar-info="You can search by invoice reference" searchbar-info="You can search by invoice reference"
/> />
</template> </template>
<i18n>
es:
Search invoice: Buscar factura recibida
You can search by invoice reference: Puedes buscar por referencia de la factura
</i18n>

View File

@ -0,0 +1,2 @@
Search invoice: Buscar factura recibida
You can search by invoice reference: Puedes buscar por referencia de la factura

View File

@ -4,6 +4,8 @@ import VnCard from 'components/common/VnCard.vue';
</script> </script>
<template> <template>
<VnCard <VnCard
data-key="InvoiceOut"
base-url="InvoiceOuts"
:descriptor="InvoiceOutDescriptor" :descriptor="InvoiceOutDescriptor"
searchbar-data-key="InvoiceOutList" searchbar-data-key="InvoiceOutList"
searchbar-url="InvoiceOuts/filter" searchbar-url="InvoiceOuts/filter"
@ -11,8 +13,3 @@ import VnCard from 'components/common/VnCard.vue';
searchbar-info="You can search by invoice reference" searchbar-info="You can search by invoice reference"
/> />
</template> </template>
<i18n>
es:
Search invoice: Buscar factura emitida
You can search by invoice reference: Puedes buscar por referencia de la factura
</i18n>

View File

@ -0,0 +1,2 @@
Search invoice: Buscar factura emitida
You can search by invoice reference: Puedes buscar por referencia de la factura