From 520039c0c7b496668d8ac599e6b83ce3f12c5e19 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 22 Feb 2023 17:41:07 +0800 Subject: [PATCH] feat(nc-gui): render >, <, >=, <= text based on field ui type --- packages/nc-gui/utils/filterUtils.ts | 36 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/utils/filterUtils.ts b/packages/nc-gui/utils/filterUtils.ts index 22e78dd45d..8074d693b0 100644 --- a/packages/nc-gui/utils/filterUtils.ts +++ b/packages/nc-gui/utils/filterUtils.ts @@ -32,6 +32,34 @@ const getNotLikeText = (fieldUiType: UITypes) => { return 'is not like' } +const getGtText = (fieldUiType: UITypes) => { + if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { + return 'is after' + } + return '>' +} + +const getLtText = (fieldUiType: UITypes) => { + if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { + return 'is before' + } + return '<' +} + +const getGteText = (fieldUiType: UITypes) => { + if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { + return 'is on or after' + } + return '>=' +} + +const getLteText = (fieldUiType: UITypes) => { + if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { + return 'is on or before' + } + return '<=' +} + export const comparisonOpList = ( fieldUiType: UITypes, ): { @@ -154,22 +182,22 @@ export const comparisonOpList = ( includedTypes: [UITypes.MultiSelect, UITypes.SingleSelect], }, { - text: '>', + text: getGtText(fieldUiType), value: 'gt', includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime], }, { - text: '<', + text: getLtText(fieldUiType), value: 'lt', includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime], }, { - text: '>=', + text: getGteText(fieldUiType), value: 'gte', includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime], }, { - text: '<=', + text: getLteText(fieldUiType), value: 'lte', includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime], },