Browse Source

feat(nc-gui): getEqText & getNeqText

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
2db63b2bd6
  1. 22
      packages/nc-gui/utils/filterUtils.ts

22
packages/nc-gui/utils/filterUtils.ts

@ -10,6 +10,24 @@ const numericUITypes: UITypes[] = [
UITypes.Rollup, UITypes.Rollup,
] ]
const getEqText = (fieldUiType: UITypes) => {
if (numericUITypes.includes(fieldUiType)) {
return '='
} else if ([UITypes.SingleSelect, UITypes.Collaborator].includes(fieldUiType)) {
return 'is'
}
return 'is equal'
}
const getNeqText = (fieldUiType: UITypes) => {
if (numericUITypes.includes(fieldUiType)) {
return '!='
} else if ([UITypes.SingleSelect, UITypes.Collaborator].includes(fieldUiType)) {
return 'is not'
}
return 'is not equal'
}
export const comparisonOpList = ( export const comparisonOpList = (
fieldUiType: UITypes, fieldUiType: UITypes,
): { ): {
@ -32,12 +50,12 @@ export const comparisonOpList = (
includedTypes: [UITypes.Checkbox], includedTypes: [UITypes.Checkbox],
}, },
{ {
text: numericUITypes.includes(fieldUiType) ? '=' : 'is equal', text: getEqText(fieldUiType),
value: 'eq', value: 'eq',
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment],
}, },
{ {
text: numericUITypes.includes(fieldUiType) ? '!=' : 'is not equal', text: getNeqText(fieldUiType),
value: 'neq', value: 'neq',
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment],
}, },

Loading…
Cancel
Save