From bcbeae22799c75d1e09384cc26a4099f384c68cb Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 22 Jun 2023 08:16:59 +0100 Subject: [PATCH] Rework grid buttons, removing add row and add column buttons, and compression height and width into new size button --- .../backend/DataTable/DataTable.svelte | 4 +- .../buttons/TableFilterButton.svelte | 8 +- .../components/grid/cells/BooleanCell.svelte | 6 - .../grid/controls/ColumnWidthButton.svelte | 76 ---------- .../grid/controls/HideColumnsButton.svelte | 13 +- .../grid/controls/RowHeightButton.svelte | 71 --------- .../grid/controls/SizeButton.svelte | 135 ++++++++++++++++++ .../grid/controls/SortButton.svelte | 7 +- .../src/components/grid/layout/Grid.svelte | 21 +-- 9 files changed, 169 insertions(+), 172 deletions(-) delete mode 100644 packages/frontend-core/src/components/grid/controls/ColumnWidthButton.svelte delete mode 100644 packages/frontend-core/src/components/grid/controls/RowHeightButton.svelte create mode 100644 packages/frontend-core/src/components/grid/controls/SizeButton.svelte diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index 81df5a475d..449be506f3 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -38,6 +38,9 @@ showAvatars={false} on:updatetable={e => tables.replaceTable(id, e.detail)} > + + + {#if isInternal} @@ -52,7 +55,6 @@ {/if} - {#if isUsersTable} diff --git a/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte index 5af8d1bac8..ce6a3f0c51 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte @@ -14,6 +14,12 @@ $: tempValue = filters || [] $: schemaFields = Object.values(schema || {}) + $: text = getText(filters) + + const getText = filters => { + const count = filters?.length + return count ? `Filter (${count})` : "Filter" + } 0} > - Filter + {text} diff --git a/packages/frontend-core/src/components/grid/controls/ColumnWidthButton.svelte b/packages/frontend-core/src/components/grid/controls/ColumnWidthButton.svelte deleted file mode 100644 index fb20cc50e5..0000000000 --- a/packages/frontend-core/src/components/grid/controls/ColumnWidthButton.svelte +++ /dev/null @@ -1,76 +0,0 @@ - - -
- (open = !open)} - selected={open} - disabled={!allCols.length} - tooltip={$compact ? "Width" : null} - > - {$compact ? "" : "Width"} - -
- - -
- {#each sizeOptions as option} - columns.actions.changeAllColumnWidths(option.size)} - selected={option.selected} - > - {option.label} - - {/each} - {#if custom} - Custom - {/if} -
-
- - diff --git a/packages/frontend-core/src/components/grid/controls/HideColumnsButton.svelte b/packages/frontend-core/src/components/grid/controls/HideColumnsButton.svelte index fb66b106c9..b8728156db 100644 --- a/packages/frontend-core/src/components/grid/controls/HideColumnsButton.svelte +++ b/packages/frontend-core/src/components/grid/controls/HideColumnsButton.svelte @@ -3,12 +3,13 @@ import { ActionButton, Popover, Toggle, Icon } from "@budibase/bbui" import { getColumnIcon } from "../lib/utils" - const { columns, stickyColumn, compact } = getContext("grid") + const { columns, stickyColumn } = getContext("grid") let open = false let anchor $: anyHidden = $columns.some(col => !col.visible) + $: text = getText($columns) const toggleVisibility = (column, visible) => { columns.update(state => { @@ -38,6 +39,11 @@ }) columns.actions.saveChanges() } + + const getText = columns => { + const hidden = columns.filter(col => !col.visible).length + return hidden ? `Hide columns (${hidden})` : "Hide columns" + }
@@ -48,13 +54,12 @@ on:click={() => (open = !open)} selected={open || anyHidden} disabled={!$columns.length} - tooltip={$compact ? "Columns" : ""} > - {$compact ? "" : "Columns"} + {text}
- +
{#if $stickyColumn} diff --git a/packages/frontend-core/src/components/grid/controls/RowHeightButton.svelte b/packages/frontend-core/src/components/grid/controls/RowHeightButton.svelte deleted file mode 100644 index e9617ce0b6..0000000000 --- a/packages/frontend-core/src/components/grid/controls/RowHeightButton.svelte +++ /dev/null @@ -1,71 +0,0 @@ - - -
- (open = !open)} - selected={open} - tooltip={$compact ? "Height" : null} - > - {$compact ? "" : "Height"} - -
- - -
- {#each sizeOptions as option} - changeRowHeight(option.size)} - > - {option.label} - - {/each} -
-
- - diff --git a/packages/frontend-core/src/components/grid/controls/SizeButton.svelte b/packages/frontend-core/src/components/grid/controls/SizeButton.svelte new file mode 100644 index 0000000000..eb9bf917d9 --- /dev/null +++ b/packages/frontend-core/src/components/grid/controls/SizeButton.svelte @@ -0,0 +1,135 @@ + + +
+ (open = !open)} + selected={open} + disabled={!allCols.length} + > + Size + +
+ + +
+
+ +
+ {#each rowSizeOptions as option} + changeRowHeight(option.size)} + > + {option.label} + + {/each} +
+
+
+ +
+ {#each columnSizeOptions as option} + columns.actions.changeAllColumnWidths(option.size)} + selected={option.selected} + > + {option.label} + + {/each} + {#if custom} + Custom + {/if} +
+
+
+
+ + diff --git a/packages/frontend-core/src/components/grid/controls/SortButton.svelte b/packages/frontend-core/src/components/grid/controls/SortButton.svelte index 2018e83e44..bd75249216 100644 --- a/packages/frontend-core/src/components/grid/controls/SortButton.svelte +++ b/packages/frontend-core/src/components/grid/controls/SortButton.svelte @@ -2,7 +2,7 @@ import { getContext } from "svelte" import { ActionButton, Popover, Select } from "@budibase/bbui" - const { sort, columns, stickyColumn, compact } = getContext("grid") + const { sort, columns, stickyColumn } = getContext("grid") let open = false let anchor @@ -90,13 +90,12 @@ on:click={() => (open = !open)} selected={open} disabled={!columnOptions.length} - tooltip={$compact ? "Sort" : ""} > - {$compact ? "" : "Sort"} + Sort
- +