From 533b41ad78d525e380f2b380d51cbb7a2873e967 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 17 Feb 2025 10:53:45 +0100 Subject: [PATCH] feat: refs #6897 update table column widths and alignment, enhance input --- src/components/VnTable/VnTable.vue | 18 +++++---- src/pages/Entry/Card/EntryBuys.vue | 11 +++--- src/pages/Entry/EntryList.vue | 30 +++++++++++++-- src/pages/Entry/EntryStockBought.vue | 18 ++++++--- src/pages/Entry/EntryStockBoughtDetail.vue | 16 ++++---- .../integration/entry/entryList.spec.js | 32 ++++++++-------- .../integration/entry/stockBought.spec.js | 38 ++++++++++++------- 7 files changed, 103 insertions(+), 60 deletions(-) diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 3e1923b4c..37563a907 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -353,14 +353,14 @@ const clickHandler = async (event) => { const column = $props.columns.find((col) => col.name === colField); if (editingRow.value !== null && editingField.value !== null) { - if (editingRow.value === rowIndex && editingField.value === colField) { - return; - } + if (editingRow.value == rowIndex && editingField.value == colField) return; destroyInput(editingRow.value, editingField.value); } - if (isEditableColumn(column)) + + if (isEditableColumn(column)) { await renderInput(Number(rowIndex), colField, clickedElement); + } }; async function handleTabKey(event, rowIndex, colField) { @@ -449,8 +449,11 @@ async function renderInput(rowId, field, clickedElement) { node.appContext = app._context; render(node, clickedElement); - if (['checkbox', 'toggle', undefined].includes(column?.component)) + if (['toggle'].includes(column?.component)) node.el?.querySelector('span > div').focus(); + + if (['checkbox', undefined].includes(column?.component)) + node.el?.querySelector('span > div > div').focus(); } function destroyInput(rowIndex, field, clickedElement) { @@ -489,9 +492,7 @@ async function handleTabNavigation(rowIndex, colName, direction) { if (isEditableColumn(columns[newColumnIndex])) break; } while (iterations < totalColumns); - if (iterations >= totalColumns) { - return; - } + if (iterations >= totalColumns + 1) return; if (direction === 1 && newColumnIndex <= currentColumnIndex) { rowIndex++; @@ -760,6 +761,7 @@ const checkbox = ref(null); : 'hidden' }`" @click="btn.action(row)" + :data-cy="btn?.name ?? `tableAction-${index}`" /> diff --git a/src/pages/Entry/Card/EntryBuys.vue b/src/pages/Entry/Card/EntryBuys.vue index e159c5356..f3b73cb04 100644 --- a/src/pages/Entry/Card/EntryBuys.vue +++ b/src/pages/Entry/Card/EntryBuys.vue @@ -209,13 +209,14 @@ const columns = [ row['amount'] = row['quantity'] * row['buyingValue']; }, }, - width: '20px', + width: '30px', style: (row) => { if (row.groupingMode === 'grouping') return { color: 'var(--vn-label-color)' }; }, }, { + align: 'center', labelAbbreviation: 'GM', label: t('Grouping selector'), toolTip: t('Grouping selector'), @@ -249,7 +250,7 @@ const columns = [ toolTip: 'Grouping', name: 'grouping', component: 'number', - width: '20px', + width: '30px', create: true, style: (row) => { if (row.groupingMode === 'packing') return { color: 'var(--vn-label-color)' }; @@ -508,7 +509,7 @@ async function setBuyUltimate(itemFk, data) { allowedKeys.forEach((key) => { if (buyUltimateData.hasOwnProperty(key) && key !== 'entryFk') { - data[key] = buyUltimateData[key]; + if (!['stickers', 'quantity'].includes(key)) data[key] = buyUltimateData[key]; } }); } @@ -600,7 +601,6 @@ onMounted(() => { ref="entryBuysRef" data-key="EntryBuys" :url="`Entries/${entityId}/getBuyList`" - order="name DESC" save-url="Buys/crud" :disable-option="{ card: true }" v-model:selected="selectedRows" @@ -644,7 +644,8 @@ onMounted(() => { :is-editable="editableMode" :without-header="!editableMode" :with-filters="editableMode" - :right-search="editableMode" + :right-search="false" + :right-search-icon="false" :row-click="false" :columns="columns" :beforeSaveFn="beforeSave" diff --git a/src/pages/Entry/EntryList.vue b/src/pages/Entry/EntryList.vue index 845d65604..d50f6b219 100644 --- a/src/pages/Entry/EntryList.vue +++ b/src/pages/Entry/EntryList.vue @@ -44,28 +44,32 @@ const entryQueryFilter = { const columns = computed(() => [ { - label: 'Ex', + labelAbbreviation: 'Ex', + label: t('entry.list.tableVisibleColumns.isExcludedFromAvailable'), toolTip: t('entry.list.tableVisibleColumns.isExcludedFromAvailable'), name: 'isExcludedFromAvailable', component: 'checkbox', width: '35px', }, { - label: 'Pe', + labelAbbreviation: 'Pe', + label: t('entry.list.tableVisibleColumns.isOrdered'), toolTip: t('entry.list.tableVisibleColumns.isOrdered'), name: 'isOrdered', component: 'checkbox', width: '35px', }, { - label: 'Le', + labelAbbreviation: 'LE', + label: t('entry.list.tableVisibleColumns.isConfirmed'), toolTip: t('entry.list.tableVisibleColumns.isConfirmed'), name: 'isConfirmed', component: 'checkbox', width: '35px', }, { - label: 'Re', + labelAbbreviation: 'Re', + label: t('entry.list.tableVisibleColumns.isReceived'), toolTip: t('entry.list.tableVisibleColumns.isReceived'), name: 'isReceived', component: 'checkbox', @@ -89,6 +93,7 @@ const columns = computed(() => [ chip: { condition: () => true, }, + width: '50px', }, { label: t('entry.list.tableVisibleColumns.supplierFk'), @@ -99,8 +104,10 @@ const columns = computed(() => [ attrs: { url: 'suppliers', fields: ['id', 'name'], + where: { order: 'name DESC' }, }, format: (row, dashIfEmpty) => dashIfEmpty(row.supplierName), + width: '110px', }, { align: 'left', @@ -124,6 +131,7 @@ const columns = computed(() => [ label: 'AWB', name: 'awbCode', component: 'input', + width: '100px', }, { align: 'left', @@ -160,6 +168,7 @@ const columns = computed(() => [ component: null, }, format: (row, dashIfEmpty) => dashIfEmpty(row.warehouseOutName), + width: '65px', }, { align: 'left', @@ -175,12 +184,24 @@ const columns = computed(() => [ component: null, }, format: (row, dashIfEmpty) => dashIfEmpty(row.warehouseInName), + width: '65px', }, { align: 'left', + labelAbbreviation: t('Type'), label: t('entry.list.tableVisibleColumns.entryTypeDescription'), + toolTip: t('entry.list.tableVisibleColumns.entryTypeDescription'), name: 'entryTypeCode', + component: 'select', + attrs: { + url: 'entryTypes', + fields: ['code', 'description'], + optionValue: 'code', + optionLabel: 'description', + }, cardVisible: true, + width: '65px', + format: (row, dashIfEmpty) => dashIfEmpty(row.entryTypeDescription), }, { name: 'companyFk', @@ -320,4 +341,5 @@ es: Search entries: Buscar entradas You can search by entry reference: Puedes buscar por referencia de la entrada Create entry: Crear entrada + Type: Tipo diff --git a/src/pages/Entry/EntryStockBought.vue b/src/pages/Entry/EntryStockBought.vue index fa0bdc12e..da8557828 100644 --- a/src/pages/Entry/EntryStockBought.vue +++ b/src/pages/Entry/EntryStockBought.vue @@ -34,18 +34,20 @@ const columns = computed(() => [ label: t('entryStockBought.buyer'), isTitle: true, component: 'select', + isEditable: false, cardVisible: true, create: true, attrs: { url: 'Workers/activeWithInheritedRole', - fields: ['id', 'name'], + fields: ['id', 'name', 'nickname'], where: { role: 'buyer' }, optionFilter: 'firstName', - optionLabel: 'name', + optionLabel: 'nickname', optionValue: 'id', useLike: false, }, columnFilter: false, + width: '70px', }, { align: 'center', @@ -55,6 +57,7 @@ const columns = computed(() => [ create: true, component: 'number', summation: true, + width: '60px', }, { align: 'center', @@ -78,6 +81,7 @@ const columns = computed(() => [ actions: [ { title: t('entryStockBought.viewMoreDetails'), + name: 'searchBtn', icon: 'search', isPrimary: true, action: (row) => { @@ -91,6 +95,7 @@ const columns = computed(() => [ }, }, ], + 'data-cy': 'table-actions', }, ]); @@ -158,7 +163,7 @@ function round(value) { @on-fetch=" (data) => { travel = data.find( - (data) => data.warehouseIn?.code.toLowerCase() === 'vnh' + (data) => data.warehouseIn?.code.toLowerCase() === 'vnh', ); } " @@ -179,6 +184,7 @@ function round(value) { @click="openDialog()" :title="t('entryStockBought.editTravel')" color="primary" + data-cy="edit-travel" /> @@ -239,10 +245,11 @@ function round(value) { table-height="80vh" auto-load :column-search="false" + :without-header="true" > @@ -279,10 +286,11 @@ function round(value) { justify-content: center; } .column { + min-width: 30%; + margin-top: 5%; display: flex; flex-direction: column; align-items: center; - min-width: 35%; } .text-negative { color: $negative !important; diff --git a/src/pages/Entry/EntryStockBoughtDetail.vue b/src/pages/Entry/EntryStockBoughtDetail.vue index 812171825..9d382f23a 100644 --- a/src/pages/Entry/EntryStockBoughtDetail.vue +++ b/src/pages/Entry/EntryStockBoughtDetail.vue @@ -21,7 +21,7 @@ const $props = defineProps({ const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&dated=${$props.dated}`; const columns = [ { - align: 'left', + align: 'right', label: t('Entry'), name: 'entryFk', isTitle: true, @@ -29,7 +29,7 @@ const columns = [ columnFilter: false, }, { - align: 'left', + align: 'right', name: 'itemFk', label: t('Item'), columnFilter: false, @@ -44,21 +44,21 @@ const columns = [ cardVisible: true, }, { - align: 'left', + align: 'right', name: 'volume', label: t('Volume'), columnFilter: false, cardVisible: true, }, { - align: 'left', + align: 'right', label: t('Packaging'), name: 'packagingFk', columnFilter: false, cardVisible: true, }, { - align: 'left', + align: 'right', label: 'Packing', name: 'packing', columnFilter: false, @@ -73,12 +73,14 @@ const columns = [ ref="tableRef" data-key="StockBoughtsDetail" :url="customUrl" - order="itemName DESC" + order="volume DESC" :columns="columns" :right-search="false" :disable-infinite-scroll="true" :disable-option="{ card: true }" :limit="0" + :without-header="true" + :with-filters="false" auto-load >