1
0
Fork 0
mirror of synced 2024-08-28 08:21:41 +12:00

Update columns setting to show the number of columns

This commit is contained in:
Andrew Kingston 2023-07-11 11:14:02 +01:00
parent f084a36fe7
commit 50451c8c43

View file

@ -20,6 +20,7 @@
let drawer let drawer
let boundValue let boundValue
$: text = getText(value)
$: datasource = getDatasourceForProvider($currentAsset, componentInstance) $: datasource = getDatasourceForProvider($currentAsset, componentInstance)
$: schema = getSchema($currentAsset, datasource) $: schema = getSchema($currentAsset, datasource)
$: options = allowCellEditing $: options = allowCellEditing
@ -31,6 +32,17 @@
allowLinks: true, allowLinks: true,
}) })
const getText = value => {
if (!value?.length) {
return "All columns"
}
let text = `${value.length} column`
if (value.length !== 1) {
text += "s"
}
return text
}
const getSchema = (asset, datasource) => { const getSchema = (asset, datasource) => {
const schema = getSchemaForDatasource(asset, datasource).schema const schema = getSchemaForDatasource(asset, datasource).schema
@ -76,7 +88,7 @@
</script> </script>
<div class="column-editor"> <div class="column-editor">
<ActionButton on:click={open}>Configure columns</ActionButton> <ActionButton on:click={open}>{text}</ActionButton>
</div> </div>
<Drawer bind:this={drawer} title="Columns"> <Drawer bind:this={drawer} title="Columns">
<Button cta slot="buttons" on:click={save}>Save</Button> <Button cta slot="buttons" on:click={save}>Save</Button>