From 40f7ccf42b6d6e9ba505c20dec199c8dff5d52cc Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 2 Oct 2024 14:58:02 +0200 Subject: [PATCH 001/492] perf: refs #7404 #7679 improve create --- src/components/CrudModel.vue | 2 +- src/pages/Item/ItemFixedPrice.vue | 123 ++++++++++++++++++++---------- 2 files changed, 84 insertions(+), 41 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 0386e037b..3b95f0b35 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -246,7 +246,7 @@ function getChanges() { for (const [i, row] of formData.value.entries()) { if (!row[pk]) { creates.push(row); - } else if (originalData.value) { + } else if (originalData.value[i]) { const data = getDifferences(originalData.value[i], row); if (!isEmpty(data)) { updates.push({ diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index fddf154a2..2a7c3a522 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -150,6 +150,14 @@ const columns = computed(() => [ icon: 'delete', action: (row) => confirmRemove(row), isPrimary: true, + // show: (row) => !validations({ row }), + // }, + // { + // title: t('save'), + // icon: 'save', + // action: (row) => upsertFixedPrice(row), + // isPrimary: true, + // show: (row) => validations({ row }), }, ], }, @@ -221,13 +229,41 @@ const updateMinPrice = async (value, props) => { }); }; +const validations = ({ row, rowIndex, col }) => { + const isNew = !row.id; + // Si la row no tiene id significa que fue agregada con addRow y no se ha guardado en la base de datos + // Si isNew es falso no se checkea si el valor es igual a la original + if (!isNew) + // if (fixedPricesOriginalData.value[rowIndex][col.field] == row[col.field]) + return false; + + const requiredFields = [ + 'itemFk', + 'started', + 'ended', + 'rate2', + 'rate3', + 'warehouseFk', + ]; + const isValid = requiredFields.every( + (field) => row[field] !== null && row[field] !== undefined + ); + return isValid; +}; const upsertPrice = async (props, resetMinPrice = false) => { try { - const { row } = props; - if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) { - if (resetMinPrice) row.hasMinPrice = 0; - await upsertFixedPrice(row); + const isValid = validations({ ...props }); + if (!isValid) { + // notify(t('globals.fillRequiredFields'), 'negative'); + return; } + const { row } = props; + const changes = tableRef.value.CrudModelRef.getChanges(); + if (changes?.updates?.length > 0) { + if (resetMinPrice) row.hasMinPrice = 0; + } + const data = await upsertFixedPrice(row); + tableRef.value.CrudModelRef.formData[props.rowIndex] = data; } catch (err) { console.error('Error editing price', err); } @@ -264,39 +300,39 @@ function checkLastVisibleRow() { const addRow = (original = null) => { let copy = null; - if (!original) { - const today = Date.vnNew(); - const millisecsInDay = 86400000; - const daysInWeek = 7; - const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay); + // if (!original) { + const today = Date.vnNew(); + const millisecsInDay = 86400000; + const daysInWeek = 7; + const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay); - copy = { - id: 0, - started: today, - ended: nextWeek, - hasMinPrice: 0, - $index: 0, - }; - } else - copy = { - $index: original.$index - 1, - itemFk: original.itemFk, - name: original.name, - subName: original.subName, - value5: original.value5, - value6: original.value6, - value7: original.value7, - value8: original.value8, - value9: original.value9, - value10: original.value10, - warehouseFk: original.warehouseFk, - rate2: original.rate2, - rate3: original.rate3, - hasMinPrice: original.hasMinPrice, - minPrice: original.minPrice, - started: Date.vnNew(), - ended: Date.vnNew(), - }; + copy = { + id: 0, + started: today, + ended: nextWeek, + hasMinPrice: 0, + $index: 0, + }; + // } else + // copy = { + // $index: original.$index - 1, + // itemFk: original.itemFk, + // name: original.name, + // subName: original.subName, + // value5: original.value5, + // value6: original.value6, + // value7: original.value7, + // value8: original.value8, + // value9: original.value9, + // value10: original.value10, + // warehouseFk: original.warehouseFk, + // rate2: original.rate2, + // rate3: original.rate3, + // hasMinPrice: original.hasMinPrice, + // minPrice: original.minPrice, + // started: Date.vnNew(), + // ended: Date.vnNew(), + // }; return { original, copy }; }; @@ -436,10 +472,6 @@ function handleOnDataSave({ CrudModelRef }) { auto-load :is-editable="true" :right-search="false" - :table="{ - 'row-key': 'id', - selection: 'multiple', - }" :crud-model="{ paginate: false, }" @@ -585,7 +617,18 @@ function handleOnDataSave({ CrudModelRef }) { + Date: Wed, 2 Oct 2024 22:49:26 +0200 Subject: [PATCH 002/492] test: #7679 ItemFixedPrice --- src/pages/Item/ItemFixedPrice.vue | 1 - .../integration/item/ItemFixedPrice.spec.js | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/cypress/integration/item/ItemFixedPrice.spec.js diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index 2a7c3a522..97532bf40 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -476,7 +476,6 @@ function handleOnDataSave({ CrudModelRef }) { paginate: false, }" v-model:selected="rowsSelected" - :row-click="saveOnRowChange" :create-as-dialog="false" :create="{ onDataSaved: handleOnDataSave, diff --git a/test/cypress/integration/item/ItemFixedPrice.spec.js b/test/cypress/integration/item/ItemFixedPrice.spec.js new file mode 100644 index 000000000..343ef13f6 --- /dev/null +++ b/test/cypress/integration/item/ItemFixedPrice.spec.js @@ -0,0 +1,35 @@ +/* ==== Test Created with Cypress Studio ==== */ +describe('Worker Create', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('/#/item/fixed-price', { timeout: 5000 }); + cy.waitForElement('.q-table'); + }); + it('start', function () { + cy.get( + '.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon' + ).click(); + cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click(); + cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); + cy.selectOption( + '.q-virtual-scroll__content > :nth-child(2) > :nth-child(1)', + '#15' + ); + cy.get('.q-virtual-scroll__content > :nth-child(2) > :nth-child(3)').type('1'); + cy.get('.q-virtual-scroll__content > :nth-child(2) > :nth-child(4)').type('2'); + cy.selectOption( + '.q-virtual-scroll__content > :nth-child(2) > :nth-child(8)', + 'Warehouse One' + ); + cy.get('.q-notification__message').should('have.text', 'Data saved'); + + cy.get( + '.q-virtual-scroll__content > :nth-child(2) > .text-right > .q-btn > .q-btn__content > .q-icon' + ).click(); + cy.get( + '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block' + ).click(); + cy.get('.q-notification__message').should('have.text', 'Data saved'); + }); +}); From 477404f00a6a1f7bc6b0847a93dc74a29fe02db5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 2 Oct 2024 22:50:57 +0200 Subject: [PATCH 003/492] test: #7679 ItemFixedPrice --- test/cypress/integration/item/ItemFixedPrice.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cypress/integration/item/ItemFixedPrice.spec.js b/test/cypress/integration/item/ItemFixedPrice.spec.js index 343ef13f6..21e141a6a 100644 --- a/test/cypress/integration/item/ItemFixedPrice.spec.js +++ b/test/cypress/integration/item/ItemFixedPrice.spec.js @@ -1,12 +1,12 @@ -/* ==== Test Created with Cypress Studio ==== */ -describe('Worker Create', () => { +/// +describe('Handle Items FixedPrice', () => { beforeEach(() => { cy.viewport(1280, 720); cy.login('developer'); cy.visit('/#/item/fixed-price', { timeout: 5000 }); cy.waitForElement('.q-table'); }); - it('start', function () { + it('Create and delete', function () { cy.get( '.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon' ).click(); From dc13096bc19e1cf8d269a0734bc89b9d2dd20991 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 9 Oct 2024 00:50:53 +0200 Subject: [PATCH 004/492] perf: remove comments --- src/pages/Item/ItemFixedPrice.vue | 49 ++----------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index 97532bf40..0390df2a9 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -150,14 +150,6 @@ const columns = computed(() => [ icon: 'delete', action: (row) => confirmRemove(row), isPrimary: true, - // show: (row) => !validations({ row }), - // }, - // { - // title: t('save'), - // icon: 'save', - // action: (row) => upsertFixedPrice(row), - // isPrimary: true, - // show: (row) => validations({ row }), }, ], }, @@ -219,8 +211,6 @@ const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => { }; const updateMinPrice = async (value, props) => { - // El checkbox hasMinPrice se encuentra en la misma columna que el input hasMinPrice - // Por lo tanto le mandamos otro objeto con las mismas propiedades pero con el campo 'field' cambiado props.row.hasMinPrice = value; await upsertPrice({ row: props.row, @@ -229,13 +219,9 @@ const updateMinPrice = async (value, props) => { }); }; -const validations = ({ row, rowIndex, col }) => { +const validations = ({ row }) => { const isNew = !row.id; - // Si la row no tiene id significa que fue agregada con addRow y no se ha guardado en la base de datos - // Si isNew es falso no se checkea si el valor es igual a la original - if (!isNew) - // if (fixedPricesOriginalData.value[rowIndex][col.field] == row[col.field]) - return false; + if (!isNew) return false; const requiredFields = [ 'itemFk', @@ -254,7 +240,6 @@ const upsertPrice = async (props, resetMinPrice = false) => { try { const isValid = validations({ ...props }); if (!isValid) { - // notify(t('globals.fillRequiredFields'), 'negative'); return; } const { row } = props; @@ -278,13 +263,6 @@ async function upsertFixedPrice(row) { } } -async function saveOnRowChange(row) { - if (rowsSelected.value.length > 1) return; - if (rowsSelected.value[0]?.id === row.id) return; - else if (rowsSelected.value.length === 1) await upsertPrice(rowsSelected.value[0]); - rowsSelected.value = [row]; -} - function checkLastVisibleRow() { let lastVisibleRow = null; @@ -300,7 +278,6 @@ function checkLastVisibleRow() { const addRow = (original = null) => { let copy = null; - // if (!original) { const today = Date.vnNew(); const millisecsInDay = 86400000; const daysInWeek = 7; @@ -313,26 +290,6 @@ const addRow = (original = null) => { hasMinPrice: 0, $index: 0, }; - // } else - // copy = { - // $index: original.$index - 1, - // itemFk: original.itemFk, - // name: original.name, - // subName: original.subName, - // value5: original.value5, - // value6: original.value6, - // value7: original.value7, - // value8: original.value8, - // value9: original.value9, - // value10: original.value10, - // warehouseFk: original.warehouseFk, - // rate2: original.rate2, - // rate3: original.rate3, - // hasMinPrice: original.hasMinPrice, - // minPrice: original.minPrice, - // started: Date.vnNew(), - // ended: Date.vnNew(), - // }; return { original, copy }; }; @@ -345,7 +302,7 @@ function highlightNewRow({ $index: index }) { row.classList.add('highlight'); setTimeout(() => { row.classList.remove('highlight'); - }, 3000); // Duración de la animación en milisegundos + }, 3000); } } const openEditTableCellDialog = () => { From 321b8dd9f911c2a15c4753f47ebdb7154bb7ee6d Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 11 Oct 2024 11:01:58 +0200 Subject: [PATCH 005/492] fix: refs #8004 some style issues on all list --- src/components/NavBar.vue | 21 +---------------- src/components/VnTable/VnTable.vue | 19 ++-------------- src/components/common/RightMenu.vue | 16 +++++++++++-- src/components/common/VnInputDate.vue | 19 ++-------------- src/components/common/VnInputTime.vue | 8 +------ src/composables/isMobile.js | 3 +++ src/css/app.scss | 8 ++++++- src/i18n/locale/en.yml | 2 +- src/i18n/locale/es.yml | 2 +- src/pages/Claim/ClaimList.vue | 2 +- src/pages/Customer/CustomerList.vue | 1 - src/pages/Entry/EntryList.vue | 4 ---- src/pages/InvoiceIn/InvoiceInList.vue | 16 +++++++------ src/pages/InvoiceOut/InvoiceOutList.vue | 7 +----- src/pages/Item/ItemList.vue | 2 +- src/pages/Route/RouteExtendedList.vue | 24 -------------------- src/pages/Route/RouteList.vue | 2 +- src/pages/Shelving/ShelvingList.vue | 6 ----- src/pages/Supplier/Card/SupplierAccounts.vue | 1 + src/pages/Supplier/SupplierList.vue | 9 ++++++-- src/pages/Ticket/TicketList.vue | 5 +++- src/pages/Travel/Card/TravelCard.vue | 1 + src/pages/Travel/TravelFilter.vue | 2 +- src/pages/Travel/TravelList.vue | 19 +++++----------- src/pages/Wagon/WagonList.vue | 1 - src/pages/Worker/WorkerList.vue | 1 + src/pages/Zone/ZoneList.vue | 7 +----- src/router/modules/shelving.js | 2 +- src/router/modules/wagon.js | 2 +- src/router/modules/zone.js | 2 +- 30 files changed, 70 insertions(+), 144 deletions(-) create mode 100644 src/composables/isMobile.js diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index 00faaebc2..5497862c7 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -15,12 +15,10 @@ const quasar = useQuasar(); const state = useState(); const user = state.getUser(); const appName = 'Lilium'; +const pinnedModulesRef = ref(); onMounted(() => stateStore.setMounted()); - -const pinnedModulesRef = ref(); - - - -en: - Go to Salix: Go to Salix -es: - Go to Salix: Ir a Salix - diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 5a30f4d53..7d45fcfec 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -453,7 +453,7 @@ function handleOnDataSaved(_) { - es: Open date: Abrir fecha diff --git a/src/components/common/VnInputTime.vue b/src/components/common/VnInputTime.vue index a5e7d3002..d8150fd58 100644 --- a/src/components/common/VnInputTime.vue +++ b/src/components/common/VnInputTime.vue @@ -79,7 +79,7 @@ function dateToTime(newDate) { :class="{ required: $attrs.required }" style="min-width: 100px" :rules="mixinRules" - @click="isPopupOpen = false" + @click="isPopupOpen = !isPopupOpen" type="time" hide-bottom-space > @@ -99,12 +99,6 @@ function dateToTime(newDate) { isPopupOpen = false; " /> - [ title: t('components.smartCard.viewSummary'), icon: 'preview', action: (row) => viewSummary(row.id, ClaimSummary), + isPrimary: true, }, ], }, @@ -134,7 +135,6 @@ const STATE_COLOR = { :columns="columns" redirect="claim" :right-search="false" - auto-load >