0
0
Fork 0

feat(VnTable): refs #6825 use checkbox if startsWith 'is' or 'has'

This commit is contained in:
Alex Moreno 2024-05-23 13:50:44 +02:00
parent 2ec4e3540f
commit 89e1b3581a
4 changed files with 21 additions and 29 deletions

View File

@ -99,6 +99,11 @@ const col = computed(() => {
...specific.forceAttrs, ...specific.forceAttrs,
}; };
} }
if (
(newColumn.name.startsWith('is') || newColumn.name.startsWith('has')) &&
!newColumn.component
)
newColumn.component = 'checkbox';
if ($props.default && !newColumn.component) newColumn.component = $props.default; if ($props.default && !newColumn.component) newColumn.component = $props.default;
return newColumn; return newColumn;

View File

@ -66,7 +66,7 @@ const components = {
event: updateEvent, event: updateEvent,
attrs: { attrs: {
dense: true, dense: true,
class: 'q-pa-sm q-mt-md', class: $props.showTitle ? 'q-py-sm q-mt-md' : 'q-px-md q-py-xs',
'toggle-indeterminate': true, 'toggle-indeterminate': true,
}, },
forceAttrs: { forceAttrs: {
@ -89,7 +89,7 @@ const components = {
async function addFilter(value) { async function addFilter(value) {
if (value && typeof value === 'object') value = model.value; if (value && typeof value === 'object') value = model.value;
value = value == '' ? null : value; value = value === '' ? null : value;
let field = columnFilter.value?.name ?? $props.column.name; let field = columnFilter.value?.name ?? $props.column.name;
const toFilter = { [field]: value }; const toFilter = { [field]: value };
@ -97,9 +97,9 @@ async function addFilter(value) {
} }
function alignRow() { function alignRow() {
if ($props.column.align == 'left') return 'justify-start'; if ($props.column.align == 'left') return 'justify-start items-start';
if ($props.column.align == 'right') return 'justify-end'; if ($props.column.align == 'right') return 'justify-end items-end';
return 'justify-center'; return 'flex-center';
} }
</script> </script>
<template> <template>
@ -112,19 +112,17 @@ function alignRow() {
</div> </div>
<div <div
v-if="columnFilter !== false && column.name != 'tableActions'" v-if="columnFilter !== false && column.name != 'tableActions'"
class="row no-wrap" class="full-width"
:class="alignRow()" :class="alignRow()"
> >
<span :class="$props.column.component != 'checkbox' ? 'full-width' : alignRow()"> <VnTableColumn
<VnTableColumn :column="$props.column"
:column="$props.column" :row="{}"
:row="{}" default="input"
default="input" v-model="model"
v-model="model" :components="components"
:components="components" component-prop="columnFilter"
component-prop="columnFilter" />
/>
</span>
</div> </div>
<div v-else-if="showTitle" style="height: 45px"><!-- fixme! --></div> <div v-else-if="showTitle" style="height: 45px"><!-- fixme! --></div>
</template> </template>

View File

@ -479,7 +479,7 @@ defineExpose({
.vnTable { .vnTable {
thead tr th { thead tr th {
position: sticky; position: sticky;
z-index: 1; z-index: 2;
} }
thead tr:first-child th { thead tr:first-child th {
top: 0; top: 0;
@ -505,10 +505,10 @@ defineExpose({
.sticky { .sticky {
position: sticky; position: sticky;
right: 0; right: 0;
z-index: 1;
} }
td.sticky { td.sticky {
background-color: var(--q-dark); background-color: var(--q-dark);
z-index: 1;
} }
} }

View File

@ -177,25 +177,21 @@ const columns = computed(() => [
condition: (value) => !value, condition: (value) => !value,
icon: 'vn:disabled', icon: 'vn:disabled',
}, },
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.isVies'), label: t('customer.extendedList.tableVisibleColumns.isVies'),
name: 'isVies', name: 'isVies',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.isTaxDataChecked'), label: t('customer.extendedList.tableVisibleColumns.isTaxDataChecked'),
name: 'isTaxDataChecked', name: 'isTaxDataChecked',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.isEqualizated'), label: t('customer.extendedList.tableVisibleColumns.isEqualizated'),
name: 'isEqualizated', name: 'isEqualizated',
component: 'checkbox',
created: true, created: true,
}, },
{ {
@ -207,43 +203,36 @@ const columns = computed(() => [
condition: (value) => value, condition: (value) => value,
icon: 'vn:frozen', icon: 'vn:frozen',
}, },
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.hasToInvoice'), label: t('customer.extendedList.tableVisibleColumns.hasToInvoice'),
name: 'hasToInvoice', name: 'hasToInvoice',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.hasToInvoiceByAddress'), label: t('customer.extendedList.tableVisibleColumns.hasToInvoiceByAddress'),
name: 'hasToInvoiceByAddress', name: 'hasToInvoiceByAddress',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.isToBeMailed'), label: t('customer.extendedList.tableVisibleColumns.isToBeMailed'),
name: 'isToBeMailed', name: 'isToBeMailed',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.hasLcr'), label: t('customer.extendedList.tableVisibleColumns.hasLcr'),
name: 'hasLcr', name: 'hasLcr',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.hasCoreVnl'), label: t('customer.extendedList.tableVisibleColumns.hasCoreVnl'),
name: 'hasCoreVnl', name: 'hasCoreVnl',
component: 'checkbox',
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.hasSepaVnl'), label: t('customer.extendedList.tableVisibleColumns.hasSepaVnl'),
name: 'hasSepaVnl', name: 'hasSepaVnl',
component: 'checkbox',
}, },
{ {
align: 'right', align: 'right',