commit
f5650a82b5
|
@ -487,7 +487,7 @@
|
||||||
]}
|
]}
|
||||||
getOptionLabel={option => option.label}
|
getOptionLabel={option => option.label}
|
||||||
getOptionValue={option => option.value}
|
getOptionValue={option => option.value}
|
||||||
tooltip="Dynamic formula are calculated when retrieved, but cannot be filtered,
|
tooltip="Dynamic formula are calculated when retrieved, but cannot be filtered or sorted by,
|
||||||
while static formula are calculated when the row is saved."
|
while static formula are calculated when the row is saved."
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import TableSelect from "./controls/TableSelect.svelte"
|
||||||
import ColorPicker from "./controls/ColorPicker.svelte"
|
import ColorPicker from "./controls/ColorPicker.svelte"
|
||||||
import { IconSelect } from "./controls/IconSelect"
|
import { IconSelect } from "./controls/IconSelect"
|
||||||
import FieldSelect from "./controls/FieldSelect.svelte"
|
import FieldSelect from "./controls/FieldSelect.svelte"
|
||||||
|
import SortableFieldSelect from "./controls/SortableFieldSelect.svelte"
|
||||||
import MultiFieldSelect from "./controls/MultiFieldSelect.svelte"
|
import MultiFieldSelect from "./controls/MultiFieldSelect.svelte"
|
||||||
import SearchFieldSelect from "./controls/SearchFieldSelect.svelte"
|
import SearchFieldSelect from "./controls/SearchFieldSelect.svelte"
|
||||||
import SchemaSelect from "./controls/SchemaSelect.svelte"
|
import SchemaSelect from "./controls/SchemaSelect.svelte"
|
||||||
|
@ -41,6 +42,7 @@ const componentMap = {
|
||||||
filter: FilterEditor,
|
filter: FilterEditor,
|
||||||
url: URLSelect,
|
url: URLSelect,
|
||||||
columns: ColumnEditor,
|
columns: ColumnEditor,
|
||||||
|
"field/sortable": SortableFieldSelect,
|
||||||
"field/string": FormFieldSelect,
|
"field/string": FormFieldSelect,
|
||||||
"field/number": FormFieldSelect,
|
"field/number": FormFieldSelect,
|
||||||
"field/options": FormFieldSelect,
|
"field/options": FormFieldSelect,
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<script>
|
||||||
|
import { Select } from "@budibase/bbui"
|
||||||
|
import {
|
||||||
|
getDatasourceForProvider,
|
||||||
|
getSchemaForDatasource,
|
||||||
|
} from "builderStore/dataBinding"
|
||||||
|
import { currentAsset } from "builderStore"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
import { UNSORTABLE_TYPES } from "constants"
|
||||||
|
|
||||||
|
export let componentInstance = {}
|
||||||
|
export let value = ""
|
||||||
|
export let placeholder
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
|
$: schema = getSchemaForDatasource($currentAsset, datasource).schema
|
||||||
|
$: options = getSortableFields(schema)
|
||||||
|
$: boundValue = getValidValue(value, options)
|
||||||
|
|
||||||
|
const getSortableFields = schema => {
|
||||||
|
return Object.entries(schema || {})
|
||||||
|
.filter(entry => !UNSORTABLE_TYPES.includes(entry[1].type))
|
||||||
|
.map(entry => entry[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
const getValidValue = (value, options) => {
|
||||||
|
// Reset value if there aren't any options
|
||||||
|
if (!Array.isArray(options)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset value if the value isn't found in the options
|
||||||
|
if (options.indexOf(value) === -1) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
const onChange = value => {
|
||||||
|
boundValue = getValidValue(value.detail, options)
|
||||||
|
dispatch("change", boundValue)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Select {placeholder} value={boundValue} on:change={onChange} {options} />
|
|
@ -55,7 +55,7 @@
|
||||||
Add plugin
|
Add plugin
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{#if filteredPlugins?.length}
|
{#if $plugins?.length}
|
||||||
<div class="filters">
|
<div class="filters">
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<Select
|
<Select
|
||||||
|
|
|
@ -3523,7 +3523,7 @@
|
||||||
"key": "filter"
|
"key": "filter"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field/sortable",
|
||||||
"label": "Sort Column",
|
"label": "Sort Column",
|
||||||
"key": "sortColumn"
|
"key": "sortColumn"
|
||||||
},
|
},
|
||||||
|
@ -3853,7 +3853,7 @@
|
||||||
"key": "filter"
|
"key": "filter"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field/sortable",
|
||||||
"label": "Sort Column",
|
"label": "Sort Column",
|
||||||
"key": "sortColumn"
|
"key": "sortColumn"
|
||||||
},
|
},
|
||||||
|
@ -4018,7 +4018,7 @@
|
||||||
"key": "filter"
|
"key": "filter"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field/sortable",
|
||||||
"label": "Sort Column",
|
"label": "Sort Column",
|
||||||
"key": "sortColumn"
|
"key": "sortColumn"
|
||||||
},
|
},
|
||||||
|
@ -4177,7 +4177,7 @@
|
||||||
"key": "filter"
|
"key": "filter"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field/sortable",
|
||||||
"label": "Sort Column",
|
"label": "Sort Column",
|
||||||
"key": "sortColumn"
|
"key": "sortColumn"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue