Fixed relative date filter initalization (#12811)
This PR fixes problems with date filter : - Filter chip shows the label with plural, ex : `This weeks` - Using a relative filter now initializes to `This day` - Switching between the different relative sub-operands (This, Past, Next) now initializes with a value so we're never in an "empty" state.
This commit is contained in:
@ -7,4 +7,14 @@ export const computeVariableDateViewFilterValue = (
|
||||
direction: VariableDateViewFilterValueDirection,
|
||||
amount: number | undefined,
|
||||
unit: VariableDateViewFilterValueUnit,
|
||||
) => `${direction}_${amount?.toString()}_${unit}`;
|
||||
) => {
|
||||
if (direction === 'THIS') {
|
||||
return `THIS_1_${unit}`;
|
||||
} else if (amount === undefined || amount <= 0) {
|
||||
throw new Error(
|
||||
'Amount must be defined and greater than 0 for relative date filters',
|
||||
);
|
||||
}
|
||||
|
||||
return `${direction}_${amount.toString()}_${unit}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user