From 630c7634bcab969407271d33b5fc8772350fff77 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 3 Feb 2023 16:30:52 +0800 Subject: [PATCH] feat(nc-gui): revise attachment filter operators --- 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 0b7c7fa086..be567e79bf 100644 --- a/packages/nc-gui/utils/filterUtils.ts +++ b/packages/nc-gui/utils/filterUtils.ts @@ -28,6 +28,20 @@ const getNeqText = (fieldUiType: UITypes) => { return 'is not equal' } +const getLikeText = (fieldUiType: UITypes) => { + if (UITypes.Attachment) { + return 'filenames contain' + } + return 'is like' +} + +const getNotLikeText = (fieldUiType: UITypes) => { + if (UITypes.Attachment) { + return "filenames doesn't contain" + } + return 'is not like' +} + export const comparisonOpList = ( fieldUiType: UITypes, ): { @@ -60,12 +74,12 @@ export const comparisonOpList = ( excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], }, { - text: 'is like', + text: getLikeText(fieldUiType), value: 'like', excludedTypes: [UITypes.Checkbox, UITypes.SingleSelect, UITypes.MultiSelect, UITypes.Collaborator, ...numericUITypes], }, { - text: 'is not like', + text: getNotLikeText(fieldUiType), value: 'nlike', excludedTypes: [UITypes.Checkbox, UITypes.SingleSelect, UITypes.MultiSelect, UITypes.Collaborator, ...numericUITypes], }, @@ -101,13 +115,27 @@ export const comparisonOpList = ( text: 'is null', value: 'null', ignoreVal: true, - excludedTypes: [...numericUITypes, UITypes.Checkbox, UITypes.SingleSelect, UITypes.MultiSelect, UITypes.Collaborator], + excludedTypes: [ + ...numericUITypes, + UITypes.Checkbox, + UITypes.SingleSelect, + UITypes.MultiSelect, + UITypes.Collaborator, + UITypes.Attachment, + ], }, { text: 'is not null', value: 'notnull', ignoreVal: true, - excludedTypes: [...numericUITypes, UITypes.Checkbox, UITypes.SingleSelect, UITypes.MultiSelect, UITypes.Collaborator], + excludedTypes: [ + ...numericUITypes, + UITypes.Checkbox, + UITypes.SingleSelect, + UITypes.MultiSelect, + UITypes.Collaborator, + UITypes.Attachment, + ], }, { text: 'contains all of',