mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* fix: handle calendar boundaries in date comparisons * feat: add a single-date filter to the dashboard API * feat: send the viewer timezone with dashboard data requests * refactor: share dashboard filter controls and target settings * feat: configure dashboard filter conditions on date fields * feat: add the Date filter to the dashboard widget picker Implement the single-date mode of #6886. * fix: restore dragging dashboard filters by their titles * feat: persist the dashboard date filter display format * feat: choose how dashboard filter dates are displayed * test: align numeric filter checks with shared dashboard controls * style: format the dashboard date filter component test * fix: accept fixed UTC offsets in dashboard date filters * fix: expose dashboard filter dates as ISO strings in formulas * fix: seed dashboard conditions with compatible operators * feat: expose date ranges in dashboard formulas and viewer selections * feat: configure inclusive date range conditions for dashboard targets * feat: persist and dispatch inclusive dashboard date ranges * docs: describe date range selections in the dashboard dispatch API * feat: select and configure dashboard date ranges * fix: let viewers clear each dashboard date range endpoint * fix: preserve unfinished dashboard date range bounds on refresh * fix: refresh public dashboards after a date filter mode change * test: group dashboard date filter mode transitions * fix: warn about incompatible date range formula operands * fix: convert dashboard date defaults from the saved widget * fix: keep dashboard filter controls aligned when a condition has a warning * fix: clear incompatible dashboard conditions when switching date modes * fix: show cleared date conditions without warnings or redundant saves * fix: ignore empty dashboard date conditions after switching modes * fix: ignore dashboard date conditions without a single date and simplify mode switch clearing --------- Co-authored-by: peter_baserow <peter@baserow.io>
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
import isEqual from 'lodash/isEqual'
|
|
|
|
/** Viewer values changed automatically by an optimistic widget settings save. */
|
|
export class WidgetValueUpdate {
|
|
constructor(previousValue, updatedValue, selection) {
|
|
this.originalValue = previousValue
|
|
this.updatedValue = updatedValue
|
|
this.selection = selection
|
|
}
|
|
|
|
merge(previousValue, updatedValue, selection) {
|
|
// A viewer can change the selection between two coalesced settings edits.
|
|
if (selection !== this.selection) {
|
|
this.originalValue = previousValue
|
|
}
|
|
this.updatedValue = updatedValue
|
|
this.selection = selection
|
|
}
|
|
|
|
restore(context, registry, widgetId) {
|
|
const selection = context.state.widgetSelections[widgetId]
|
|
let value
|
|
if (selection !== this.selection) {
|
|
// Preserve later user choices, including a clear, even if restoring the
|
|
// configuration just applied a nonempty default to that empty selection.
|
|
value = selection?.value
|
|
} else {
|
|
if (
|
|
isEqual(this.originalValue, this.updatedValue) ||
|
|
!isEqual(context.state.widgetValues[widgetId], this.updatedValue)
|
|
)
|
|
return
|
|
value = this.originalValue
|
|
}
|
|
const widget = context.state.widgets.find(({ id }) => id === widgetId)
|
|
const type = widget && registry.get('dashboardWidget', widget.type)
|
|
if (type?.isFilterWidget) {
|
|
type.valueChanged(
|
|
widget,
|
|
{ ...context, registry },
|
|
type.normalizeSelection(widget, value)
|
|
)
|
|
}
|
|
}
|
|
}
|