From 40f7ccf42b6d6e9ba505c20dec199c8dff5d52cc Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 2 Oct 2024 14:58:02 +0200 Subject: [PATCH 001/173] 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/173] 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/173] 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/173] 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 b82453582a9e25f25d65ffe27ee1ae3a2af62de1 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 17 Oct 2024 07:44:31 +0200 Subject: [PATCH 005/173] fix: refs #7304 7304 clean warning --- src/components/ui/VnAvatar.vue | 2 +- src/pages/Customer/Card/CustomerBasicData.vue | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ui/VnAvatar.vue b/src/components/ui/VnAvatar.vue index 1deb105db..2423f8ba7 100644 --- a/src/components/ui/VnAvatar.vue +++ b/src/components/ui/VnAvatar.vue @@ -6,7 +6,7 @@ import { useColor } from 'src/composables/useColor'; import { getCssVar } from 'quasar'; const $props = defineProps({ - workerId: { type: Number, required: true }, + workerId: { type: Number, default: null }, description: { type: String, default: null }, title: { type: String, default: null }, color: { type: String, default: null }, diff --git a/src/pages/Customer/Card/CustomerBasicData.vue b/src/pages/Customer/Card/CustomerBasicData.vue index d31669b43..3743a4b76 100644 --- a/src/pages/Customer/Card/CustomerBasicData.vue +++ b/src/pages/Customer/Card/CustomerBasicData.vue @@ -155,7 +155,6 @@ const exprBuilder = (param, value) => { url="Clients" :input-debounce="0" :label="t('customer.basicData.previousClient')" - :options="clients" :rules="validate('client.transferorFk')" emit-value map-options From 1bafdf1b858ff097859770e4db8347ad2e10ee41 Mon Sep 17 00:00:00 2001 From: carlossa Date: Sun, 20 Oct 2024 15:01:37 +0200 Subject: [PATCH 006/173] fix: refs #6389 ipt --- src/pages/Monitor/Ticket/MonitorTicketFilter.vue | 4 +++- src/pages/Monitor/Ticket/MonitorTickets.vue | 6 ++++++ src/pages/Monitor/locale/en.yml | 1 + src/pages/Monitor/locale/es.yml | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue index 57248d580..7a5d296a5 100644 --- a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue +++ b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue @@ -43,6 +43,7 @@ const getLocale = (label) => { (groupedStates = data.map((x) => Object.assign(x, { code: t(x.code) }))) " /> + { /> + [ }, }, }, + { + label: t('salesTicketsTable.payMethod'), + name: 'payMethod', + align: 'left', + columnFilter: false, + }, { label: t('salesTicketsTable.total'), name: 'totalWithVat', diff --git a/src/pages/Monitor/locale/en.yml b/src/pages/Monitor/locale/en.yml index b8082f02a..9a7317469 100644 --- a/src/pages/Monitor/locale/en.yml +++ b/src/pages/Monitor/locale/en.yml @@ -42,6 +42,7 @@ salesTicketsTable: preview: Preview total: Total preparation: Preparation + payMethod: Pay method searchBar: label: Search tickets info: Search tickets by id or alias diff --git a/src/pages/Monitor/locale/es.yml b/src/pages/Monitor/locale/es.yml index 4ee5b90a9..60760b70d 100644 --- a/src/pages/Monitor/locale/es.yml +++ b/src/pages/Monitor/locale/es.yml @@ -42,6 +42,7 @@ salesTicketsTable: preview: Vista previa total: Total preparation: Preparación + payMethod: Método de pago searchBar: label: Buscar tickets info: Buscar tickets por identificador o alias From daf57c9b2bfb4d8001a520cd0bec7be23efacef5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 23 Oct 2024 12:20:53 +0200 Subject: [PATCH 007/173] fix: refs #6389 front filters --- .../Monitor/Ticket/MonitorTicketFilter.vue | 13 +++++++++++- src/pages/Monitor/Ticket/MonitorTickets.vue | 21 +++++++++++++++++++ src/pages/Monitor/locale/en.yml | 1 + src/pages/Monitor/locale/es.yml | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue index 7a5d296a5..ae5dc7a56 100644 --- a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue +++ b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue @@ -43,7 +43,6 @@ const getLocale = (label) => { (groupedStates = data.map((x) => Object.assign(x, { code: t(x.code) }))) " /> - { /> + + + + + [ }, }, }, + { + label: t('salesTicketsTable.department'), + name: 'department', + align: 'left', + component: 'select', + attrs: { + url: 'Departments', + optionValue: 'name', + optionLabel: 'name', + }, + columnFilter: { + component: 'select', + url: 'Departments', + attrs: { + optionValue: 'name', + optionLabel: 'name', + dense: true, + }, + }, + }, { align: 'right', name: 'tableActions', diff --git a/src/pages/Monitor/locale/en.yml b/src/pages/Monitor/locale/en.yml index 9a7317469..083c24e4e 100644 --- a/src/pages/Monitor/locale/en.yml +++ b/src/pages/Monitor/locale/en.yml @@ -43,6 +43,7 @@ salesTicketsTable: total: Total preparation: Preparation payMethod: Pay method + department: Department searchBar: label: Search tickets info: Search tickets by id or alias diff --git a/src/pages/Monitor/locale/es.yml b/src/pages/Monitor/locale/es.yml index 60760b70d..a3037d75b 100644 --- a/src/pages/Monitor/locale/es.yml +++ b/src/pages/Monitor/locale/es.yml @@ -43,6 +43,7 @@ salesTicketsTable: total: Total preparation: Preparación payMethod: Método de pago + department: Departamento searchBar: label: Buscar tickets info: Buscar tickets por identificador o alias From e8fd3c0a8f2bcb057c41396e211f099be62b7537 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 23 Oct 2024 14:58:03 +0200 Subject: [PATCH 008/173] fix: refs #6389 fix front, filters, itp --- src/i18n/locale/en.yml | 1 + src/i18n/locale/es.yml | 1 + .../Monitor/Ticket/MonitorTicketFilter.vue | 12 +++++ src/pages/Monitor/Ticket/MonitorTickets.vue | 48 ++++++++++++++++--- src/pages/Monitor/locale/en.yml | 1 + src/pages/Monitor/locale/es.yml | 1 + 6 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index fa0a14f45..8fd495e68 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -308,6 +308,7 @@ globals: email: Email SSN: SSN fi: FI + packing: ITP changePass: Change password deleteConfirmTitle: Delete selected elements errors: diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 5dfe90e98..f777089a6 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -312,6 +312,7 @@ globals: email: Correo SSN: NSS fi: NIF + packing: ITP changePass: Cambiar contraseña deleteConfirmTitle: Eliminar los elementos seleccionados errors: diff --git a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue index ae5dc7a56..f952850d2 100644 --- a/src/pages/Monitor/Ticket/MonitorTicketFilter.vue +++ b/src/pages/Monitor/Ticket/MonitorTicketFilter.vue @@ -222,6 +222,18 @@ const getLocale = (label) => { /> + + + + + [ align: 'left', format: (row) => row.practicalHour, columnFilter: false, + dense: true, }, { label: t('salesTicketsTable.preparation'), @@ -227,22 +233,32 @@ const columns = computed(() => [ label: t('salesTicketsTable.department'), name: 'department', align: 'left', - component: 'select', - attrs: { - url: 'Departments', - optionValue: 'name', - optionLabel: 'name', - }, columnFilter: { component: 'select', url: 'Departments', attrs: { + options: DepartmentOpts.value, optionValue: 'name', optionLabel: 'name', dense: true, }, }, }, + { + label: t('salesTicketsTable.packing'), + name: 'packing', + align: 'left', + columnFilter: { + component: 'select', + url: 'ItemPackingTypes', + attrs: { + options: ItemPackingTypeOpts.value, + 'option-value': 'code', + 'option-label': 'code', + dense: true, + }, + }, + }, { align: 'right', name: 'tableActions', @@ -349,6 +365,24 @@ const openTab = (id) => auto-load @on-fetch="(data) => (zoneOpts = data)" /> + + - Date: Mon, 11 Nov 2024 09:56:03 +0100 Subject: [PATCH 014/173] revert: #7679 improve changes --- src/pages/Item/ItemFixedPrice.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index d46bd5c3e..3e4b1513f 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -220,9 +220,6 @@ const updateMinPrice = async (value, props) => { }; const validations = ({ row }) => { - const isNew = !row.id; - if (!isNew) return false; - const requiredFields = [ 'itemFk', 'started', @@ -247,6 +244,7 @@ const upsertPrice = async (props, resetMinPrice = false) => { if (changes?.updates?.length > 0) { if (resetMinPrice) row.hasMinPrice = 0; } + if (!changes.updates && !changes.creates) return; const data = await upsertFixedPrice(row); tableRef.value.CrudModelRef.formData[props.rowIndex] = data; } catch (err) { @@ -429,6 +427,10 @@ function handleOnDataSave({ CrudModelRef }) { auto-load :is-editable="true" :right-search="false" + :table="{ + 'row-key': 'id', + selection: 'multiple', + }" :crud-model="{ paginate: false, }" From 9b681d806bb2021b54cbb28f14813113b21e6844 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 13 Nov 2024 10:13:00 +0100 Subject: [PATCH 015/173] perf: qFormMixin improvement --- src/boot/qformMixin.js | 45 ++++++++++++++++++++++--- src/components/CreateBankEntityForm.vue | 1 - 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/boot/qformMixin.js b/src/boot/qformMixin.js index 8fa5f5200..d859f77d9 100644 --- a/src/boot/qformMixin.js +++ b/src/boot/qformMixin.js @@ -1,11 +1,48 @@ -import { getCurrentInstance } from 'vue'; - +function focusFirstInput(input) { + input.focus(); + return; +} export default { mounted: function () { - console.error('qformMixin mounted'); const that = this; const form = document.querySelector('.q-form#formModel'); if (!form) return; + try { + // Login + const inputsFormCard = document.querySelectorAll( + '.q-form#formModel input:not([disabled]):not([type="checkbox"])' + ); + if (inputsFormCard.length) { + // .focus(); + // observerInstance.disconnect(); + // return; + focusFirstInput(inputsFormCard[0]); + } + // VnNotes + const textareas = document.querySelectorAll( + 'textarea:not([disabled]), [contenteditable]:not([disabled])' + ); + if (textareas.length) { + // textareas[textareas.length - 1].focus(); + // observerInstance.disconnect(); + // return; + focusFirstInput(textareas[textareas.length - 1]); + } + // if (!inputs || inputs.length === 0) return; + const inputs = document.querySelectorAll( + 'form#formModel input:not([disabled]):not([type="checkbox"])' + ); + const input = inputs[0]; + if (!input) return; + // if (input.type === 'textarea' || input.form) { + // AUTOFOCUS + + focusFirstInput(input); + // input.focus(); + // observerInstance.disconnect(); + } catch (error) { + console.error(error); + } form.addEventListener('keyup', function (evt) { if (evt.key === 'Enter') { const input = evt.target; @@ -23,5 +60,5 @@ export default { that.onSubmit(); } }); - }, + }, // mounted }; diff --git a/src/components/CreateBankEntityForm.vue b/src/components/CreateBankEntityForm.vue index a42be6ef8..17dee33a0 100644 --- a/src/components/CreateBankEntityForm.vue +++ b/src/components/CreateBankEntityForm.vue @@ -44,7 +44,6 @@ onMounted(async () => { -