Add double click to edit columns in grids

This commit is contained in:
Andrew Kingston 2024-05-20 15:02:06 +01:00
parent de13f4ea11
commit 4ede31acf6
4 changed files with 16 additions and 9 deletions

View File

@ -88,7 +88,6 @@ export { default as ListItem } from "./List/ListItem.svelte"
export { default as IconSideNav } from "./IconSideNav/IconSideNav.svelte" export { default as IconSideNav } from "./IconSideNav/IconSideNav.svelte"
export { default as IconSideNavItem } from "./IconSideNav/IconSideNavItem.svelte" export { default as IconSideNavItem } from "./IconSideNav/IconSideNavItem.svelte"
export { default as Accordion } from "./Accordion/Accordion.svelte" export { default as Accordion } from "./Accordion/Accordion.svelte"
export { default as OptionSelectDnD } from "./OptionSelectDnD/OptionSelectDnD.svelte"
export { default as AbsTooltip } from "./Tooltip/AbsTooltip.svelte" export { default as AbsTooltip } from "./Tooltip/AbsTooltip.svelte"
export { TooltipPosition, TooltipType } from "./Tooltip/AbsTooltip.svelte" export { TooltipPosition, TooltipType } from "./Tooltip/AbsTooltip.svelte"

View File

@ -9,7 +9,6 @@
DatePicker, DatePicker,
Modal, Modal,
notifications, notifications,
OptionSelectDnD,
Layout, Layout,
AbsTooltip, AbsTooltip,
ProgressCircle, ProgressCircle,
@ -42,6 +41,7 @@
import RelationshipSelector from "components/common/RelationshipSelector.svelte" import RelationshipSelector from "components/common/RelationshipSelector.svelte"
import { RowUtils } from "@budibase/frontend-core" import { RowUtils } from "@budibase/frontend-core"
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte" import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
import OptionsEditor from "./OptionsEditor.svelte"
const AUTO_TYPE = FieldType.AUTO const AUTO_TYPE = FieldType.AUTO
const FORMULA_TYPE = FieldType.FORMULA const FORMULA_TYPE = FieldType.FORMULA
@ -558,7 +558,7 @@
bind:value={editableColumn.constraints.length.maximum} bind:value={editableColumn.constraints.length.maximum}
/> />
{:else if editableColumn.type === FieldType.OPTIONS} {:else if editableColumn.type === FieldType.OPTIONS}
<OptionSelectDnD <OptionsEditor
bind:constraints={editableColumn.constraints} bind:constraints={editableColumn.constraints}
bind:optionColors={editableColumn.optionColors} bind:optionColors={editableColumn.optionColors}
/> />
@ -581,7 +581,7 @@
/> />
</div> </div>
{:else if editableColumn.type === FieldType.ARRAY} {:else if editableColumn.type === FieldType.ARRAY}
<OptionSelectDnD <OptionsEditor
bind:constraints={editableColumn.constraints} bind:constraints={editableColumn.constraints}
bind:optionColors={editableColumn.optionColors} bind:optionColors={editableColumn.optionColors}
/> />

View File

@ -1,15 +1,14 @@
<script> <script>
import { flip } from "svelte/animate" import { flip } from "svelte/animate"
import { dndzone } from "svelte-dnd-action" import { dndzone } from "svelte-dnd-action"
import Icon from "../Icon/Icon.svelte" import { Icon, Popover } from "@budibase/bbui"
import Popover from "../Popover/Popover.svelte"
import { onMount } from "svelte" import { onMount } from "svelte"
const flipDurationMs = 150
export let constraints export let constraints
export let optionColors = {} export let optionColors = {}
const flipDurationMs = 150
let options = [] let options = []
let colorPopovers = [] let colorPopovers = []
let anchors = [] let anchors = []

View File

@ -236,6 +236,14 @@
} }
const debouncedUpdateFilter = debounce(updateFilter, 250) const debouncedUpdateFilter = debounce(updateFilter, 250)
const handleDoubleClick = () => {
if (!$config.canEditColumns || column.schema.disabled || searching) {
return
}
open = true
editColumn()
}
onMount(() => subscribe("close-edit-column", close)) onMount(() => subscribe("close-edit-column", close))
</script> </script>
@ -254,6 +262,7 @@
bind:this={anchor} bind:this={anchor}
class:disabled={$isReordering || $isResizing} class:disabled={$isReordering || $isResizing}
class:sticky={idx === "sticky"} class:sticky={idx === "sticky"}
on:dblclick={handleDoubleClick}
> >
<GridCell <GridCell
on:mousedown={onMouseDown} on:mousedown={onMouseDown}
@ -316,7 +325,7 @@
{#if open} {#if open}
<GridPopover <GridPopover
{anchor} {anchor}
align="right" align="left"
on:close={close} on:close={close}
maxHeight={null} maxHeight={null}
resizable resizable