0
0
Fork 0

fix: refs #7353 sales person filter and locale

This commit is contained in:
Jorge Penadés 2024-09-17 11:37:44 +02:00
parent 198c47f0c9
commit 56f8cbe615
2 changed files with 21 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import { useRoute } from 'vue-router';
import toDate from 'filters/toDate'; import toDate from 'filters/toDate';
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue'; import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
const { t } = useI18n(); const { t, te } = useI18n();
const $props = defineProps({ const $props = defineProps({
modelValue: { modelValue: {
type: Object, type: Object,
@ -200,6 +200,11 @@ function sanitizer(params) {
} }
return params; return params;
} }
function getLocale(label) {
const globalLocale = `globals.params.${label}`;
return te(globalLocale) ? t(globalLocale) : t(`params.${label}`);
}
</script> </script>
<template> <template>
@ -248,7 +253,12 @@ function sanitizer(params) {
:removable="!unremovableParams?.includes(chip.label)" :removable="!unremovableParams?.includes(chip.label)"
@remove="remove(chip.label)" @remove="remove(chip.label)"
> >
<slot name="tags" :tag="chip" :format-fn="formatValue"> <slot
name="tags"
:tag="chip"
:format-fn="formatValue"
:locale-fn="getLocale"
>
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ chip.label }}:</strong> <strong>{{ chip.label }}:</strong>
<span>"{{ formatValue(chip.value) }}"</span> <span>"{{ formatValue(chip.value) }}"</span>
@ -262,6 +272,7 @@ function sanitizer(params) {
:tags="customTags" :tags="customTags"
:format-fn="formatValue" :format-fn="formatValue"
:search-fn="search" :search-fn="search"
:locale-fn="getLocale"
/> />
</div> </div>
</QItem> </QItem>

View File

@ -11,7 +11,7 @@ import FetchData from 'src/components/FetchData.vue';
import { dateRange } from 'src/filters'; import { dateRange } from 'src/filters';
defineProps({ dataKey: { type: String, required: true } }); defineProps({ dataKey: { type: String, required: true } });
const { t } = useI18n(); const { t, te } = useI18n();
const warehouses = ref(); const warehouses = ref();
const groupedStates = ref(); const groupedStates = ref();
@ -26,6 +26,11 @@ const handleScopeDays = (params, days, callback) => {
} }
if (callback) callback(); if (callback) callback();
}; };
const getLocale = (label) => {
const globalLocale = `globals.params.${label}`;
return te(globalLocale) ? t(globalLocale) : t(`params.${label}`);
};
</script> </script>
<template> <template>
<FetchData url="Warehouses" auto-load @on-fetch="(data) => (warehouses = data)" /> <FetchData url="Warehouses" auto-load @on-fetch="(data) => (warehouses = data)" />
@ -46,7 +51,7 @@ const handleScopeDays = (params, days, callback) => {
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong v-text="`${t(`params.${tag.label}`)}:`" /> <strong v-text="`${getLocale(tag.label)}:`" />
<span v-text="formatFn(tag.value)" /> <span v-text="formatFn(tag.value)" />
</div> </div>
</template> </template>
@ -110,7 +115,7 @@ const handleScopeDays = (params, days, callback) => {
url="Workers/search" url="Workers/search"
:params="{ departmentCodes: ['VT'] }" :params="{ departmentCodes: ['VT'] }"
is-outlined is-outlined
option-value="code" option-value="id"
option-label="name" option-label="name"
:no-one="true" :no-one="true"
> >