Apply column order for Grid block (#11099)

* Apply column order for Grid block

* Refactor

* Do not allow column reorder for Grid block

* Refactor
This commit is contained in:
melohagan 2023-07-04 08:34:59 +01:00 committed by GitHub
parent 10be6509d6
commit c9589c1edc
5 changed files with 20 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import ValidationEditor from "./controls/ValidationEditor/ValidationEditor.svelt
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import ColumnEditor from "./controls/ColumnEditor/ColumnEditor.svelte" import ColumnEditor from "./controls/ColumnEditor/ColumnEditor.svelte"
import BasicColumnEditor from "./controls/ColumnEditor/BasicColumnEditor.svelte" import BasicColumnEditor from "./controls/ColumnEditor/BasicColumnEditor.svelte"
import GridColumnEditor from "./controls/ColumnEditor/GridColumnEditor.svelte"
import BarButtonList from "./controls/BarButtonList.svelte" import BarButtonList from "./controls/BarButtonList.svelte"
import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration.svelte" import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration.svelte"
@ -47,6 +48,7 @@ const componentMap = {
fieldConfiguration: FieldConfiguration, fieldConfiguration: FieldConfiguration,
columns: ColumnEditor, columns: ColumnEditor,
"columns/basic": BasicColumnEditor, "columns/basic": BasicColumnEditor,
"columns/grid": GridColumnEditor,
"field/sortable": SortableFieldSelect, "field/sortable": SortableFieldSelect,
"field/string": FormFieldSelect, "field/string": FormFieldSelect,
"field/number": FormFieldSelect, "field/number": FormFieldSelect,

View File

@ -18,6 +18,7 @@
export let options = [] export let options = []
export let schema = {} export let schema = {}
export let allowCellEditing = true export let allowCellEditing = true
export let allowReorder = true
const flipDurationMs = 150 const flipDurationMs = 150
let dragDisabled = true let dragDisabled = true
@ -110,6 +111,7 @@
{#each columns as column (column.id)} {#each columns as column (column.id)}
<div class="column" animate:flip={{ duration: flipDurationMs }}> <div class="column" animate:flip={{ duration: flipDurationMs }}>
<div <div
class:hide={!allowReorder}
class="handle" class="handle"
aria-label="drag-handle" aria-label="drag-handle"
style={dragDisabled ? "cursor: grab" : "cursor: grabbing"} style={dragDisabled ? "cursor: grab" : "cursor: grabbing"}
@ -193,6 +195,9 @@
display: grid; display: grid;
place-items: center; place-items: center;
} }
.handle.hide {
visibility: hidden;
}
.wide { .wide {
grid-column: 2 / -1; grid-column: 2 / -1;
} }

View File

@ -13,6 +13,7 @@
export let componentInstance export let componentInstance
export let value = [] export let value = []
export let allowCellEditing = true export let allowCellEditing = true
export let allowReorder = true
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -85,6 +86,7 @@
{options} {options}
{schema} {schema}
{allowCellEditing} {allowCellEditing}
{allowReorder}
/> />
</Drawer> </Drawer>

View File

@ -0,0 +1,10 @@
<script>
import ColumnEditor from "./ColumnEditor.svelte"
</script>
<ColumnEditor
{...$$props}
on:change
allowCellEditing={false}
allowReorder={false}
/>

View File

@ -5248,7 +5248,7 @@
"required": true "required": true
}, },
{ {
"type": "columns/basic", "type": "columns/grid",
"label": "Columns", "label": "Columns",
"key": "columns", "key": "columns",
"dependsOn": "table" "dependsOn": "table"