feat: refs #7936 add autocomplete on tab fn
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-12-11 10:10:59 +01:00
parent f61509f376
commit 8a1cda6914
1 changed files with 12 additions and 6 deletions

View File

@ -119,7 +119,17 @@ function taxRate(invoiceInTax) {
return ((taxTypeSage / 100) * taxableBase).toFixed(2); return ((taxTypeSage / 100) * taxableBase).toFixed(2);
} }
const formatLabel = (row, prop) => `${row.id}: ${row[prop]}`; function autocompleteExpense(evt, row, col) {
const val = evt.target.value;
if (!val) return;
const param = isNaN(val) ? row[col.model] : val;
const lookup = expenses.value.find(
({ id }) => id == useAccountShortToStandard(param)
);
if (lookup) row[col.model] = lookup;
}
</script> </script>
<template> <template>
<FetchData <FetchData
@ -163,11 +173,7 @@ const formatLabel = (row, prop) => `${row.id}: ${row[prop]}`;
:option-label="col.optionLabel" :option-label="col.optionLabel"
:filter-options="['id', 'name']" :filter-options="['id', 'name']"
:tooltip="t('Create a new expense')" :tooltip="t('Create a new expense')"
@keydown.tab=" @keydown.tab="autocompleteExpense($event, row, col)"
row[col.model] = useAccountShortToStandard(
$event.target.value
)
"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">