1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

Merge pull request #8247 from Budibase/cheeks-fixes

Misc bug fixes
This commit is contained in:
Andrew Kingston 2022-10-14 10:14:36 +01:00 committed by GitHub
commit 299ab00dd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 6 deletions

View file

@ -487,7 +487,7 @@
]}
getOptionLabel={option => option.label}
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."
/>
{/if}

View file

@ -7,6 +7,7 @@ import TableSelect from "./controls/TableSelect.svelte"
import ColorPicker from "./controls/ColorPicker.svelte"
import { IconSelect } from "./controls/IconSelect"
import FieldSelect from "./controls/FieldSelect.svelte"
import SortableFieldSelect from "./controls/SortableFieldSelect.svelte"
import MultiFieldSelect from "./controls/MultiFieldSelect.svelte"
import SearchFieldSelect from "./controls/SearchFieldSelect.svelte"
import SchemaSelect from "./controls/SchemaSelect.svelte"
@ -41,6 +42,7 @@ const componentMap = {
filter: FilterEditor,
url: URLSelect,
columns: ColumnEditor,
"field/sortable": SortableFieldSelect,
"field/string": FormFieldSelect,
"field/number": FormFieldSelect,
"field/options": FormFieldSelect,

View file

@ -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} />

View file

@ -55,7 +55,7 @@
Add plugin
</Button>
</div>
{#if filteredPlugins?.length}
{#if $plugins?.length}
<div class="filters">
<div class="select">
<Select

View file

@ -3523,7 +3523,7 @@
"key": "filter"
},
{
"type": "field",
"type": "field/sortable",
"label": "Sort Column",
"key": "sortColumn"
},
@ -3853,7 +3853,7 @@
"key": "filter"
},
{
"type": "field",
"type": "field/sortable",
"label": "Sort Column",
"key": "sortColumn"
},
@ -4018,7 +4018,7 @@
"key": "filter"
},
{
"type": "field",
"type": "field/sortable",
"label": "Sort Column",
"key": "sortColumn"
},
@ -4177,7 +4177,7 @@
"key": "filter"
},
{
"type": "field",
"type": "field/sortable",
"label": "Sort Column",
"key": "sortColumn"
},