Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
commit
81f0c747a5
|
@ -245,7 +245,7 @@ export function useArrayData(key, userOptions) {
|
|||
async function loadMore() {
|
||||
if (!store.hasMoreData) return;
|
||||
|
||||
store.skip = store.limit * store.page;
|
||||
store.skip = (store?.filter?.limit ?? store.limit) * store.page;
|
||||
store.page += 1;
|
||||
|
||||
await fetch({ append: true });
|
||||
|
|
|
@ -17,7 +17,15 @@ describe('getAddresses', () => {
|
|||
expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, {
|
||||
params: {
|
||||
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 },
|
||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||
}),
|
||||
|
|
|
@ -4,7 +4,15 @@ export async function getAddresses(clientId, _filter = {}) {
|
|||
if (!clientId) return;
|
||||
const filter = {
|
||||
..._filter,
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||
include: [
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['defaultAddressFk'],
|
||||
},
|
||||
},
|
||||
],
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive', 'clientFk'],
|
||||
where: { isActive: true },
|
||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||
};
|
||||
|
|
|
@ -94,6 +94,7 @@ const submit = async (rows) => {
|
|||
icon="add_circle"
|
||||
v-shortcut="'+'"
|
||||
flat
|
||||
data-cy="addBarcode_input"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Add barcode') }}
|
||||
|
|
|
@ -226,7 +226,6 @@ const onDenyAccept = (_, responseData) => {
|
|||
order="shipped ASC, isOk ASC"
|
||||
:columns="columns"
|
||||
:user-params="userParams"
|
||||
:is-editable="true"
|
||||
:right-search="false"
|
||||
auto-load
|
||||
:disable-option="{ card: true }"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
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 { toDateTimeFormat } from 'src/filters/date';
|
||||
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 VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import { getAddresses } from '../Customer/composables/getAddresses';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
|
@ -24,6 +25,11 @@ const agencyList = ref([]);
|
|||
const route = useRoute();
|
||||
const addressOptions = ref([]);
|
||||
const dataKey = 'OrderList';
|
||||
const formInitialData = ref({
|
||||
active: true,
|
||||
addressId: null,
|
||||
clientFk: null,
|
||||
});
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -147,32 +153,41 @@ const columns = computed(() => [
|
|||
],
|
||||
},
|
||||
]);
|
||||
onMounted(() => {
|
||||
if (!route.query.createForm) return;
|
||||
const clientId = route.query.createForm;
|
||||
const id = JSON.parse(clientId);
|
||||
fetchClientAddress(id.clientFk);
|
||||
onMounted(async () => {
|
||||
if (!route.query) return;
|
||||
if (route.query?.createForm) {
|
||||
const query = JSON.parse(route.query?.createForm);
|
||||
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 = {}) {
|
||||
const { data } = await axios.get(`Clients/${id}/addresses`, {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
include: [
|
||||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['defaultAddressFk'],
|
||||
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;
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
order: ['isActive DESC'],
|
||||
}),
|
||||
},
|
||||
});
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
async function onClientSelected({ clientId: id }, formData = {}) {
|
||||
const { data } = await getAddresses(id);
|
||||
addressOptions.value = data;
|
||||
formData.addressId = data[0].client.defaultAddressFk;
|
||||
fetchAgencies(formData);
|
||||
formData.defaultAddressFk = data[0].client.defaultAddressFk;
|
||||
formData.addressId = formData.defaultAddressFk;
|
||||
|
||||
formInitialData.value = { addressId: formData.addressId, clientFk: id };
|
||||
await fetchAgencies(formData);
|
||||
}
|
||||
|
||||
async function fetchAgencies({ landed, addressId }) {
|
||||
|
@ -181,7 +196,7 @@ async function fetchAgencies({ landed, addressId }) {
|
|||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
order: ['agencyMode DESC', 'agencyModeFk ASC'],
|
||||
order: ['name ASC', 'agencyMode DESC', 'agencyModeFk ASC'],
|
||||
}),
|
||||
addressFk: addressId,
|
||||
landed,
|
||||
|
@ -224,11 +239,7 @@ const getDateColor = (date) => {
|
|||
onDataSaved: (url) => {
|
||||
tableRef.redirect(`${url}/catalog`);
|
||||
},
|
||||
formInitialData: {
|
||||
active: true,
|
||||
addressId: null,
|
||||
clientFk: null,
|
||||
},
|
||||
formInitialData,
|
||||
}"
|
||||
:user-params="{ showEmpty: false }"
|
||||
:columns="columns"
|
||||
|
@ -260,7 +271,7 @@ const getDateColor = (date) => {
|
|||
:include="{ relation: 'addresses' }"
|
||||
v-model="data.clientFk"
|
||||
:label="t('module.customer')"
|
||||
@update:model-value="(id) => fetchClientAddress(id, data)"
|
||||
@update:model-value="(id) => onClientSelected(id, data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
@ -285,7 +296,22 @@ const getDateColor = (date) => {
|
|||
@update:model-value="() => fetchAgencies(data)"
|
||||
>
|
||||
<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>
|
||||
<QItemLabel
|
||||
:class="{
|
||||
|
@ -313,6 +339,7 @@ const getDateColor = (date) => {
|
|||
<VnInputDate
|
||||
v-model="data.landed"
|
||||
:label="t('module.landed')"
|
||||
data-cy="landedDate"
|
||||
@update:model-value="() => fetchAgencies(data)"
|
||||
/>
|
||||
<VnSelect
|
||||
|
|
|
@ -751,7 +751,7 @@ watch(
|
|||
{{ row?.item?.subName.toUpperCase() }}
|
||||
</div>
|
||||
</div>
|
||||
<FetchedTags :item="row" :max-length="6" />
|
||||
<FetchedTags :item="row.item" :max-length="6" />
|
||||
<QPopupProxy v-if="row.id && isTicketEditable">
|
||||
<VnInput
|
||||
v-model="row.concept"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
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 { useStateStore } from 'stores/useStateStore';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
@ -51,10 +51,21 @@ const userParams = {
|
|||
onBeforeMount(() => {
|
||||
initializeFromQuery();
|
||||
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 = () => {
|
||||
if (!route) return;
|
||||
const query = route.query.table ? JSON.parse(route.query.table) : {};
|
||||
from.value = query.from || from.toISOString();
|
||||
to.value = query.to || to.toISOString();
|
||||
|
@ -69,7 +80,6 @@ const companiesOptions = ref([]);
|
|||
const accountingOptions = ref([]);
|
||||
const amountToReturn = ref();
|
||||
const dataKey = 'TicketList';
|
||||
const filterPanelRef = ref(null);
|
||||
const formInitialData = ref({});
|
||||
|
||||
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) {
|
||||
agenciesOptions.value = [];
|
||||
if (formData) formData.agencyModeId = null;
|
||||
|
@ -262,12 +297,6 @@ function redirectToLines(id) {
|
|||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
const onClientSelected = async (formData) => {
|
||||
resetAgenciesSelector(formData);
|
||||
await fetchClient(formData);
|
||||
await fetchAddresses(formData);
|
||||
};
|
||||
|
||||
const fetchAvailableAgencies = async (formData) => {
|
||||
resetAgenciesSelector(formData);
|
||||
const response = await getAgencies(formData, selectedClient.value);
|
||||
|
@ -278,22 +307,6 @@ const fetchAvailableAgencies = async (formData) => {
|
|||
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) => {
|
||||
if (row.alertLevelCode === 'OK') return 'bg-success';
|
||||
else if (row.alertLevelCode === 'FREE') return 'bg-notice';
|
||||
|
@ -445,22 +458,6 @@ function setReference(data) {
|
|||
|
||||
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>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -3,23 +3,22 @@ describe('ItemBarcodes', () => {
|
|||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080);
|
||||
cy.login('developer');
|
||||
cy.visit(`/#/item/list`);
|
||||
cy.typeSearchbar('1{enter}');
|
||||
cy.visit(`/#/item/1/barcode`);
|
||||
});
|
||||
|
||||
it('should throw an error if the barcode exists', () => {
|
||||
cy.get('[href="#/item/1/barcode"]').click();
|
||||
cy.get('.q-card > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.dataCy('Code_input').eq(3).type('1111111111');
|
||||
cy.dataCy('crudModelDefaultSaveBtn').click();
|
||||
newBarcode('1111111111');
|
||||
cy.checkNotification('Codes can not be repeated');
|
||||
});
|
||||
|
||||
it('should create a new barcode', () => {
|
||||
cy.get('[href="#/item/1/barcode"]').click();
|
||||
cy.get('.q-card > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.dataCy('Code_input').eq(3).type('1231231231');
|
||||
cy.dataCy('crudModelDefaultSaveBtn').click();
|
||||
newBarcode('1231231231');
|
||||
cy.checkNotification('Data saved');
|
||||
});
|
||||
|
||||
function newBarcode(text) {
|
||||
cy.dataCy('addBarcode_input').click();
|
||||
cy.dataCy('Code_input').eq(3).should('exist').type(text);
|
||||
cy.dataCy('crudModelDefaultSaveBtn').click();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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" />
|
||||
describe('TicketList', () => {
|
||||
describe.only('TicketList', () => {
|
||||
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -68,7 +68,7 @@ describe('TicketList', () => {
|
|||
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) => {
|
||||
req.headers['cache-control'] = 'no-cache';
|
||||
req.headers['pragma'] = 'no-cache';
|
||||
|
|
|
@ -182,14 +182,17 @@ describe('TicketSale', () => {
|
|||
it('change quantity ', () => {
|
||||
const quantity = Math.floor(Math.random() * 100) + 1;
|
||||
cy.waitForElement(firstRow);
|
||||
cy.dataCy('ticketSaleQuantityInput').clear();
|
||||
cy.dataCy('ticketSaleQuantityInput').type(quantity).trigger('tab');
|
||||
cy.dataCy('ticketSaleQuantityInput').find('input').clear();
|
||||
cy.dataCy('ticketSaleQuantityInput')
|
||||
.find('input')
|
||||
.type(quantity)
|
||||
.trigger('tab');
|
||||
cy.get('.q-page > :nth-child(6)').click();
|
||||
|
||||
handleVnConfirm();
|
||||
|
||||
cy.get('[data-cy="ticketSaleQuantityInput"]')
|
||||
.find('[data-cy="undefined_input"]')
|
||||
.find('input')
|
||||
.should('have.value', `${quantity}`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue