Merge pull request 'feat: minor visual changes' (!1546) from improve_ticker_order_list into master
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1546 Reviewed-by: Jon Elias <jon@verdnatura.es>
This commit is contained in:
commit
9f27674894
|
@ -17,7 +17,15 @@ describe('getAddresses', () => {
|
||||||
expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, {
|
expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, {
|
||||||
params: {
|
params: {
|
||||||
filter: JSON.stringify({
|
filter: JSON.stringify({
|
||||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['defaultAddressFk'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fields: ['nickname', 'street', 'city', 'id', 'isActive', 'clientFk'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -4,7 +4,15 @@ export async function getAddresses(clientId, _filter = {}) {
|
||||||
if (!clientId) return;
|
if (!clientId) return;
|
||||||
const filter = {
|
const filter = {
|
||||||
..._filter,
|
..._filter,
|
||||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['defaultAddressFk'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fields: ['nickname', 'street', 'city', 'id', 'isActive', 'clientFk'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { computed, ref, onMounted } from 'vue';
|
import { computed, ref, onMounted, watch } from 'vue';
|
||||||
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
|
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
|
||||||
import { toDateTimeFormat } from 'src/filters/date';
|
import { toDateTimeFormat } from 'src/filters/date';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
@ -16,6 +16,7 @@ import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnSection from 'src/components/common/VnSection.vue';
|
import VnSection from 'src/components/common/VnSection.vue';
|
||||||
|
import { getAddresses } from '../Customer/composables/getAddresses';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
@ -24,6 +25,11 @@ const agencyList = ref([]);
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const addressOptions = ref([]);
|
const addressOptions = ref([]);
|
||||||
const dataKey = 'OrderList';
|
const dataKey = 'OrderList';
|
||||||
|
const formInitialData = ref({
|
||||||
|
active: true,
|
||||||
|
addressId: null,
|
||||||
|
clientFk: null,
|
||||||
|
});
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
|
@ -147,32 +153,41 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
if (!route.query.createForm) return;
|
if (!route.query) return;
|
||||||
const clientId = route.query.createForm;
|
if (route.query?.createForm) {
|
||||||
const id = JSON.parse(clientId);
|
const query = JSON.parse(route.query?.createForm);
|
||||||
fetchClientAddress(id.clientFk);
|
formInitialData.value = query;
|
||||||
|
await onClientSelected({ ...formInitialData.value, clientId: query?.clientFk });
|
||||||
|
} else if (route.query?.table) {
|
||||||
|
const query = JSON.parse(route.query?.table);
|
||||||
|
const clientId = query?.clientFk;
|
||||||
|
if (clientId) await onClientSelected({ clientId });
|
||||||
|
}
|
||||||
|
if (tableRef.value) tableRef.value.create.formInitialData = formInitialData.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetchClientAddress(id, formData = {}) {
|
watch(
|
||||||
const { data } = await axios.get(`Clients/${id}/addresses`, {
|
() => route.query.table,
|
||||||
params: {
|
async (newValue) => {
|
||||||
filter: JSON.stringify({
|
if (newValue) {
|
||||||
include: [
|
const clientId = +JSON.parse(newValue)?.clientFk;
|
||||||
{
|
if (clientId) await onClientSelected({ clientId });
|
||||||
relation: 'client',
|
if (tableRef.value)
|
||||||
scope: {
|
tableRef.value.create.formInitialData = formInitialData.value;
|
||||||
fields: ['defaultAddressFk'],
|
}
|
||||||
},
|
},
|
||||||
},
|
{ immediate: true },
|
||||||
],
|
);
|
||||||
order: ['isActive DESC'],
|
|
||||||
}),
|
async function onClientSelected({ clientId: id }, formData = {}) {
|
||||||
},
|
const { data } = await getAddresses(id);
|
||||||
});
|
|
||||||
addressOptions.value = data;
|
addressOptions.value = data;
|
||||||
formData.addressId = data[0].client.defaultAddressFk;
|
formData.defaultAddressFk = data[0].client.defaultAddressFk;
|
||||||
fetchAgencies(formData);
|
formData.addressId = formData.defaultAddressFk;
|
||||||
|
|
||||||
|
formInitialData.value = { addressId: formData.addressId, clientFk: id };
|
||||||
|
await fetchAgencies(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAgencies({ landed, addressId }) {
|
async function fetchAgencies({ landed, addressId }) {
|
||||||
|
@ -181,7 +196,7 @@ async function fetchAgencies({ landed, addressId }) {
|
||||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||||
params: {
|
params: {
|
||||||
filter: JSON.stringify({
|
filter: JSON.stringify({
|
||||||
order: ['agencyMode DESC', 'agencyModeFk ASC'],
|
order: ['name ASC', 'agencyMode DESC', 'agencyModeFk ASC'],
|
||||||
}),
|
}),
|
||||||
addressFk: addressId,
|
addressFk: addressId,
|
||||||
landed,
|
landed,
|
||||||
|
@ -224,11 +239,7 @@ const getDateColor = (date) => {
|
||||||
onDataSaved: (url) => {
|
onDataSaved: (url) => {
|
||||||
tableRef.redirect(`${url}/catalog`);
|
tableRef.redirect(`${url}/catalog`);
|
||||||
},
|
},
|
||||||
formInitialData: {
|
formInitialData,
|
||||||
active: true,
|
|
||||||
addressId: null,
|
|
||||||
clientFk: null,
|
|
||||||
},
|
|
||||||
}"
|
}"
|
||||||
:user-params="{ showEmpty: false }"
|
:user-params="{ showEmpty: false }"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
@ -260,7 +271,7 @@ 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) => fetchClientAddress(id, data)"
|
@update:model-value="(id) => onClientSelected(id, data)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
@ -285,7 +296,22 @@ const getDateColor = (date) => {
|
||||||
@update:model-value="() => fetchAgencies(data)"
|
@update:model-value="() => fetchAgencies(data)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem
|
||||||
|
v-bind="scope.itemProps"
|
||||||
|
:class="{ disabled: !scope.opt.isActive }"
|
||||||
|
>
|
||||||
|
<QItemSection style="min-width: min-content" avatar>
|
||||||
|
<QIcon
|
||||||
|
v-if="
|
||||||
|
scope.opt.isActive &&
|
||||||
|
data.defaultAddressFk === scope.opt.id
|
||||||
|
"
|
||||||
|
size="sm"
|
||||||
|
color="grey"
|
||||||
|
name="star"
|
||||||
|
class="fill-icon"
|
||||||
|
/>
|
||||||
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<QItemLabel
|
<QItemLabel
|
||||||
:class="{
|
:class="{
|
||||||
|
@ -313,6 +339,7 @@ const getDateColor = (date) => {
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
v-model="data.landed"
|
v-model="data.landed"
|
||||||
:label="t('module.landed')"
|
:label="t('module.landed')"
|
||||||
|
data-cy="landedDate"
|
||||||
@update:model-value="() => fetchAgencies(data)"
|
@update:model-value="() => fetchAgencies(data)"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
|
|
@ -740,7 +740,7 @@ watch(
|
||||||
{{ row?.item?.subName.toUpperCase() }}
|
{{ row?.item?.subName.toUpperCase() }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<FetchedTags :item="row" :max-length="6" />
|
<FetchedTags :item="row.item" :max-length="6" />
|
||||||
<QPopupProxy v-if="row.id && isTicketEditable">
|
<QPopupProxy v-if="row.id && isTicketEditable">
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model="row.concept"
|
v-model="row.concept"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { computed, ref, onBeforeMount, watch } from 'vue';
|
import { computed, ref, onBeforeMount, watch, onMounted } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
@ -51,10 +51,21 @@ const userParams = {
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
initializeFromQuery();
|
initializeFromQuery();
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
if (!route.query.createForm) return;
|
});
|
||||||
onClientSelected(JSON.parse(route.query.createForm));
|
onMounted(async () => {
|
||||||
|
if (!route.query) return;
|
||||||
|
if (route.query?.createForm) {
|
||||||
|
formInitialData.value = JSON.parse(route.query?.createForm);
|
||||||
|
await onClientSelected(formInitialData.value);
|
||||||
|
} else if (route.query?.table) {
|
||||||
|
const query = route.query?.table;
|
||||||
|
const clientId = +JSON.parse(query)?.clientFk;
|
||||||
|
if (clientId) await onClientSelected({ clientId });
|
||||||
|
}
|
||||||
|
if (tableRef.value) tableRef.value.create.formInitialData = formInitialData.value;
|
||||||
});
|
});
|
||||||
const initializeFromQuery = () => {
|
const initializeFromQuery = () => {
|
||||||
|
if (!route) return;
|
||||||
const query = route.query.table ? JSON.parse(route.query.table) : {};
|
const query = route.query.table ? JSON.parse(route.query.table) : {};
|
||||||
from.value = query.from || from.toISOString();
|
from.value = query.from || from.toISOString();
|
||||||
to.value = query.to || to.toISOString();
|
to.value = query.to || to.toISOString();
|
||||||
|
@ -69,7 +80,6 @@ const companiesOptions = ref([]);
|
||||||
const accountingOptions = ref([]);
|
const accountingOptions = ref([]);
|
||||||
const amountToReturn = ref();
|
const amountToReturn = ref();
|
||||||
const dataKey = 'TicketList';
|
const dataKey = 'TicketList';
|
||||||
const filterPanelRef = ref(null);
|
|
||||||
const formInitialData = ref({});
|
const formInitialData = ref({});
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
|
@ -251,7 +261,32 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
const onClientSelected = async (formData) => {
|
||||||
|
resetAgenciesSelector(formData);
|
||||||
|
await fetchAddresses(formData);
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchAddresses = async (formData) => {
|
||||||
|
const { data } = await getAddresses(formData.clientId);
|
||||||
|
formInitialData.value = { clientId: formData.clientId };
|
||||||
|
if (!data) return;
|
||||||
|
addressesOptions.value = data;
|
||||||
|
selectedClient.value = data[0].client;
|
||||||
|
formData.addressId = selectedClient.value.defaultAddressFk;
|
||||||
|
formInitialData.value.addressId = formData.addressId;
|
||||||
|
};
|
||||||
|
watch(
|
||||||
|
() => route.query.table,
|
||||||
|
async (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
const clientId = +JSON.parse(newValue)?.clientFk;
|
||||||
|
if (clientId) await onClientSelected({ clientId });
|
||||||
|
if (tableRef.value)
|
||||||
|
tableRef.value.create.formInitialData = formInitialData.value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
function resetAgenciesSelector(formData) {
|
function resetAgenciesSelector(formData) {
|
||||||
agenciesOptions.value = [];
|
agenciesOptions.value = [];
|
||||||
if (formData) formData.agencyModeId = null;
|
if (formData) formData.agencyModeId = null;
|
||||||
|
@ -262,12 +297,6 @@ function redirectToLines(id) {
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClientSelected = async (formData) => {
|
|
||||||
resetAgenciesSelector(formData);
|
|
||||||
await fetchClient(formData);
|
|
||||||
await fetchAddresses(formData);
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
resetAgenciesSelector(formData);
|
resetAgenciesSelector(formData);
|
||||||
const response = await getAgencies(formData, selectedClient.value);
|
const response = await getAgencies(formData, selectedClient.value);
|
||||||
|
@ -278,22 +307,6 @@ const fetchAvailableAgencies = async (formData) => {
|
||||||
if (agency) formData.agencyModeId = agency.agencyModeFk;
|
if (agency) formData.agencyModeId = agency.agencyModeFk;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
|
||||||
const response = await getClient(formData.clientId);
|
|
||||||
if (!response) return;
|
|
||||||
const [client] = response.data;
|
|
||||||
selectedClient.value = client;
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
|
||||||
const response = await getAddresses(formData.clientId);
|
|
||||||
if (!response) return;
|
|
||||||
addressesOptions.value = response.data;
|
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
|
||||||
formData.addressId = defaultAddress.id;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getColor = (row) => {
|
const getColor = (row) => {
|
||||||
if (row.alertLevelCode === 'OK') return 'bg-success';
|
if (row.alertLevelCode === 'OK') return 'bg-success';
|
||||||
else if (row.alertLevelCode === 'FREE') return 'bg-notice';
|
else if (row.alertLevelCode === 'FREE') return 'bg-notice';
|
||||||
|
@ -445,22 +458,6 @@ function setReference(data) {
|
||||||
|
|
||||||
dialogData.value.value.description = newDescription;
|
dialogData.value.value.description = newDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.query.table,
|
|
||||||
(newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
const clientId = +JSON.parse(newValue)?.clientFk;
|
|
||||||
if (!clientId) return;
|
|
||||||
formInitialData.value = {
|
|
||||||
clientId,
|
|
||||||
};
|
|
||||||
if (tableRef.value) tableRef.value.create.formInitialData = { clientId };
|
|
||||||
onClientSelected({ clientId });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
describe('OrderList', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login('developer');
|
||||||
|
cy.viewport(1920, 1080);
|
||||||
|
cy.visit('/#/order/list');
|
||||||
|
cy.domContentLoad();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create order', () => {
|
||||||
|
/* ==== Generated with Cypress Studio ==== */
|
||||||
|
cy.get('[data-cy="vnTableCreateBtn"]').click();
|
||||||
|
cy.get('[data-cy="Client_select"]').type('1101');
|
||||||
|
cy.get('.q-menu').contains('Bruce Wayne').click();
|
||||||
|
cy.get('[data-cy="Address_select"]').click();
|
||||||
|
cy.get(
|
||||||
|
'.q-menu > div> div.q-item:nth-child(1) >div.q-item__section--avatar > i',
|
||||||
|
).should('have.text', 'star');
|
||||||
|
cy.get('.q-menu > div> .q-item:nth-child(1)').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`);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,5 +1,5 @@
|
||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
describe('TicketList', () => {
|
describe.only('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(() => {
|
||||||
|
@ -69,7 +69,7 @@ describe('TicketList', () => {
|
||||||
cy.url().should('match', /\/ticket\/\d+\/summary/);
|
cy.url().should('match', /\/ticket\/\d+\/summary/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the corerct problems', () => {
|
it('should show the correct problems', () => {
|
||||||
cy.intercept('GET', '**/api/Tickets/filter*', (req) => {
|
cy.intercept('GET', '**/api/Tickets/filter*', (req) => {
|
||||||
req.headers['cache-control'] = 'no-cache';
|
req.headers['cache-control'] = 'no-cache';
|
||||||
req.headers['pragma'] = 'no-cache';
|
req.headers['pragma'] = 'no-cache';
|
||||||
|
|
|
@ -183,14 +183,17 @@ describe('TicketSale', () => {
|
||||||
it('change quantity ', () => {
|
it('change quantity ', () => {
|
||||||
const quantity = Math.floor(Math.random() * 100) + 1;
|
const quantity = Math.floor(Math.random() * 100) + 1;
|
||||||
cy.waitForElement(firstRow);
|
cy.waitForElement(firstRow);
|
||||||
cy.dataCy('ticketSaleQuantityInput').clear();
|
cy.dataCy('ticketSaleQuantityInput').find('input').clear();
|
||||||
cy.dataCy('ticketSaleQuantityInput').type(quantity).trigger('tab');
|
cy.dataCy('ticketSaleQuantityInput')
|
||||||
|
.find('input')
|
||||||
|
.type(quantity)
|
||||||
|
.trigger('tab');
|
||||||
cy.get('.q-page > :nth-child(6)').click();
|
cy.get('.q-page > :nth-child(6)').click();
|
||||||
|
|
||||||
handleVnConfirm();
|
handleVnConfirm();
|
||||||
|
|
||||||
cy.get('[data-cy="ticketSaleQuantityInput"]')
|
cy.get('[data-cy="ticketSaleQuantityInput"]')
|
||||||
.find('[data-cy="undefined_input"]')
|
.find('input')
|
||||||
.should('have.value', `${quantity}`);
|
.should('have.value', `${quantity}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue