fix: tables

This commit is contained in:
Arman
2025-03-25 16:19:09 +01:00
parent 70b73a5c98
commit fad656d461
11 changed files with 20 additions and 25 deletions
+1 -1
View File
@@ -63,7 +63,7 @@
</Typography.Text>
{/if}
<Table.Root
columns={[{ id: 'resource' }, { id: 'limit' }, { id: 'rate', hide: isFree }]}
columns={[{ id: 'resource' }, { id: 'limit' }, { id: 'rate', show: !isFree }]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell column="resource" {root}>Resource</Table.Header.Cell>
@@ -128,7 +128,7 @@
const columns: Column[] = [
{ id: 'role', width: { min: 100 } },
{ id: 'create', width: { min: 100 }, hide: !withCreate },
{ id: 'create', width: { min: 100 }, show: withCreate },
{ id: 'read', width: { min: 100 } },
{ id: 'update', width: { min: 100 } },
{ id: 'delete', width: { min: 100 } },
+10 -8
View File
@@ -29,7 +29,7 @@
const prefs = preferences.getCustomCollectionColumns($page.params.collection);
columns.set(
$columns.map((column) => {
column.show = prefs?.includes(column.id) ?? false;
column.show = prefs?.includes(column.id) ?? true;
return column;
})
);
@@ -40,7 +40,7 @@
if (prefs?.columns) {
columns.set(
$columns.map((column) => {
column.show = prefs.columns?.includes(column.id) ?? false;
column.show = prefs.columns?.includes(column.id) ?? true;
return column;
})
);
@@ -75,11 +75,13 @@
});
}
$: selectedColumnsNumber = $columns.reduce((acc, column) => {
if (column.show === true) return acc;
$: selectedColumnsNumber = $columns
.filter((c) => !c?.exclude)
.reduce((acc, column) => {
if (column.show === true) return acc;
return ++acc;
}, 0);
return ++acc;
}, 0);
</script>
{#if !hideColumns && view === View.Table}
@@ -95,13 +97,13 @@
<svelte:fragment slot="tooltip">
<ActionMenu.Root>
<Layout.Stack>
{#each $columns as column}
{#each $columns.filter((c) => !c?.exclude) as column}
{#if !column?.exclude}
<InputCheckbox
id={column.id}
label={column.title}
on:change={() => (column.show = !column.show)}
checked={!column.show}
checked={column.show}
disabled={allowNoColumns
? false
: selectedColumnsNumber <= 1 && column.show !== true} />
+1 -1
View File
@@ -78,7 +78,7 @@
{ id: 'name' },
{ id: 'verification' },
{ id: 'certificate' },
{ id: 'action', width: 20, hide: !$canWriteRules }
{ id: 'action', width: 20, show: $canWriteRules }
]}>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell column="name" {root}>Name</Table.Header.Cell>