[frontend] Expose clear on the DateRangePicker component
]
];
+ const DEFAULT_RANGE = RANGE_SETS[0][0];
+
@Component({
components: { Datepicker, DropdownPanel, HueButton, HueLink }
})
inline?: boolean;
rangeSets = RANGE_SETS;
- selectedRange: Range = RANGE_SETS[0][0];
+ selectedRange: Range = DEFAULT_RANGE;
customRange: Range = {
title: I18n('Custom Range'),
}
}
+ // TODO: Switch to v-model and value prop
+ clear(): void {
+ if (this.selectedRange !== DEFAULT_RANGE) {
+ this.selectedRange = DEFAULT_RANGE;
+ this.notify();
+ }
+ }
+
setCustomFrom(from?: Date): void {
if (from) {
Vue.set(this.customRange, 'from', from.valueOf());
}
}
- apply(closePanel: () => void): void {
+ notify(): void {
let range: Range;
if (this.selectedRange.custom) {
range = {
};
}
this.$emit('date-range-changed', range);
+ }
+
+ apply(closePanel: () => void): void {
+ this.notify();
closePanel();
}
}
