mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 00:38:35 +00:00
* 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>
114 lines
3.1 KiB
Vue
114 lines
3.1 KiB
Vue
<template>
|
|
<div>
|
|
<WidgetSettingsBaseForm
|
|
ref="form"
|
|
:widget="widget"
|
|
:default-values="widget"
|
|
@values-changed="baseFormValuesChanged($event)"
|
|
/>
|
|
<component
|
|
:is="widgetSettingsComponent"
|
|
ref="settings"
|
|
:dashboard="dashboard"
|
|
:widget="widget"
|
|
:store-prefix="storePrefix"
|
|
:small="small"
|
|
:show-own-filters="showOwnFilters"
|
|
:link-filter-widget-id="linkFilterWidgetId"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { computed } from 'vue'
|
|
import _ from 'lodash'
|
|
import DashboardFormulaInput from '@baserow/modules/dashboard/components/DashboardFormulaInput'
|
|
import WidgetSettingsBaseForm from '@baserow/modules/dashboard/components/widget/WidgetSettingsBaseForm'
|
|
import { notifyIf } from '@baserow/modules/core/utils/error'
|
|
|
|
export default {
|
|
name: 'WidgetSettings',
|
|
components: { WidgetSettingsBaseForm },
|
|
provide() {
|
|
return {
|
|
formulaComponent: DashboardFormulaInput,
|
|
dataProvidersAllowed: [],
|
|
dashboardFormulaContext: computed(() => ({
|
|
dashboard: this.dashboard,
|
|
storePrefix: this.storePrefix,
|
|
})),
|
|
}
|
|
},
|
|
props: {
|
|
linkFilterWidgetId: { type: Number, default: null },
|
|
/** Whether the widget's own filter conditions can be edited here. */
|
|
showOwnFilters: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
small: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
dashboard: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
widget: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
storePrefix: {
|
|
type: String,
|
|
required: false,
|
|
default: '',
|
|
},
|
|
},
|
|
computed: {
|
|
widgetType() {
|
|
return this.$registry.get('dashboardWidget', this.widget.type)
|
|
},
|
|
widgetSettingsComponent() {
|
|
return this.widgetType.settingsComponent
|
|
},
|
|
},
|
|
methods: {
|
|
/** Validate the same title and data settings used by the sidebar. */
|
|
validate() {
|
|
this.$refs.form.touch()
|
|
const valid = this.$refs.form.isFormValid()
|
|
if (!valid) this.$refs.form.focusOnFirstError()
|
|
const settingsValid = this.$refs.settings?.validate?.() ?? true
|
|
return valid && settingsValid
|
|
},
|
|
async baseFormValuesChanged(values) {
|
|
if (this.$refs.form.isFormValid()) {
|
|
const defaultValues = this.$refs.form.defaultValues
|
|
const originalValues = JSON.parse(JSON.stringify(defaultValues))
|
|
const defaultWithUpdatedValues = { ...defaultValues, ...values }
|
|
|
|
// Compute only the values in the form that has been actually
|
|
// changed
|
|
const updatedValues = Object.fromEntries(
|
|
Object.entries(defaultWithUpdatedValues).filter(
|
|
([key, value]) => !_.isEqual(value, defaultValues[key])
|
|
)
|
|
)
|
|
try {
|
|
await this.$store.dispatch(
|
|
`${this.storePrefix}dashboardApplication/updateWidget`,
|
|
{
|
|
widgetId: this.widget.id,
|
|
values: updatedValues,
|
|
originalValues,
|
|
}
|
|
)
|
|
} catch (error) {
|
|
notifyIf(error, 'dashboard')
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|