test: refs #7356 removing unused mapper functions and updating default mapper logic
This commit is contained in:
parent
73740822a3
commit
2190a0c17d
|
@ -69,7 +69,12 @@ const $props = defineProps({
|
|||
},
|
||||
mapper: {
|
||||
type: Function,
|
||||
default: null,
|
||||
default: (formData, originalData) => {
|
||||
return getUpdatedValues(
|
||||
Object.keys(getDifferences(formData, originalData)),
|
||||
formData,
|
||||
);
|
||||
},
|
||||
},
|
||||
clearStoreOnUnmount: {
|
||||
type: Boolean,
|
||||
|
@ -221,9 +226,7 @@ async function save() {
|
|||
isLoading.value = true;
|
||||
try {
|
||||
formData.value = trimData(formData.value);
|
||||
const body = $props.mapper
|
||||
? $props.mapper(formData.value, originalData.value)
|
||||
: formData.value;
|
||||
const body = $props.mapper(formData.value, originalData.value);
|
||||
const method = $props.urlCreate ? 'post' : 'patch';
|
||||
const url =
|
||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||
|
@ -289,12 +292,7 @@ function trimData(data) {
|
|||
}
|
||||
return data;
|
||||
}
|
||||
function onBeforeSave(formData, originalData) {
|
||||
return getUpdatedValues(
|
||||
Object.keys(getDifferences(formData, originalData)),
|
||||
formData,
|
||||
);
|
||||
}
|
||||
|
||||
async function onKeyup(evt) {
|
||||
if (evt.key === 'Enter' && !('prevent-submit' in attrs)) {
|
||||
const input = evt.target;
|
||||
|
@ -331,7 +329,7 @@ defineExpose({
|
|||
class="q-pa-md"
|
||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
||||
id="formModel"
|
||||
:mapper="onBeforeSave"
|
||||
:mapper="mapper"
|
||||
>
|
||||
<QCard>
|
||||
<slot
|
||||
|
|
|
@ -52,12 +52,7 @@ function onBeforeSave(formData, originalData) {
|
|||
@on-fetch="(data) => (businessTypes = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
:url-update="`Clients/${route.params.id}`"
|
||||
auto-load
|
||||
:mapper="onBeforeSave"
|
||||
model="Customer"
|
||||
>
|
||||
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="Customer">
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnInput
|
||||
|
|
|
@ -31,12 +31,6 @@ function handleLocation(data, location) {
|
|||
data.provinceFk = provinceFk;
|
||||
data.countryFk = countryFk;
|
||||
}
|
||||
function onBeforeSave(formData, originalData) {
|
||||
return getUpdatedValues(
|
||||
Object.keys(getDifferences(formData, originalData)),
|
||||
formData,
|
||||
);
|
||||
}
|
||||
|
||||
async function checkEtChanges(data, _, originalData) {
|
||||
const equalizatedHasChanged = originalData.isEqualizated != data.isEqualizated;
|
||||
|
@ -75,7 +69,6 @@ async function acceptPropagate({ isEqualizated }) {
|
|||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||
auto-load
|
||||
model="Customer"
|
||||
:mapper="onBeforeSave"
|
||||
observe-form-changes
|
||||
@on-data-saved="checkEtChanges"
|
||||
>
|
||||
|
|
|
@ -103,17 +103,6 @@ const calculateFromDeliveredAmount = (event) => {
|
|||
initialData.amountToReturn = parseFloat(event) - initialData.amountPaid;
|
||||
};
|
||||
|
||||
function onBeforeSave(data) {
|
||||
const exceededAmount = data.amountPaid > maxAmount.value;
|
||||
if (isCash.value && exceededAmount)
|
||||
return notify(t('Amount exceeded', { maxAmount: maxAmount.value }), 'negative');
|
||||
|
||||
if (isCash.value && shouldSendEmail.value && !data.email)
|
||||
return notify(t('There is no assigned email for this client'), 'negative');
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async function onDataSaved(formData, { id }) {
|
||||
try {
|
||||
if (shouldSendEmail.value && isCash.value)
|
||||
|
@ -182,7 +171,6 @@ async function getAmountPaid() {
|
|||
ref="formModelRef"
|
||||
:form-initial-data="initialData"
|
||||
:url-create="urlCreate"
|
||||
:mapper="onBeforeSave"
|
||||
@on-data-saved="onDataSaved"
|
||||
:prevent-submit="true"
|
||||
>
|
||||
|
|
|
@ -91,7 +91,7 @@ const totalPrice = computed(() => {
|
|||
const totalNewPrice = computed(() => {
|
||||
return rows.value.reduce(
|
||||
(acc, item) => acc + item.component.newPrice * item.quantity,
|
||||
0
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -210,18 +210,18 @@ onMounted(async () => {
|
|||
flat
|
||||
>
|
||||
<template #body-cell-item="{ row }">
|
||||
<QTd @click.stop class="link">
|
||||
<QBtn flat>
|
||||
<QTd align="center">
|
||||
<span @click.stop class="link">
|
||||
{{ row.itemFk }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</QBtn>
|
||||
</span>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-description="{ row }">
|
||||
<QTd style="min-width: 120px; max-width: 120px">
|
||||
<div class="column q-pb-xs" style="min-width: 120px">
|
||||
<span>{{ row.item.name }}</span>
|
||||
<FetchedTags :item="row.item" class="full-width" />
|
||||
<FetchedTags :item="row.item" class="full-width" :columns="6" />
|
||||
</div>
|
||||
</QTd>
|
||||
</template>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
|
||||
import TicketBasicData from './TicketBasicData.vue';
|
||||
import TicketBasicDataForm from './TicketBasicDataForm.vue';
|
||||
|
@ -13,6 +13,7 @@ import { useArrayData } from 'src/composables/useArrayData';
|
|||
|
||||
const { notify } = useNotify();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const stepperRef = ref(null);
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
|
@ -21,6 +22,7 @@ const step = ref(1);
|
|||
const haveNegatives = ref(true);
|
||||
|
||||
const ticket = computed(() => useArrayData('Ticket').store?.data);
|
||||
const entityId = computed(() => +route?.params?.id);
|
||||
|
||||
const isFormInvalid = () => {
|
||||
return (
|
||||
|
@ -44,7 +46,7 @@ const getPriceDifference = async () => {
|
|||
shipped: ticket.value.shipped,
|
||||
};
|
||||
const { data } = await axios.post(
|
||||
`tickets/${formData.value.id}/priceDifference`,
|
||||
`tickets/${entityId.value}/priceDifference`,
|
||||
params,
|
||||
);
|
||||
ticket.value.sale = data;
|
||||
|
@ -71,7 +73,7 @@ const submit = async () => {
|
|||
};
|
||||
|
||||
const { data } = await axios.post(
|
||||
`tickets/${formData.value.id}/componentUpdate`,
|
||||
`tickets/${entityId.value}/componentUpdate`,
|
||||
params,
|
||||
);
|
||||
|
||||
|
|
|
@ -6,7 +6,47 @@ describe('TicketRequest', () => {
|
|||
cy.visit('/#/ticket/31/basic-data');
|
||||
});
|
||||
|
||||
it('Should load layout', () => {
|
||||
it('Should redirect to customer basic data', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.get(':nth-child(2) > div > .text-primary').click();
|
||||
cy.get('[data-cy="Address_select"]').click();
|
||||
cy.get('.q-btn-group > [data-v-d4506789=""] > .q-btn__content > .q-icon').click();
|
||||
cy.get(
|
||||
'[data-cy="CustomerBasicData-menu-item"] > .q-item__section--main',
|
||||
).click();
|
||||
cy.url().should('include', '/customer/1104/basic-data');
|
||||
});
|
||||
it.only('stepper', () => {
|
||||
cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active');
|
||||
|
||||
cy.get('.q-stepper__nav > .q-btn--standard').click();
|
||||
cy.get('.q-stepper__tab--done').should('have.class', 'q-stepper__tab--done');
|
||||
cy.get('.q-stepper__tab--active').should('have.class', 'q-stepper__tab--active');
|
||||
cy.get('tr:nth-child(1)>:nth-child(1)>span').should('have.class', 'link').click();
|
||||
cy.dataCy('ItemDescriptor').should('exist');
|
||||
cy.get('.q-drawer__content > :nth-child(1) > :nth-child(2) > span').should(
|
||||
'have.text',
|
||||
'Price: €34.40',
|
||||
);
|
||||
cy.get('.q-drawer__content > :nth-child(1) > :nth-child(3) > span').should(
|
||||
'have.text',
|
||||
'New price: €34.20',
|
||||
);
|
||||
cy.get('.q-drawer__content > :nth-child(1) > :nth-child(4) > span').should(
|
||||
'have.text',
|
||||
'Difference: €0.20',
|
||||
);
|
||||
cy.get(
|
||||
':nth-child(3) > .q-radio > .q-radio__inner > .q-radio__bg > .q-radio__check',
|
||||
).should('have.class', 'q-radio__check');
|
||||
cy.get(
|
||||
'.q-stepper__step-inner > .q-drawer-container > .q-drawer > .q-drawer__content',
|
||||
).click();
|
||||
cy.get(':nth-child(2) > :nth-child(1) > .text-weight-bold').click();
|
||||
cy.get(':nth-child(3) > .q-radio > .q-radio__inner').should(
|
||||
'have.class',
|
||||
'q-radio__inner--truthy',
|
||||
);
|
||||
cy.get('.q-drawer__content > :nth-child(2)').click();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,10 +3,20 @@ describe('TicketRequest', () => {
|
|||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/31/sms');
|
||||
cy.visit('/#/ticket/32/sms');
|
||||
});
|
||||
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
cy.get('.q-infinite-scroll > :nth-child(1)').should(
|
||||
'have.text',
|
||||
'0004 444444444Lorem ipsum dolor sit amet, consectetur adipiscing elit.2001-01-01 00:00:00OK',
|
||||
);
|
||||
cy.get(
|
||||
':nth-child(1) > .q-item > .q-item__section--top > .column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image',
|
||||
).should('have.class', 'q-img__image--loaded');
|
||||
cy.get(
|
||||
':nth-child(1) > .q-item > .q-item__section--side.justify-center > .center > .q-chip > .q-chip__content',
|
||||
).should('have.class', 'q-chip__content');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue