1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Merge pull request #10409 from Budibase/more-grid-tweaks

More grid tweaks
This commit is contained in:
Andrew Kingston 2023-04-25 09:58:56 +01:00 committed by GitHub
commit 0204f13c1a
6 changed files with 36 additions and 7 deletions

View file

@ -1,7 +1,7 @@
<script> <script>
import CreateEditRow from "../../modals/CreateEditRow.svelte" import CreateEditRow from "../../modals/CreateEditRow.svelte"
import { getContext, onMount } from "svelte" import { getContext, onMount } from "svelte"
import { Modal } from "@budibase/bbui" import { Modal, notifications } from "@budibase/bbui"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
const { subscribe, rows } = getContext("grid") const { subscribe, rows } = getContext("grid")
@ -9,6 +9,11 @@
let modal let modal
let row let row
const deleteRow = e => {
rows.actions.deleteRows([e.detail])
notifications.success("Deleted 1 row")
}
onMount(() => onMount(() =>
subscribe("add-row", () => { subscribe("add-row", () => {
row = {} row = {}
@ -24,5 +29,9 @@
</script> </script>
<Modal bind:this={modal}> <Modal bind:this={modal}>
<CreateEditRow {row} on:updaterows={e => rows.actions.refreshRow(e.detail)} /> <CreateEditRow
{row}
on:updaterows={e => rows.actions.refreshRow(e.detail)}
on:deleteRows={deleteRow}
/>
</Modal> </Modal>

View file

@ -48,8 +48,8 @@
} }
const cellAPI = { const cellAPI = {
focus: () => api?.focus(), focus: () => api?.focus?.(),
blur: () => api?.blur(), blur: () => api?.blur?.(),
isActive: () => api?.isActive?.() ?? false, isActive: () => api?.isActive?.() ?? false,
onKeyDown: (...params) => api?.onKeyDown(...params), onKeyDown: (...params) => api?.onKeyDown(...params),
isReadonly: () => readonly, isReadonly: () => readonly,

View file

@ -113,11 +113,15 @@
} }
.expand { .expand {
opacity: 0; opacity: 0;
pointer-events: none;
margin-right: 4px; margin-right: 4px;
} }
.expand :global(.spectrum-Icon) {
pointer-events: none;
}
.expand.visible { .expand.visible {
opacity: 1; opacity: 1;
}
.expand.visible :global(.spectrum-Icon) {
pointer-events: all; pointer-events: all;
} }
</style> </style>

View file

@ -93,6 +93,16 @@
columns.actions.changePrimaryDisplay(column.name) columns.actions.changePrimaryDisplay(column.name)
open = false open = false
} }
const hideColumn = () => {
columns.update(state => {
const index = state.findIndex(col => col.name === column.name)
state[index].visible = false
return state.slice()
})
columns.actions.saveChanges()
open = false
}
</script> </script>
<div <div
@ -184,6 +194,7 @@
<MenuItem disabled={!canMoveRight} icon="ChevronRight" on:click={moveRight}> <MenuItem disabled={!canMoveRight} icon="ChevronRight" on:click={moveRight}>
Move right Move right
</MenuItem> </MenuItem>
<MenuItem icon="VisibilityOff" on:click={hideColumn}>Hide column</MenuItem>
</Menu> </Menu>
</Popover> </Popover>

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
import { ActionButton, Popover, Toggle } from "@budibase/bbui" import { ActionButton, Popover, Toggle } from "@budibase/bbui"
const { columns } = getContext("grid") const { columns, stickyColumn } = getContext("grid")
let open = false let open = false
let anchor let anchor
@ -55,13 +55,17 @@
<Popover bind:open {anchor} align="left"> <Popover bind:open {anchor} align="left">
<div class="content"> <div class="content">
<div class="columns"> <div class="columns">
{#if $stickyColumn}
<Toggle disabled size="S" value={true} />
<span>{$stickyColumn.label}</span>
{/if}
{#each $columns as column} {#each $columns as column}
<Toggle <Toggle
size="S" size="S"
value={column.visible} value={column.visible}
on:change={e => toggleVisibility(column, e.detail)} on:change={e => toggleVisibility(column, e.detail)}
/> />
<span>{column.name}</span> <span>{column.label}</span>
{/each} {/each}
</div> </div>
<div class="buttons"> <div class="buttons">

View file

@ -46,6 +46,7 @@
} }
return return
} else if (e.key === "Tab") { } else if (e.key === "Tab") {
e.preventDefault()
api?.blur?.() api?.blur?.()
changeFocusedColumn(1) changeFocusedColumn(1)
return return