diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index b188bde48..d15f0b3fb 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -79,7 +79,7 @@ const userParams = ref({}); defineExpose({ search, sanitizer, params: userParams }); onMounted(() => { - userParams.value = $props.modelValue ?? {}; + if (!userParams.value) userParams.value = $props.modelValue ?? {}; emit('init', { params: userParams.value }); }); @@ -105,7 +105,8 @@ watch( watch( () => arrayData.store.userParams, - (val, oldValue) => (val || oldValue) && setUserParams(val) + (val, oldValue) => (val || oldValue) && setUserParams(val), + { immediate: true } ); watch( diff --git a/src/filters/parsePhone.js b/src/filters/parsePhone.js index 27474321f..6cb1bea17 100644 --- a/src/filters/parsePhone.js +++ b/src/filters/parsePhone.js @@ -4,13 +4,15 @@ export default async function parsePhone(phone, country) { if (!phone) return; if (phone.startsWith('+')) return `${phone.slice(1)}`; if (phone.startsWith('00')) return `${phone.slice(2)}`; + + let prefix; try { - const prefix = ( - await axios.get(`Prefixes/${country.toLowerCase()}`) - ).data?.prefix.replace(/^0+/, ''); - if (phone.startsWith(prefix)) return phone; - return `${prefix}${phone}`; + prefix = (await axios.get(`Prefixes/${country.toLowerCase()}`)).data?.prefix; } catch (e) { - return null; + prefix = (await axios.get('PbxConfigs/findOne')).data?.defaultPrefix; } + prefix = prefix.replace(/^0+/, ''); + + if (phone.startsWith(prefix)) return phone; + return `${prefix}${phone}`; } diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index 31a6931a4..9c645bdbd 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -330,6 +330,7 @@ globals: fi: FI myTeam: My team departmentFk: Department + countryFk: Country changePass: Change password deleteConfirmTitle: Delete selected elements changeState: Change state diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index ccc21e225..17f82e11e 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -334,6 +334,7 @@ globals: SSN: NSS fi: NIF myTeam: Mi equipo + countryFk: País changePass: Cambiar contraseña deleteConfirmTitle: Eliminar los elementos seleccionados changeState: Cambiar estado diff --git a/src/pages/InvoiceOut/locale/es.yml b/src/pages/InvoiceOut/locale/es.yml index 192f5b26f..feb9050fa 100644 --- a/src/pages/InvoiceOut/locale/es.yml +++ b/src/pages/InvoiceOut/locale/es.yml @@ -10,7 +10,7 @@ invoiceOutList: ref: Referencia issued: Fecha emisión created: F. creación - dueDate: F. máxima + dueDate: Fecha vencimiento invoiceOutSerial: Serial ticket: Ticket taxArea: Area diff --git a/src/pages/Item/Card/ItemTags.vue b/src/pages/Item/Card/ItemTags.vue index f4ab90d93..a077c72c6 100644 --- a/src/pages/Item/Card/ItemTags.vue +++ b/src/pages/Item/Card/ItemTags.vue @@ -138,6 +138,7 @@ const insertTag = (rows) => { :required="false" :rules="validate('itemTag.tagFk')" :use-like="false" + sort-by="value" /> @@ -197,6 +201,18 @@ const getLocale = (label) => { /> + + + + + import('src/pages/Travel/Card/TravelLog.vue'), diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index 1f27cc76f..c5ebe762e 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -106,7 +106,7 @@ export default { }, { name: 'ZoneHistory', - path: 'history', + path: 'log', meta: { title: 'log', icon: 'history', diff --git a/test/vitest/__tests__/components/common/VnLinkPhone.spec.js b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js index 1505e32f7..a34ef90a5 100644 --- a/test/vitest/__tests__/components/common/VnLinkPhone.spec.js +++ b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js @@ -36,4 +36,15 @@ describe('parsePhone filter', () => { const phone = await parsePhone('+44123456789', '34'); expect(phone).toBe('44123456789'); }); + + it('adds default prefix on error', async () => { + vi.spyOn(axios, 'get').mockImplementation((url) => { + if (url.includes('Prefixes')) + return Promise.reject(new Error('Network error')); + else if (url.includes('PbxConfigs')) + return Promise.resolve({ data: { defaultPrefix: '39' } }); + }); + const phone = await parsePhone('123456789', '34'); + expect(phone).toBe('39123456789'); + }); }); diff --git a/test/vitest/helper.js b/test/vitest/helper.js index 4bfae5dc8..ce057c7c3 100644 --- a/test/vitest/helper.js +++ b/test/vitest/helper.js @@ -44,7 +44,18 @@ vi.mock('vue-router', () => ({ vi.mock('axios'); vi.spyOn(useValidator, 'useValidator').mockImplementation(() => { - return { validate: vi.fn() }; + return { + validate: vi.fn(), + validations: () => ({ + format: vi.fn(), + presence: vi.fn(), + required: vi.fn(), + length: vi.fn(), + numericality: vi.fn(), + min: vi.fn(), + custom: vi.fn(), + }), + }; }); class FormDataMock {