0
0
Fork 0

Merge remote-tracking branch 'origin/dev' into 6321_negative_tickets

This commit is contained in:
Javier Segarra 2024-04-23 11:45:00 +02:00
commit 46aefa67d1
14 changed files with 43 additions and 71 deletions

View File

@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2420.01]
## [2418.01] ## [2418.01]
## [2416.01] - 2024-04-18 ## [2416.01] - 2024-04-18

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-front", "name": "salix-front",
"version": "24.18.0", "version": "24.20.0",
"description": "Salix frontend", "description": "Salix frontend",
"productName": "Salix", "productName": "Salix",
"author": "Verdnatura", "author": "Verdnatura",

View File

@ -187,7 +187,7 @@ const columns = computed(() => [
downloadFile( downloadFile(
prop.row.id, prop.row.id,
$props.downloadModel, $props.downloadModel,
null, undefined,
prop.row.download prop.row.download
), ),
}, },

View File

@ -32,7 +32,7 @@ async function insert() {
<template> <template>
<QCard class="q-pa-xs q-mb-xl full-width" v-if="$props.addNote"> <QCard class="q-pa-xs q-mb-xl full-width" v-if="$props.addNote">
<QCardSection horizontal> <QCardSection horizontal>
<VnAvatar :descriptor="false" :worker-id="1" size="md" /> <VnAvatar :worker-id="currentUser.id" size="md" />
<div class="full-width row justify-between q-pa-xs"> <div class="full-width row justify-between q-pa-xs">
<VnUserLink :name="t('New note')" :worker-id="currentUser.id" /> <VnUserLink :name="t('New note')" :worker-id="currentUser.id" />
{{ t('globals.now') }} {{ t('globals.now') }}
@ -78,8 +78,8 @@ async function insert() {
<TransitionGroup name="list" tag="div" class="column items-center full-width"> <TransitionGroup name="list" tag="div" class="column items-center full-width">
<QCard <QCard
class="q-pa-xs q-mb-sm full-width" class="q-pa-xs q-mb-sm full-width"
v-for="note in rows" v-for="(note, index) in rows"
:key="note.id" :key="note.id ?? index"
> >
<QCardSection horizontal> <QCardSection horizontal>
<VnAvatar <VnAvatar

View File

@ -77,7 +77,6 @@ const arrayData = useArrayData(props.dataKey, {
userParams: props.userParams, userParams: props.userParams,
exprBuilder: props.exprBuilder, exprBuilder: props.exprBuilder,
}); });
const hasMoreData = ref();
const store = arrayData.store; const store = arrayData.store;
onMounted(() => { onMounted(() => {
@ -97,7 +96,7 @@ const addFilter = async (filter, params) => {
async function fetch() { async function fetch() {
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
if (!arrayData.hasMoreData.value) { if (!store.hasMoreData) {
isLoading.value = false; isLoading.value = false;
} }
emit('onFetch', store.data); emit('onFetch', store.data);
@ -110,8 +109,8 @@ async function paginate() {
isLoading.value = true; isLoading.value = true;
await arrayData.loadMore(); await arrayData.loadMore();
if (!arrayData.hasMoreData.value) { if (!store.hasMoreData) {
if (store.userParamsChanged) arrayData.hasMoreData.value = true; if (store.userParamsChanged) store.hasMoreData = true;
store.userParamsChanged = false; store.userParamsChanged = false;
endPagination(); endPagination();
return; return;
@ -132,9 +131,7 @@ function endPagination() {
emit('onPaginate'); emit('onPaginate');
} }
async function onLoad(index, done) { async function onLoad(index, done) {
if (!store.data) { if (!store.data) return done();
return done();
}
if (store.data.length === 0 || !props.url) return done(false); if (store.data.length === 0 || !props.url) return done(false);
@ -142,7 +139,7 @@ async function onLoad(index, done) {
await paginate(); await paginate();
let isDone = false; let isDone = false;
if (store.userParamsChanged) isDone = !arrayData.hasMoreData.value; if (store.userParamsChanged) isDone = !store.hasMoreData;
done(isDone); done(isDone);
} }
@ -182,13 +179,12 @@ defineExpose({ fetch, addFilter });
</QCard> </QCard>
</div> </div>
</div> </div>
<QInfiniteScroll <QInfiniteScroll
v-if="store.data" v-if="store.data"
@load="onLoad" @load="onLoad"
:offset="offset" :offset="offset"
:disable="disableInfiniteScroll || !arrayData.hasMoreData"
class="full-width" class="full-width"
:disable="disableInfiniteScroll || !store.hasMoreData"
v-bind="$attrs" v-bind="$attrs"
> >
<slot name="body" :rows="store.data"></slot> <slot name="body" :rows="store.data"></slot>
@ -196,7 +192,10 @@ defineExpose({ fetch, addFilter });
<QSpinner color="orange" size="md" /> <QSpinner color="orange" size="md" />
</div> </div>
</QInfiniteScroll> </QInfiniteScroll>
<div v-if="!isLoading && hasMoreData" class="w-full flex justify-center q-mt-md"> <div
v-if="!isLoading && store.hasMoreData"
class="w-full flex justify-center q-mt-md"
>
<QBtn color="primary" :label="t('Load more data')" @click="paginate()" /> <QBtn color="primary" :label="t('Load more data')" @click="paginate()" />
</div> </div>
</template> </template>

View File

@ -9,12 +9,9 @@ const arrayDataStore = useArrayDataStore();
export function useArrayData(key, userOptions) { export function useArrayData(key, userOptions) {
if (!key) throw new Error('ArrayData: A key is required to use this composable'); if (!key) throw new Error('ArrayData: A key is required to use this composable');
if (!arrayDataStore.get(key)) { if (!arrayDataStore.get(key)) arrayDataStore.set(key);
arrayDataStore.set(key);
}
const store = arrayDataStore.get(key); const store = arrayDataStore.get(key);
const hasMoreData = ref(false);
const route = useRoute(); const route = useRoute();
let canceller = null; let canceller = null;
@ -22,6 +19,7 @@ export function useArrayData(key, userOptions) {
onMounted(() => { onMounted(() => {
setOptions(); setOptions();
store.skip = 0;
const query = route.query; const query = route.query;
if (query.params) { if (query.params) {
@ -29,9 +27,7 @@ export function useArrayData(key, userOptions) {
} }
}); });
if (key && userOptions) { if (key && userOptions) setOptions();
setOptions();
}
function setOptions() { function setOptions() {
const allowedOptions = [ const allowedOptions = [
@ -96,8 +92,7 @@ export function useArrayData(key, userOptions) {
}); });
const { limit } = filter; const { limit } = filter;
hasMoreData.value = limit && response.data.length >= limit; store.hasMoreData = limit && response.data.length >= limit;
store.hasMoreData = hasMoreData.value;
if (append) { if (append) {
if (!store.data) store.data = []; if (!store.data) store.data = [];
@ -169,7 +164,7 @@ export function useArrayData(key, userOptions) {
} }
async function loadMore() { async function loadMore() {
if (!hasMoreData.value && !store.hasMoreData) return; if (!store.hasMoreData) return;
store.skip = store.limit * page.value; store.skip = store.limit * page.value;
page.value += 1; page.value += 1;
@ -211,7 +206,6 @@ export function useArrayData(key, userOptions) {
destroy, destroy,
loadMore, loadMore,
store, store,
hasMoreData,
totalRows, totalRows,
updateStateParams, updateStateParams,
isLoading, isLoading,

View File

@ -16,7 +16,7 @@ const claimId = computed(() => $props.id || route.params.id);
const claimFilter = { const claimFilter = {
where: { claimFk: claimId.value }, where: { claimFk: claimId.value },
fields: ['created', 'workerFk', 'text'], fields: ['id', 'created', 'workerFk', 'text'],
include: { include: {
relation: 'worker', relation: 'worker',
scope: { scope: {

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import { useRoute } from 'vue-router';
import { computed, onMounted } from 'vue'; import { computed, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
@ -33,20 +33,8 @@ const arrayData = useArrayData('SupplierConsumption', {
const store = arrayData.store; const store = arrayData.store;
const dateRanges = computed(() => { const dateRanges = computed(() => {
const ranges = { const { from, to } = arrayData.store?.userParams || {};
from: null, return { from, to };
to: null,
};
if (route.query && route.query.params) {
const params = JSON.parse(route.query.params);
if (params.from && params.to) {
ranges.from = params.from;
ranges.to = params.to;
}
}
return ranges;
}); });
const reportParams = computed(() => ({ const reportParams = computed(() => ({
@ -117,7 +105,7 @@ onMounted(async () => {
<template> <template>
<Teleport to="#st-actions" v-if="stateStore.isSubToolbarShown()"> <Teleport to="#st-actions" v-if="stateStore.isSubToolbarShown()">
<QBtn <QBtn
:disabled="!dateRanges.from && !dateRanges.to" :disabled="!dateRanges.from || !dateRanges.to || !rows.length"
color="primary" color="primary"
icon-right="picture_as_pdf" icon-right="picture_as_pdf"
no-caps no-caps
@ -129,7 +117,7 @@ onMounted(async () => {
</QTooltip> </QTooltip>
</QBtn> </QBtn>
<QBtn <QBtn
:disabled="!dateRanges.from && !dateRanges.to" :disabled="!dateRanges.from || !dateRanges.to || !rows.length"
color="primary" color="primary"
icon-right="email" icon-right="email"
no-caps no-caps
@ -140,7 +128,6 @@ onMounted(async () => {
</QTooltip> </QTooltip>
</QBtn> </QBtn>
</Teleport> </Teleport>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8"> <QScrollArea class="fit text-grey-8">

View File

@ -31,7 +31,7 @@ const entityId = computed(() => {
}); });
const worker = ref(); const worker = ref();
const filter = { where: { id: route.params.id}}; const filter = { where: { id: entityId } };
const sip = ref(null); const sip = ref(null);
@ -60,7 +60,7 @@ const setData = (entity) => {
<CardDescriptor <CardDescriptor
module="Worker" module="Worker"
data-key="workerData" data-key="workerData"
:url="`Workers/summary`" url="Workers/summary"
:filter="filter" :filter="filter"
:title="data.title" :title="data.title"
:subtitle="data.subtitle" :subtitle="data.subtitle"

View File

@ -1,5 +1,6 @@
const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item'; const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item';
describe('VnLocation', () => { describe('VnLocation', () => {
const dialogInputs = '.q-dialog label input';
describe('Create', () => { describe('Create', () => {
const inputLocation = const inputLocation =
'.q-form .q-card> :nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control'; '.q-form .q-card> :nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control';
@ -39,13 +40,9 @@ describe('VnLocation', () => {
cy.get( cy.get(
':nth-child(6) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon' ':nth-child(6) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon'
).click(); ).click();
cy.get(' .q-card > h1').should('have.text', 'New postcode'); cy.get('.q-card > h1').should('have.text', 'New postcode');
cy.get( cy.get(dialogInputs).eq(0).clear('12');
'.q-card > :nth-child(4) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(1) > input' cy.get(dialogInputs).eq(0).type('1234453');
).clear('12');
cy.get(
'.q-card > :nth-child(4) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(1) > input'
).type('1234453');
cy.selectOption( cy.selectOption(
'.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control ', '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control ',
'Valencia' 'Valencia'

View File

@ -21,7 +21,8 @@ describe('ClaimPhoto', () => {
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data saved');
}); });
it('should open first image dialog change to second and close', () => { /* it.skip('should open first image dialog change to second and close', () => {
skiped fix on https://redmine.verdnatura.es/issues/7113
cy.get( cy.get(
':nth-child(1) > .q-card > .q-img > .q-img__container > .q-img__image' ':nth-child(1) > .q-card > .q-img > .q-img__container > .q-img__image'
).click(); ).click();
@ -37,7 +38,7 @@ describe('ClaimPhoto', () => {
cy.get('.q-carousel__slide > .q-img > .q-img__container > .q-img__image').should( cy.get('.q-carousel__slide > .q-img > .q-img__container > .q-img__image').should(
'not.be.visible' 'not.be.visible'
); );
}); }); */
it('should remove third and fourth file', () => { it('should remove third and fourth file', () => {
cy.get( cy.get(

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('InvoiceInDueDay', () => { describe('InvoiceInDueDay', () => {
const inputs = 'label input'; const inputs = 'label input';
const inputBtns = 'label button';
const addBtn = '.q-page-sticky > div > .q-btn > .q-btn__content'; const addBtn = '.q-page-sticky > div > .q-btn > .q-btn__content';
beforeEach(() => { beforeEach(() => {
@ -10,7 +9,6 @@ describe('InvoiceInDueDay', () => {
}); });
it('should update the amount', () => { it('should update the amount', () => {
cy.get(inputBtns).eq(1).click();
cy.get(inputs).eq(3).type(23); cy.get(inputs).eq(3).type(23);
cy.saveCard(); cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data saved');

View File

@ -1,11 +1,11 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('InvoiceInVat', () => { describe('InvoiceInVat', () => {
const inputs = 'label input';
const inputBtns = 'label button';
const thirdRow = 'tbody > :nth-child(3)'; const thirdRow = 'tbody > :nth-child(3)';
const firstLineVat = 'tbody > :nth-child(1) > :nth-child(4)'; const firstLineVat = 'tbody > :nth-child(1) > :nth-child(4)';
const dialogInputs = '.q-dialog label input'; const dialogInputs = '.q-dialog label input';
const dialogBtns = '.q-dialog button'; const dialogBtns = '.q-dialog button';
const acrossInput =
':nth-child(1) > .q-td.q-table--col-auto-width > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .default-icon';
const randomInt = Math.floor(Math.random() * 100); const randomInt = Math.floor(Math.random() * 100);
beforeEach(() => { beforeEach(() => {
@ -13,11 +13,8 @@ describe('InvoiceInVat', () => {
cy.visit(`/#/invoice-in/1/vat`); cy.visit(`/#/invoice-in/1/vat`);
}); });
it('should edit the first line', () => { it('should edit the sage iva', () => {
cy.get(inputBtns).eq(1).click();
cy.get(inputs).eq(2).type(23);
cy.selectOption(firstLineVat, 'H.P. IVA 21% CEE'); cy.selectOption(firstLineVat, 'H.P. IVA 21% CEE');
cy.saveCard(); cy.saveCard();
cy.visit(`/#/invoice-in/1/vat`); cy.visit(`/#/invoice-in/1/vat`);
@ -36,16 +33,13 @@ describe('InvoiceInVat', () => {
}); });
it('should throw an error if there are fields undefined', () => { it('should throw an error if there are fields undefined', () => {
cy.get(inputBtns).eq(0).click(); cy.get(acrossInput).click();
cy.get(':nth-child(1) > .q-td.q-table--col-auto-width > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .default-icon').click();
cy.get(dialogBtns).eq(2).click(); cy.get(dialogBtns).eq(2).click();
cy.get('.q-notification__message').should('have.text', "The code can't be empty"); cy.get('.q-notification__message').should('have.text', "The code can't be empty");
}); });
it('should correctly handle expense addition', () => { it('should correctly handle expense addition', () => {
cy.get(inputBtns).eq(0).click(); cy.get(acrossInput).click();
cy.get(':nth-child(1) > .q-td.q-table--col-auto-width > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .default-icon').click();
cy.get(dialogInputs).eq(0).type(randomInt); cy.get(dialogInputs).eq(0).type(randomInt);
cy.get(dialogInputs).eq(1).click(); cy.get(dialogInputs).eq(1).click();
cy.get(dialogInputs).eq(1).type('This is a dummy expense'); cy.get(dialogInputs).eq(1).type('This is a dummy expense');

View File

@ -48,7 +48,7 @@ describe('VnPaginate', () => {
{ id: 3, name: 'Bruce Wayne' }, { id: 3, name: 'Bruce Wayne' },
], ],
}); });
vm.arrayData.hasMoreData.value = true; vm.store.hasMoreData = true;
await vm.$nextTick(); await vm.$nextTick();
vm.store.data = [ vm.store.data = [