mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(dashboard): add choice selector and field option picker * refactor(dashboard): import raw option paths separately * chore(dashboard): remove redundant choice selector changelog * fix(dashboard): open explorer when switching to formula mode * fix: show the formula again when a reused formula input leaves raw mode --------- Co-authored-by: peter_baserow <peter@baserow.io>
65 lines
2.0 KiB
Vue
65 lines
2.0 KiB
Vue
<template>
|
|
<DashboardFormulaInput
|
|
:model-value="modelValue"
|
|
:data-providers-allowed="['table_context']"
|
|
allow-node-selection="array"
|
|
allow-raw-values
|
|
:raw-value-to-formula="pathToFormula"
|
|
@input="$emit('input', $event)"
|
|
>
|
|
<template #raw-input="{ value, disabled, readOnly, input }">
|
|
<Dropdown
|
|
:value="value"
|
|
:disabled="disabled || readOnly"
|
|
:placeholder="$t('textFilterWidget.chooseOptionsField')"
|
|
show-search
|
|
@input="input"
|
|
>
|
|
<DropdownItem
|
|
v-for="field in fields"
|
|
:key="field.path"
|
|
:name="field.name"
|
|
:value="field.path"
|
|
/>
|
|
</Dropdown>
|
|
</template>
|
|
</DashboardFormulaInput>
|
|
</template>
|
|
|
|
<script setup>
|
|
import DashboardFormulaInput from '@baserow/modules/dashboard/components/DashboardFormulaInput'
|
|
import { toFormulaStringLiteral } from '@baserow/modules/core/formula'
|
|
|
|
const props = defineProps({
|
|
modelValue: { type: Object, default: () => ({}) },
|
|
})
|
|
defineEmits(['input'])
|
|
const app = useNuxtApp()
|
|
const context = inject('dashboardFormulaContext', ref({ storePrefix: '' }))
|
|
const fields = computed(() => {
|
|
const provider = app.$registry.get('dashboardDataProvider', 'table_context')
|
|
const schema = provider.getDataSchema(context.value)
|
|
return Object.entries(schema.properties || {}).flatMap(([tableId, table]) =>
|
|
Object.entries(table.properties || {})
|
|
.filter(
|
|
([, field]) =>
|
|
field.type === 'array' &&
|
|
field.items?.properties?.value?.type === 'string'
|
|
)
|
|
.map(([fieldId, field]) => ({
|
|
path: `${provider.type}.${tableId}.${fieldId}`,
|
|
name: `${table.title} / ${field.title}`,
|
|
}))
|
|
)
|
|
})
|
|
const modelValue = computed(() =>
|
|
props.modelValue.mode || props.modelValue.formula
|
|
? props.modelValue
|
|
: { ...props.modelValue, mode: 'raw' }
|
|
)
|
|
const pathToFormula = (path) =>
|
|
path.startsWith('table_context.')
|
|
? `get(${toFormulaStringLiteral(path)})`
|
|
: toFormulaStringLiteral(path)
|
|
</script>
|