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

Merge pull request #8726 from Budibase/feature/dynamic-filter-custom-labels

Dynamic filter custom labels
This commit is contained in:
melohagan 2022-11-21 17:14:53 +00:00 committed by GitHub
commit 44525dd3f2
7 changed files with 38 additions and 9 deletions

View file

@ -19,6 +19,7 @@ import FormFieldSelect from "./controls/FormFieldSelect.svelte"
import ValidationEditor from "./controls/ValidationEditor/ValidationEditor.svelte"
import DrawerBindableCombobox from "components/common/bindings/DrawerBindableCombobox.svelte"
import ColumnEditor from "./controls/ColumnEditor/ColumnEditor.svelte"
import BasicColumnEditor from "./controls/ColumnEditor/BasicColumnEditor.svelte"
import BarButtonList from "./controls/BarButtonList.svelte"
const componentMap = {
@ -42,6 +43,7 @@ const componentMap = {
filter: FilterEditor,
url: URLSelect,
columns: ColumnEditor,
"columns/basic": BasicColumnEditor,
"field/sortable": SortableFieldSelect,
"field/string": FormFieldSelect,
"field/number": FormFieldSelect,

View file

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

View file

@ -17,6 +17,7 @@
export let columns = []
export let options = []
export let schema = {}
export let allowCellEditing = true
const flipDurationMs = 150
let dragDisabled = true
@ -123,7 +124,9 @@
on:change={e => (column.displayName = e.detail)}
/>
<Input bind:value={column.displayName} placeholder="Label" />
<CellEditor bind:column />
{#if allowCellEditing}
<CellEditor bind:column />
{/if}
<Icon
name="Close"
hoverable

View file

@ -11,6 +11,8 @@
export let componentInstance
export let value = []
export let allowCellEditing = true
export let subject = "Table"
const dispatch = createEventDispatcher()
@ -68,10 +70,16 @@
</script>
<ActionButton on:click={open}>Configure columns</ActionButton>
<Drawer bind:this={drawer} title="Table Columns">
<Drawer bind:this={drawer} title="{subject} Columns">
<svelte:fragment slot="description">
Configure the columns in your table.
Configure the columns in your {subject.toLowerCase()}.
</svelte:fragment>
<Button cta slot="buttons" on:click={save}>Save</Button>
<ColumnDrawer slot="body" bind:columns={boundValue} {options} {schema} />
<ColumnDrawer
slot="body"
bind:columns={boundValue}
{options}
{schema}
{allowCellEditing}
/>
</Drawer>

View file

@ -3932,10 +3932,10 @@
"required": true
},
{
"type": "multifield",
"label": "Allowed filter fields",
"type": "columns/basic",
"label": "Allowed filter columns",
"key": "allowedFields",
"placeholder": "All fields"
"dependsOn": "dataProvider"
},
{
"type": "select",

View file

@ -61,7 +61,10 @@
clonedSchema = schema
} else {
allowedFields?.forEach(field => {
if (schema[field]) {
if (schema[field.name]) {
clonedSchema[field.name] = schema[field.name]
clonedSchema[field.name].displayName = field.displayName
} else if (schema[field]) {
clonedSchema[field] = schema[field]
}
})

View file

@ -25,7 +25,10 @@
!BannedTypes.includes(field.type) ||
(field.type === "formula" && field.formulaType === "static")
)
.map(field => field.name)
.map(field => ({
label: field.displayName || field.name,
value: field.name,
}))
const addFilter = () => {
filters = [