Files
Jonathan Adelineandpeter_baserow a26c5ce6b0 feat: filter dashboard widgets by date or date range (#6954)
* 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>
2026-12-03 20:40:18 +04:00

182 lines
4.9 KiB
Vue

<template>
<div
class="form-input"
:class="{
'form-input--error': error,
'form-input--monospace': monospace,
'form-input--icon-left': iconLeft,
'form-input--icon-right': iconRight,
'form-input--loading': loading,
'form-input--disabled': disabled,
'form-input--small': size === 'small',
'form-input--large': size === 'large',
'form-input--xlarge': size === 'xlarge',
'form-input--suffix': !!$slots.suffix,
'form-input--no-controls': removeNumberInputControls,
'form-input--can-clear': canClear,
}"
@click="focusOnClick && focus()"
>
<i
v-if="iconLeft"
class="form-input__icon form-input__icon-left"
:class="iconLeft"
/>
<div class="form-input__wrapper">
<input
:id="forInput"
ref="input"
v-pre-hydration-input
class="form-input__input"
:class="{
'form-input__input--text-invisible': textInvisible,
}"
:value="fromValue(innerValue)"
:disabled="disabled"
:type="type"
:min="type === 'number' && min > -1 ? parseInt(min) : false"
:max="type === 'number' && max > -1 ? parseInt(max) : false"
:step="type === 'number' && step > -1 ? parseFloat(step) : false"
:placeholder="placeholder"
:required="required"
:autocomplete="autocomplete"
:maxlength="maxlength"
:aria-invalid="error || undefined"
:aria-describedby="error ? errorDescriptionId : undefined"
@blur="onBlur"
@click="$emit('click', $event)"
@focus="$emit('focus', $event)"
@keyup="$emit('keyup', $event)"
@keydown="$emit('keydown', $event)"
@keypress="$emit('keypress', $event)"
@input.stop="onInput"
@mouseup="$emit('mouseup', $event)"
@mousedown="$emit('mousedown', $event)"
/>
<i
v-if="iconRight"
class="form-input__icon form-input__icon-right"
:class="iconRight"
/>
<a
v-if="canClear"
v-show="fromValue(innerValue) !== ''"
class="form-input__clear"
@click="updateValue('')"
>
<i class="iconoir-cancel"></i>
</a>
</div>
<div v-if="$slots.suffix" class="form-input__suffix">
<slot name="suffix"></slot>
</div>
</div>
</template>
<script setup>
import { ref, inject } from 'vue'
import vPreHydrationInput from '@baserow/modules/core/directives/preHydrationInput'
const props = defineProps({
error: Boolean,
errorDescriptionId: { type: String, default: null },
label: { type: String, default: '' },
size: {
type: String,
default: 'regular',
validator: (v) => ['regular', 'small', 'large', 'xlarge'].includes(v),
},
placeholder: { default: '', type: String },
/* Legacy + new v-model */
value: { default: undefined, validator: () => true },
modelValue: { default: undefined, validator: () => true },
toValue: { type: Function, default: (v) => v },
fromValue: { type: Function, default: (v) => v },
defaultValueWhenEmpty: { type: [Number, String], default: null },
type: { type: String, default: 'text' },
disabled: Boolean,
monospace: Boolean,
loading: Boolean,
iconLeft: { type: String, default: '' },
iconRight: { type: String, default: '' },
required: Boolean,
removeNumberInputControls: Boolean,
autocomplete: { type: String, default: '' },
maxlength: { type: Number, default: null },
min: { type: Number, default: -1 },
max: { type: Number, default: -1 },
step: { type: Number, default: -1 },
focusOnClick: { type: Boolean, default: true },
textInvisible: Boolean,
canClear: { type: Boolean, default: false },
})
const emit = defineEmits([
'input',
'update:modelValue',
'blur',
'click',
'focus',
'keyup',
'keydown',
'keypress',
'mouseup',
'mousedown',
])
const forInput = inject('forInput', null)
const input = ref(null)
/* Keep compat with nuxt2 version */
const innerValue = computed(() =>
props.modelValue !== undefined ? props.modelValue : props.value
)
/* Unified emitter for compat with legacy usages */
function updateValue(raw) {
const converted = props.toValue(raw)
emit('input', converted) // legacy
emit('update:modelValue', converted) // new v-model
}
function onInput(e) {
const raw = e.target.value
if (!raw && props.defaultValueWhenEmpty !== null) return
updateValue(raw)
}
function onBlur(e) {
if (!input.value) {
// The FormInput element was unmounted in the meantime. It happens in the login
// form for instance if you hit enter after filling the form.
return
}
const raw = input.value.value
if (!raw && props.defaultValueWhenEmpty !== null) {
input.value.value = props.defaultValueWhenEmpty
updateValue(props.defaultValueWhenEmpty)
}
emit('blur', e)
}
function focus() {
input.value?.focus()
}
function blur() {
input.value?.blur()
}
defineExpose({ focus, blur })
</script>