Change anyHidden to anyRestricted
This commit is contained in:
parent
4dbfa28feb
commit
5444655237
|
@ -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}
|
||||||
|
|
Loading…
Reference in New Issue