refactor: refs #8684 improve input handling in VnTable and clean up ItemRequest component
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Pablo Natek 2025-05-05 10:49:37 +02:00
parent 240b927a02
commit cb1fa3c7f5
4 changed files with 10 additions and 7 deletions

View File

@ -493,6 +493,11 @@ async function renderInput(rowId, field, clickedElement) {
console.log('target: ', event.target); console.log('target: ', event.target);
await handleTabKey(event, rowId, field); await handleTabKey(event, rowId, field);
event.stopPropagation(); event.stopPropagation();
const column = $props.columns.find((col) => col.name === field);
if (typeof column?.beforeDestroy === 'function')
await column.beforeDestroy(
CrudModelRef.value.formData[editingRow.value],
);
break; break;
case 'Escape': case 'Escape':
console.log('destroyInput 5'); console.log('destroyInput 5');
@ -530,10 +535,6 @@ async function updateSelectValue(value, column, row, oldValue) {
} }
async function destroyInput(rowIndex, field, clickedElement) { async function destroyInput(rowIndex, field, clickedElement) {
const column = $props.columns.find((col) => col.name === field);
if (typeof column?.beforeDestroy === 'function')
await column.beforeDestroy(CrudModelRef.value.formData[rowIndex]);
if (!clickedElement) if (!clickedElement)
clickedElement = document.querySelector( clickedElement = document.querySelector(
`[data-row-index="${rowIndex}"][data-col-field="${field}"]`, `[data-row-index="${rowIndex}"][data-col-field="${field}"]`,

View File

@ -282,7 +282,6 @@ const columns = computed(() => [
actions: [ actions: [
{ {
title: t('globals.clone'), title: t('globals.clone'),
icon: 'vn:clone', icon: 'vn:clone',
action: openCloneDialog, action: openCloneDialog,
isPrimary: true, isPrimary: true,

View File

@ -158,7 +158,7 @@ const columns = computed(() => [
await tableRef.value.reload(); await tableRef.value.reload();
} catch (error) { } catch (error) {
notify(error.response.data.error.message, 'negative'); notify(error.response.data.error.message, 'negative');
console.log('error: ', error); await tableRef.value.reload();
} }
}, },
}, },
@ -200,6 +200,7 @@ const columns = computed(() => [
{ {
title: t('Discard'), title: t('Discard'),
icon: 'thumb_down', icon: 'thumb_down',
fill: true,
isPrimary: true, isPrimary: true,
action: (row) => showDenyRequestForm(row.id), action: (row) => showDenyRequestForm(row.id),
}, },

View File

@ -7,7 +7,9 @@ describe('Item list', () => {
it('should filter the items and redirect to the summary', () => { it('should filter the items and redirect to the summary', () => {
cy.selectOption('[data-cy="Category_select"]', 'Plant'); cy.selectOption('[data-cy="Category_select"]', 'Plant');
cy.selectOption('[data-cy="Type_select"]', 'Anthurium'); cy.selectOption('[data-cy="Type_select"]', 'Anthurium');
cy.get('.q-virtual-scroll__content > :nth-child(4) > :nth-child(4)').click(); cy.get('td[data-row-index="0"][data-col-field="description"]')
.should('exist')
.click();
cy.url().should('include', '/summary'); cy.url().should('include', '/summary');
}); });