Merge pull request 'fix: add agencyModeFk to selectedClient' (!1560) from hotfix_fixGetAgenciesTicketList into master
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1560 Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
commit
561a895d04
|
@ -22,6 +22,12 @@ describe('getAddresses', () => {
|
||||||
relation: 'client',
|
relation: 'client',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['defaultAddressFk'],
|
fields: ['defaultAddressFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'defaultAddress',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'agencyModeFk'],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -9,6 +9,12 @@ export async function getAddresses(clientId, _filter = {}) {
|
||||||
relation: 'client',
|
relation: 'client',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['defaultAddressFk'],
|
fields: ['defaultAddressFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'defaultAddress',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'agencyModeFk'],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -158,11 +158,11 @@ onMounted(async () => {
|
||||||
if (route.query?.createForm) {
|
if (route.query?.createForm) {
|
||||||
const query = JSON.parse(route.query?.createForm);
|
const query = JSON.parse(route.query?.createForm);
|
||||||
formInitialData.value = query;
|
formInitialData.value = query;
|
||||||
await onClientSelected({ ...formInitialData.value, clientId: query?.clientFk });
|
await onClientSelected({ ...formInitialData.value, clientFk: query?.clientFk });
|
||||||
} else if (route.query?.table) {
|
} else if (route.query?.table) {
|
||||||
const query = JSON.parse(route.query?.table);
|
const query = JSON.parse(route.query?.table);
|
||||||
const clientId = query?.clientFk;
|
const clientFk = query?.clientFk;
|
||||||
if (clientId) await onClientSelected({ clientId });
|
if (clientFk) await onClientSelected({ clientFk });
|
||||||
}
|
}
|
||||||
if (tableRef.value) tableRef.value.create.formInitialData = formInitialData.value;
|
if (tableRef.value) tableRef.value.create.formInitialData = formInitialData.value;
|
||||||
});
|
});
|
||||||
|
@ -171,8 +171,8 @@ watch(
|
||||||
() => route.query.table,
|
() => route.query.table,
|
||||||
async (newValue) => {
|
async (newValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
const clientId = +JSON.parse(newValue)?.clientFk;
|
const clientFk = +JSON.parse(newValue)?.clientFk;
|
||||||
if (clientId) await onClientSelected({ clientId });
|
if (clientFk) await onClientSelected({ clientFk });
|
||||||
if (tableRef.value)
|
if (tableRef.value)
|
||||||
tableRef.value.create.formInitialData = formInitialData.value;
|
tableRef.value.create.formInitialData = formInitialData.value;
|
||||||
}
|
}
|
||||||
|
@ -180,13 +180,19 @@ watch(
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
async function onClientSelected({ clientId: id }, formData = {}) {
|
async function onClientSelected({ clientFk }, formData = {}) {
|
||||||
const { data } = await getAddresses(id);
|
if (!clientFk) {
|
||||||
|
addressOptions.value = [];
|
||||||
|
formData.defaultAddressFk = null;
|
||||||
|
formData.addressId = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { data } = await getAddresses(clientFk);
|
||||||
addressOptions.value = data;
|
addressOptions.value = data;
|
||||||
formData.defaultAddressFk = data[0].client.defaultAddressFk;
|
formData.defaultAddressFk = data[0].client.defaultAddressFk;
|
||||||
formData.addressId = formData.defaultAddressFk;
|
formData.addressId = formData.defaultAddressFk;
|
||||||
|
|
||||||
formInitialData.value = { addressId: formData.addressId, clientFk: id };
|
formInitialData.value = { addressId: formData.addressId, clientFk };
|
||||||
await fetchAgencies(formData);
|
await fetchAgencies(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +277,9 @@ const getDateColor = (date) => {
|
||||||
:include="{ relation: 'addresses' }"
|
:include="{ relation: 'addresses' }"
|
||||||
v-model="data.clientFk"
|
v-model="data.clientFk"
|
||||||
:label="t('module.customer')"
|
:label="t('module.customer')"
|
||||||
@update:model-value="(id) => onClientSelected(id, data)"
|
@update:model-value="
|
||||||
|
(id) => onClientSelected({ clientFk: id }, data)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
|
|
@ -22,7 +22,6 @@ import { toTimeFormat } from 'src/filters/date';
|
||||||
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
||||||
import TicketProblems from 'src/components/TicketProblems.vue';
|
import TicketProblems from 'src/components/TicketProblems.vue';
|
||||||
import VnSection from 'src/components/common/VnSection.vue';
|
import VnSection from 'src/components/common/VnSection.vue';
|
||||||
import { getClient } from 'src/pages/Customer/composables/getClient';
|
|
||||||
import { getAddresses } from 'src/pages/Customer/composables/getAddresses';
|
import { getAddresses } from 'src/pages/Customer/composables/getAddresses';
|
||||||
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
|
import { getAgencies } from 'src/pages/Route/Agency/composables/getAgencies';
|
||||||
|
|
||||||
|
@ -267,6 +266,12 @@ const onClientSelected = async (formData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
|
if (!formData.clientId) {
|
||||||
|
addressesOptions.value = [];
|
||||||
|
formData.defaultAddressFk = null;
|
||||||
|
formData.addressId = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const { data } = await getAddresses(formData.clientId);
|
||||||
formInitialData.value = { clientId: formData.clientId };
|
formInitialData.value = { clientId: formData.clientId };
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
|
@ -58,13 +58,22 @@ describe('Client list', () => {
|
||||||
cy.waitForElement('.q-form');
|
cy.waitForElement('.q-form');
|
||||||
cy.checkValueForm(1, search);
|
cy.checkValueForm(1, search);
|
||||||
cy.checkValueForm(2, search);
|
cy.checkValueForm(2, search);
|
||||||
|
cy.dataCy('Customer_select').should('have.value', search);
|
||||||
|
cy.dataCy('Address_select').should('have.value', search);
|
||||||
});
|
});
|
||||||
it('Client founded create order', () => {
|
it('Client founded create order', () => {
|
||||||
const search = 'Jessica Jones';
|
const search = 'Jessica Jones';
|
||||||
cy.searchByLabel('Name', search);
|
|
||||||
|
cy.intercept('GET', /\/api\/Clients\/1110\/summary/).as('customer');
|
||||||
|
cy.dataCy('Name_input').type(`${search}{enter}`);
|
||||||
|
cy.wait('@customer');
|
||||||
|
cy.get('.actions > .q-card__actions').should('exist');
|
||||||
cy.clickButtonWith('icon', 'icon-basketadd');
|
cy.clickButtonWith('icon', 'icon-basketadd');
|
||||||
|
cy.url().should('include', `/customer/1110/summary`);
|
||||||
cy.waitForElement('#formModel');
|
cy.waitForElement('#formModel');
|
||||||
cy.waitForElement('.q-form');
|
cy.waitForElement('.q-form');
|
||||||
cy.checkValueForm(1, search);
|
cy.checkValueForm(1, search);
|
||||||
|
cy.dataCy('Client_select').should('have.value', search);
|
||||||
|
cy.dataCy('Address_select').should('have.value', search);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,6 @@ describe('OrderList', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create order', () => {
|
it('create order', () => {
|
||||||
/* ==== Generated with Cypress Studio ==== */
|
|
||||||
cy.get('[data-cy="vnTableCreateBtn"]').click();
|
cy.get('[data-cy="vnTableCreateBtn"]').click();
|
||||||
cy.get('[data-cy="Client_select"]').type('1101');
|
cy.get('[data-cy="Client_select"]').type('1101');
|
||||||
cy.get('.q-menu').contains('Bruce Wayne').click();
|
cy.get('.q-menu').contains('Bruce Wayne').click();
|
||||||
|
@ -29,4 +28,45 @@ describe('OrderList', () => {
|
||||||
});
|
});
|
||||||
cy.url().should('include', `/order`);
|
cy.url().should('include', `/order`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('filter list and create order', () => {
|
||||||
|
cy.dataCy('Customer ID_input').type('1101{enter}');
|
||||||
|
cy.dataCy('vnTableCreateBtn').click();
|
||||||
|
cy.dataCy('landedDate').find('input').type('06/01/2001');
|
||||||
|
cy.get('.q-card [data-cy="Agency_select"]').click();
|
||||||
|
cy.get('.q-menu > div> .q-item:nth-child(1)').click();
|
||||||
|
cy.intercept('GET', /\/api\/Orders\/\d/).as('orderSale');
|
||||||
|
cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click();
|
||||||
|
cy.wait('@orderSale');
|
||||||
|
cy.get('.q-item > .q-item__label.subtitle').then((text) => {
|
||||||
|
const id = text.text().trim().split('#')[1];
|
||||||
|
cy.get('.q-item > .q-item__label').should('have.text', ` #${id}`);
|
||||||
|
});
|
||||||
|
cy.url().should('include', `/order`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create order from customer summary', function () {
|
||||||
|
const clientId = 1101;
|
||||||
|
cy.dataCy('Customer ID_input').type(`${clientId}{enter}`);
|
||||||
|
cy.get(
|
||||||
|
':nth-child(1) > [data-col-field="clientFk"] > .no-padding > .link',
|
||||||
|
).click();
|
||||||
|
cy.get(
|
||||||
|
`[href="#/order/list?createForm={%22clientFk%22:${clientId},%22addressId%22:1}"] > .q-btn__content > .q-icon`,
|
||||||
|
).click();
|
||||||
|
cy.dataCy('vnTableCreateBtn').click();
|
||||||
|
cy.get('[data-cy="Client_select"]').should('have.value', 'Bruce Wayne');
|
||||||
|
cy.get('[data-cy="Address_select"]').should('have.value', 'Bruce Wayne');
|
||||||
|
cy.dataCy('landedDate').find('input').type('06/01/2001');
|
||||||
|
cy.get('.q-card [data-cy="Agency_select"]').click();
|
||||||
|
cy.get('.q-menu > div> .q-item:nth-child(1)').click();
|
||||||
|
cy.intercept('GET', /\/api\/Orders\/\d/).as('orderSale');
|
||||||
|
cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click();
|
||||||
|
cy.wait('@orderSale');
|
||||||
|
cy.get('.q-item > .q-item__label.subtitle').then((text) => {
|
||||||
|
const id = text.text().trim().split('#')[1];
|
||||||
|
cy.get('.q-item > .q-item__label').should('have.text', ` #${id}`);
|
||||||
|
});
|
||||||
|
cy.url().should('include', `/order`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -139,7 +139,7 @@ describe('Ticket Lack detail', () => {
|
||||||
cy.wait('@getItemGetSimilar');
|
cy.wait('@getItemGetSimilar');
|
||||||
});
|
});
|
||||||
describe('Replace item if', () => {
|
describe('Replace item if', () => {
|
||||||
it.only('Quantity is less than available', () => {
|
it('Quantity is less than available', () => {
|
||||||
cy.get(':nth-child(1) > .text-right > .q-btn').click();
|
cy.get(':nth-child(1) > .text-right > .q-btn').click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
describe.only('TicketList', () => {
|
describe('TicketList', () => {
|
||||||
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -12,12 +12,10 @@ describe.only('TicketList', () => {
|
||||||
const searchResults = (search) => {
|
const searchResults = (search) => {
|
||||||
if (search) cy.typeSearchbar().type(search);
|
if (search) cy.typeSearchbar().type(search);
|
||||||
cy.dataCy('vn-searchbar').find('input').type('{enter}');
|
cy.dataCy('vn-searchbar').find('input').type('{enter}');
|
||||||
// cy.dataCy('ticketListTable').should('exist');
|
|
||||||
cy.get(firstRow).should('exist');
|
cy.get(firstRow).should('exist');
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should search results', () => {
|
it('should search results', () => {
|
||||||
// cy.dataCy('ticketListTable').should('not.exist');
|
|
||||||
cy.get('.q-field__control').should('exist');
|
cy.get('.q-field__control').should('exist');
|
||||||
searchResults();
|
searchResults();
|
||||||
});
|
});
|
||||||
|
@ -53,7 +51,7 @@ describe.only('TicketList', () => {
|
||||||
cy.getOption().click();
|
cy.getOption().click();
|
||||||
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
|
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
|
||||||
});
|
});
|
||||||
it('Client list create new client', () => {
|
it('Client list create new ticket', () => {
|
||||||
cy.dataCy('vnTableCreateBtn').should('exist');
|
cy.dataCy('vnTableCreateBtn').should('exist');
|
||||||
cy.dataCy('vnTableCreateBtn').click();
|
cy.dataCy('vnTableCreateBtn').click();
|
||||||
const data = {
|
const data = {
|
||||||
|
|
Loading…
Reference in New Issue