Merge pull request 'feat: refs #9026 enhance FormModelPopup with reset button and update VnTable grid layout' (!1831) from 9026_first_proposal into master
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1831
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Javier Segarra 2025-05-23 20:40:13 +00:00
commit cca2b664eb
4 changed files with 63 additions and 15 deletions

View File

@ -2,6 +2,7 @@
import { ref, computed, useAttrs, nextTick } from 'vue'; import { ref, computed, useAttrs, nextTick } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { tMobile } from 'src/composables/tMobile';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
@ -93,12 +94,25 @@ defineExpose({
z-max z-max
@click="emit('onDataCanceled')" @click="emit('onDataCanceled')"
/> />
<QBtn
:label="tMobile('globals.reset')"
:title="t('globals.reset')"
color="primary"
icon="restart_alt"
flat
:disabled="isLoading"
:loading="isLoading"
data-cy="FormModelPopup_reset"
@click="reset"
z-max
/>
<QBtn <QBtn
:flat="showSaveAndContinueBtn" :flat="showSaveAndContinueBtn"
:label="t('globals.save')" :label="tMobile('globals.save')"
:title="t('globals.save')" :title="t('globals.save')"
:type="!showSaveAndContinueBtn ? 'submit' : 'button'" :type="!showSaveAndContinueBtn ? 'submit' : 'button'"
color="primary" color="primary"
icon="save"
class="q-ml-sm" class="q-ml-sm"
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading" :loading="isLoading"

View File

@ -1091,6 +1091,8 @@ const handleHeaderSelection = (evt, data) => {
</QTooltip> </QTooltip>
</QPageSticky> </QPageSticky>
<QDialog <QDialog
:no-esc-dismiss="false"
:no-backdrop-dismiss="true"
v-model="showForm" v-model="showForm"
transition-show="scale" transition-show="scale"
transition-hide="scale" transition-hide="scale"
@ -1223,7 +1225,11 @@ es:
.grid-create { .grid-create {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, max-content)); grid-template-columns: repeat(auto-fit, minmax(220px, max-content));
@media (max-width: 600px) {
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
max-width: 100%; max-width: 100%;
grid-gap: 20px; grid-gap: 20px;
margin: 0 auto; margin: 0 auto;

View File

@ -1,6 +1,7 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
const firstRow = 'tr.cursor-pointer > :nth-child(1)'; const firstRow = 'tr.cursor-pointer > :nth-child(1)';
const ticketId = 1000000; const ticketId = 1000000;
const itemId = '88';
const clickNotificationAction = () => { const clickNotificationAction = () => {
const notification = '.q-notification'; const notification = '.q-notification';
cy.waitForElement(notification); cy.waitForElement(notification);
@ -18,7 +19,7 @@ describe.skip('Ticket Lack detail', { testIsolation: true }, () => {
cy.viewport(1980, 1020); cy.viewport(1980, 1020);
cy.login('developer'); cy.login('developer');
cy.intercept('GET', /\/api\/Tickets\/itemLack\/88.*$/).as('getItemLack'); cy.intercept('GET', /\/api\/Tickets\/itemLack\/88.*$/).as('getItemLack');
cy.visit('/#/ticket/negative/88'); cy.visit(`/#/ticket/negative/${itemId}`);
cy.window().then((win) => { cy.window().then((win) => {
cy.stub(win, 'open').as('open'); cy.stub(win, 'open').as('open');
}); });
@ -105,7 +106,7 @@ describe.skip('Ticket Lack detail', { testIsolation: true }, () => {
cy.dataCy('New item_select').should('be.visible'); cy.dataCy('New item_select').should('be.visible');
cy.selectOption('[data-cy="New item_select"]', 'Palito rojo'); cy.selectOption('[data-cy="New item_select"]', 'Palito rojo');
cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
cy.checkNotification('Ticket 1000000: price retrieval failed'); cy.checkNotification(`Ticket ${ticketId}: price retrieval failed`);
cy.dataCy('changeItem').click(); cy.dataCy('changeItem').click();
cy.selectOption('[data-cy="New item_select"]', 'Ranged weapon longbow 200cm'); cy.selectOption('[data-cy="New item_select"]', 'Ranged weapon longbow 200cm');
cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
@ -113,20 +114,22 @@ describe.skip('Ticket Lack detail', { testIsolation: true }, () => {
clickNotificationAction(); clickNotificationAction();
}); });
after(() => { after(() => {
cy.intercept('GET', /\/api\/Tickets\/\d+/).as('sale');
cy.visit(`/#/ticket/${ticketId}/sale`); cy.visit(`/#/ticket/${ticketId}/sale`);
cy.wait('@sale');
const quantity = Math.floor(Math.random() * 100) + 1; const quantity = Math.floor(Math.random() * 100) + 1;
const rowIndex = 1; cy.findRowIndexByColValue('itemFk', itemId, (rowIndex) => {
cy.dataCy('ticketSaleQuantityInput')
.find('input')
.eq(rowIndex)
.clear()
.type(`${quantity}{enter}`);
cy.dataCy('ticketSaleQuantityInput') cy.dataCy('ticketSaleQuantityInput')
.find('input') .find('input')
.eq(rowIndex) .eq(rowIndex)
.clear() .should('have.value', `${quantity}`);
.type(`${quantity}{enter}`); });
cy.dataCy('ticketSaleQuantityInput')
.find('input')
.eq(rowIndex)
.should('have.value', `${quantity}`);
}); });
}); });

View File

@ -48,6 +48,31 @@ Cypress.Commands.add('validateVnTableRows', (opts = {}) => {
}); });
}); });
}); });
Cypress.Commands.add('findRowIndexByColValue', (colField, value, cb) => {
return cy
.get('[data-cy="vnTable"] .q-virtual-scroll__content')
.children()
.then(($rows) => {
let foundIndex = -1;
Cypress._.some($rows, (row, index) => {
const cell = row.querySelector(`[data-col-field="${colField}"]`);
const text = cell?.textContent?.trim();
if (text === value) {
foundIndex = index;
return true;
}
});
if (foundIndex === -1) {
throw new Error(
`No se encontró ninguna fila con ${colField} = "${value}"`,
);
}
cb(foundIndex);
});
});
Cypress.Commands.add('colField', (name, index = null, key = 'data-col-field') => { Cypress.Commands.add('colField', (name, index = null, key = 'data-col-field') => {
if (index) { if (index) {