1
0
Fork 0
mirror of synced 2024-09-30 00:57:16 +13: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} 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}

View file

@ -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,

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 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

View file

@ -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"
}, },