Change anyHidden to anyRestricted

This commit is contained in:
Adria Navarro 2024-05-31 11:14:41 +02:00
parent 4dbfa28feb
commit 5444655237
1 changed files with 4 additions and 10 deletions

View File

@ -12,8 +12,9 @@
let open = false let open = false
let anchor let anchor
$: anyHidden = $columns.some(col => !col.visible) $: restrictedColumns = $columns.filter(col => !col.visible || col.readonly)
$: text = getText($columns) $: anyRestricted = restrictedColumns.length
$: text = anyRestricted ? `Columns (${anyRestricted} restricted)` : "Columns"
const toggleColumn = async (column, permission) => { const toggleColumn = async (column, permission) => {
const visible = permission !== PERMISSION_OPTIONS.HIDDEN const visible = permission !== PERMISSION_OPTIONS.HIDDEN
@ -28,13 +29,6 @@
dispatch(visible ? "show-column" : "hide-column") dispatch(visible ? "show-column" : "hide-column")
} }
const getText = columns => {
const restricted = columns.filter(
col => !col.visible || col.readonly
).length
return restricted ? `Columns (${restricted} restricted)` : "Columns"
}
const PERMISSION_OPTIONS = { const PERMISSION_OPTIONS = {
WRITABLE: "writable", WRITABLE: "writable",
READONLY: "readonly", READONLY: "readonly",
@ -83,7 +77,7 @@
quiet quiet
size="M" size="M"
on:click={() => (open = !open)} on:click={() => (open = !open)}
selected={open || anyHidden} selected={open || anyRestricted}
disabled={!$columns.length} disabled={!$columns.length}
> >
{text} {text}