HOTFIX: ticketSale keyup.enter #1009

Merged
jsegarra merged 5 commits from hotfix_ticketSale_enter into master 2024-11-28 10:03:40 +00:00
10 changed files with 177 additions and 149 deletions
Showing only changes of commit dc156e44b6 - Show all commits

View File

@ -1,6 +1,7 @@
<script setup> <script setup>
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue'; import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
import axios from 'axios'; import axios from 'axios';
import { parsePhone } from 'src/filters';
const props = defineProps({ const props = defineProps({
phoneNumber: { type: [String, Number], default: null }, phoneNumber: { type: [String, Number], default: null },
channel: { type: Number, default: null }, channel: { type: Number, default: null },
@ -24,9 +25,9 @@ onBeforeMount(async () => {
.data; .data;
if (!channel) channel = defaultChannel; if (!channel) channel = defaultChannel;
config[ config[type].href = `${url}?customerIdentity=%2B${parsePhone(
type props.phoneNumber
].href = `${url}?customerIdentity=%2B${props.phoneNumber}&channelId=${channel}`; )}&channelId=${channel}`;
} }
}); });
</script> </script>

View File

@ -12,10 +12,12 @@ import dateRange from './dateRange';
import toHour from './toHour'; import toHour from './toHour';
import dashOrCurrency from './dashOrCurrency'; import dashOrCurrency from './dashOrCurrency';
import getParamWhere from './getParamWhere'; import getParamWhere from './getParamWhere';
import parsePhone from './parsePhone';
import isDialogOpened from './isDialogOpened'; import isDialogOpened from './isDialogOpened';
export { export {
isDialogOpened, isDialogOpened,
parsePhone,
toLowerCase, toLowerCase,
toLowerCamel, toLowerCamel,
toDate, toDate,

12
src/filters/parsePhone.js Normal file
View File

@ -0,0 +1,12 @@
export default function (phone, prefix = 34) {
if (phone.startsWith('+')) {
return `${phone.slice(1)}`;
}
if (phone.startsWith('00')) {
return `${phone.slice(2)}`;
}
if (phone.startsWith(prefix) && phone.length === prefix.length + 9) {
return `${prefix}${phone.slice(prefix.length)}`;
}
return `${prefix}${phone}`;
}

View File

@ -861,7 +861,6 @@ components:
cardDescriptor: cardDescriptor:
mainList: Main list mainList: Main list
summary: Summary summary: Summary
moreOptions: More options
leftMenu: leftMenu:
addToPinned: Add to pinned addToPinned: Add to pinned
removeFromPinned: Remove from pinned removeFromPinned: Remove from pinned

View File

@ -101,8 +101,8 @@ const exprBuilder = (param, value) => {
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem class="q-mb-sm"> <QItem class="q-mb-sm">
<QItemSection <QItemSection>
><VnSelect <VnSelect
url="Provinces" url="Provinces"
:label="t('Province')" :label="t('Province')"
v-model="params.provinceFk" v-model="params.provinceFk"
@ -120,32 +120,31 @@ const exprBuilder = (param, value) => {
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem class="q-mb-md"> <QItem class="q-mb-sm">
<QItemSection> <QItemSection>
<VnInput :label="t('City')" v-model="params.city" is-outlined /> <VnInput :label="t('City')" v-model="params.city" is-outlined />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QSeparator /> <QItem class="q-mb-sm">
<QExpansionItem :label="t('More options')" expand-separator> <QItemSection>
<QItem> <VnInput :label="t('Phone')" v-model="params.phone" is-outlined>
<QItemSection> <template #prepend>
<VnInput :label="t('Phone')" v-model="params.phone" is-outlined> <QIcon name="phone" size="xs" />
<template #prepend> </template>
<QIcon name="phone" size="xs" /> </VnInput>
</template> </QItemSection>
</VnInput> </QItem>
</QItemSection> <QItem class="q-mb-sm">
</QItem> <QItemSection>
<QItem> <VnInput :label="t('Email')" v-model="params.email" is-outlined>
<QItemSection> <template #prepend>
<VnInput :label="t('Email')" v-model="params.email" is-outlined> <QIcon name="email" size="sm" />
<template #prepend> </template>
<QIcon name="email" size="sm" /> </VnInput>
</template> </QItemSection>
</VnInput> </QItem>
</QItemSection> <QItem class="q-mb-sm">
</QItem> <QItemSection>
<QItem>
<VnSelect <VnSelect
url="Zones" url="Zones"
:label="t('Zone')" :label="t('Zone')"
@ -160,18 +159,17 @@ const exprBuilder = (param, value) => {
outlined outlined
rounded rounded
auto-load auto-load
/></QItemSection>
</QItem>
<QItem class="q-mb-sm">
<QItemSection>
<VnInput
:label="t('Postcode')"
v-model="params.postcode"
is-outlined
/> />
</QItem> </QItemSection>
<QItem> </QItem>
<QItemSection>
<VnInput
:label="t('Postcode')"
v-model="params.postcode"
is-outlined
/>
</QItemSection>
</QItem>
</QExpansionItem>
</template> </template>
</VnFilterPanel> </VnFilterPanel>
</template> </template>
@ -203,7 +201,6 @@ es:
Salesperson: Comercial Salesperson: Comercial
Province: Provincia Province: Provincia
City: Ciudad City: Ciudad
More options: Más opciones
Phone: Teléfono Phone: Teléfono
Email: Email Email: Email
Zone: Zona Zone: Zona

View File

@ -184,5 +184,4 @@ es:
Amount: Importe Amount: Importe
Issued: Fecha factura Issued: Fecha factura
Id or supplier: Id o proveedor Id or supplier: Id o proveedor
More options: Más opciones
</i18n> </i18n>

View File

@ -83,36 +83,29 @@ const states = ref();
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QSeparator /> <QItem>
<QExpansionItem :label="t('More options')" expand-separator> <QItemSection>
<QItem> <VnInputDate
<QItemSection> v-model="params.issued"
<VnInputDate :label="t('Issued')"
v-model="params.issued" is-outlined
:label="t('Issued')" />
is-outlined </QItemSection>
/> </QItem>
</QItemSection> <QItem>
</QItem> <QItemSection>
<QItem> <VnInputDate
<QItemSection> v-model="params.created"
<VnInputDate :label="t('Created')"
v-model="params.created" is-outlined
:label="t('Created')" />
is-outlined </QItemSection>
/> </QItem>
</QItemSection> <QItem>
</QItem> <QItemSection>
<QItem> <VnInputDate v-model="params.dued" :label="t('Dued')" is-outlined />
<QItemSection> </QItemSection>
<VnInputDate </QItem>
v-model="params.dued"
:label="t('Dued')"
is-outlined
/>
</QItemSection>
</QItem>
</QExpansionItem>
</template> </template>
</VnFilterPanel> </VnFilterPanel>
</template> </template>
@ -149,5 +142,4 @@ es:
Issued: Fecha emisión Issued: Fecha emisión
Created: Fecha creación Created: Fecha creación
Dued: Fecha vencimiento Dued: Fecha vencimiento
More options: Más opciones
</i18n> </i18n>

View File

@ -15,6 +15,7 @@ import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vu
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import dataByOrder from 'src/utils/dataByOrder';
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
@ -167,7 +168,7 @@ async function fetchAgencies({ landed, addressId }) {
const { data } = await axios.get('Agencies/landsThatDay', { const { data } = await axios.get('Agencies/landsThatDay', {
params: { addressFk: addressId, landed }, params: { addressFk: addressId, landed },
}); });
agencyList.value = data; agencyList.value = dataByOrder(data, 'agencyMode ASC');
} }
const getDateColor = (date) => { const getDateColor = (date) => {

View File

@ -212,81 +212,78 @@ const getGroupedStates = (data) => {
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QSeparator /> <QItem>
<QExpansionItem :label="t('More options')" expand-separator> <QItemSection v-if="!provinces">
<QItem> <QSkeleton type="QInput" class="full-width" />
<QItemSection v-if="!provinces"> </QItemSection>
<QSkeleton type="QInput" class="full-width" /> <QItemSection v-if="provinces">
</QItemSection> <QSelect
<QItemSection v-if="provinces"> :label="t('Province')"
<QSelect v-model="params.provinceFk"
:label="t('Province')" @update:model-value="searchFn()"
v-model="params.provinceFk" :options="provinces"
@update:model-value="searchFn()" option-value="id"
:options="provinces" option-label="name"
option-value="id" emit-value
option-label="name" map-options
emit-value use-input
map-options dense
use-input outlined
dense rounded
outlined />
rounded </QItemSection>
/> </QItem>
</QItemSection> <QItem>
</QItem> <QItemSection v-if="!agencies">
<QItem> <QSkeleton type="QInput" class="full-width" />
<QItemSection v-if="!agencies"> </QItemSection>
<QSkeleton type="QInput" class="full-width" /> <QItemSection v-if="agencies">
</QItemSection> <QSelect
<QItemSection v-if="agencies"> :label="t('Agency')"
<QSelect v-model="params.agencyModeFk"
:label="t('Agency')" @update:model-value="searchFn()"
v-model="params.agencyModeFk" :options="agencies"
@update:model-value="searchFn()" option-value="id"
:options="agencies" option-label="name"
option-value="id" emit-value
option-label="name" map-options
emit-value use-input
map-options dense
use-input outlined
dense rounded
outlined />
rounded </QItemSection>
/> </QItem>
</QItemSection> <QItem>
</QItem> <QItemSection v-if="!warehouses">
<QItem> <QSkeleton type="QInput" class="full-width" />
<QItemSection v-if="!warehouses"> </QItemSection>
<QSkeleton type="QInput" class="full-width" /> <QItemSection v-if="warehouses">
</QItemSection> <QSelect
<QItemSection v-if="warehouses"> :label="t('Warehouse')"
<QSelect v-model="params.warehouseFk"
:label="t('Warehouse')" @update:model-value="searchFn()"
v-model="params.warehouseFk" :options="warehouses"
@update:model-value="searchFn()" option-value="id"
:options="warehouses" option-label="name"
option-value="id" emit-value
option-label="name" map-options
emit-value use-input
map-options dense
use-input outlined
dense rounded
outlined />
rounded </QItemSection>
/> </QItem>
</QItemSection> <QItem>
</QItem> <QItemSection>
<QItem> <VnInput
<QItemSection> v-model="params.collectionFk"
<VnInput :label="t('Collection')"
v-model="params.collectionFk" is-outlined
:label="t('Collection')" />
is-outlined </QItemSection>
/> </QItem>
</QItemSection>
</QItem>
</QExpansionItem>
</template> </template>
</VnFilterPanel> </VnFilterPanel>
</template> </template>
@ -340,7 +337,6 @@ es:
With problems: Con problemas With problems: Con problemas
Invoiced: Facturado Invoiced: Facturado
Routed: Enrutado Routed: Enrutado
More options: Más opciones
Province: Provincia Province: Provincia
Agency: Agencia Agency: Agencia
Warehouse: Almacén Warehouse: Almacén

View File

@ -0,0 +1,29 @@
import { describe, it, expect } from 'vitest';
import parsePhone from 'src/filters/parsePhone';
describe('parsePhone filter', () => {
it("adds prefix +34 if it doesn't have one", () => {
const resultado = parsePhone('123456789', '34');
expect(resultado).toBe('34123456789');
});
it('maintains prefix +34 if it is already correct', () => {
const resultado = parsePhone('+34123456789', '34');
expect(resultado).toBe('34123456789');
});
it('converts prefix 0034 to +34', () => {
const resultado = parsePhone('0034123456789', '34');
expect(resultado).toBe('34123456789');
});
it('converts prefix 34 without symbol to +34', () => {
const resultado = parsePhone('34123456789', '34');
expect(resultado).toBe('34123456789');
});
it('replaces incorrect prefix with the correct one', () => {
const resultado = parsePhone('+44123456789', '34');
expect(resultado).toBe('44123456789');
});
});