Files
Peter EvansandJeremie Pardou f07d8c895e feat: set up dashboard filters from a table and create the widgets they filter (#6771)
* feat: set up dashboard filters from a table and create the widgets they filter

* feat: refine dashboard filter setup and widget association

Support multi-table filters, guided widget configuration, same-table condition copying in display order, and automatic linking defaults. Preserve independent target settings and undo/redo behavior.

* fix: show copied filter conditions after widget association

* test: cover guided dashboard widget creation from a filter

* test: cover dashboard filter copying across tables

* refactor: simplify dashboard filter configuration

* fix: restore dashboard filter links exactly on undo and redo

* feat: set up a new widget and how a filter narrows it down in one modal

* feat: fold the add-widget modal into collapsible sections that fit chart settings

* fix: cancel queued updates when destroying dashboard charts

* fix: reference dashboard option context by table

* refactor: rename dashboard table context provider

* fix: label dashboard table context as field options

* fix: shorten dashboard table options label

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-23 15:00:35 +00:00

89 lines
2.2 KiB
Vue

<template>
<ItemPickerModal
ref="modal"
:title="$t('createWidgetModal.title')"
:search-placeholder="$t('createWidgetModal.searchPlaceholder')"
:groups="widgetGroups"
>
<template #items="{ items }">
<CreateWidgetCard
v-for="widgetVariation in items"
:key="widgetVariation.name"
:dashboard="dashboard"
:disabled="loading"
:widget-type="widgetVariation.type"
:variation="widgetVariation"
@widget-variation-selected="widgetVariationSelected"
/>
</template>
</ItemPickerModal>
</template>
<script>
import modal from '@baserow/modules/core/mixins/modal'
import ItemPickerModal from '@baserow/modules/core/components/ItemPickerModal'
import CreateWidgetCard from '@baserow/modules/dashboard/components/CreateWidgetCard'
export default {
name: 'CreateWidgetModal',
components: { CreateWidgetCard, ItemPickerModal },
mixins: [modal],
props: {
dashboard: {
type: Object,
required: true,
},
loading: {
type: Boolean,
required: false,
default: false,
},
/** Only offer widgets that show data, for example to be filtered. */
hideFilters: {
type: Boolean,
required: false,
default: false,
},
},
emits: ['widget-variation-selected'],
computed: {
widgetTypes() {
return this.$registry.getOrderedList('dashboardWidget')
},
widgetVariations() {
return this.widgetTypes.reduce((acc, widgetType) => {
return acc.concat(widgetType.variations)
}, [])
},
widgetGroups() {
return [
{
id: 'widgets',
label: this.$t('createWidgetModal.widgets'),
items: this.widgetVariations.filter(
({ type }) => !type.isFilterWidget
),
},
{
id: 'filters',
label: this.$t('createWidgetModal.filters'),
items: this.hideFilters
? []
: this.widgetVariations.filter(({ type }) => type.isFilterWidget),
},
]
},
},
methods: {
widgetVariationSelected(widgetVariation) {
if (this.loading) {
return
}
this.$emit('widget-variation-selected', widgetVariation)
this.hide()
},
},
}
</script>