Browse Source

fix: show datetime related labels for created/latstmodified fields

pull/7574/head
Pranav C 5 months ago
parent
commit
0ffaed55dd
  1. 53
      packages/nc-gui/utils/filterUtils.ts

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

@ -4,9 +4,15 @@ const getEqText = (fieldUiType: UITypes) => {
if (isNumericCol(fieldUiType) || fieldUiType === UITypes.Time) { if (isNumericCol(fieldUiType) || fieldUiType === UITypes.Time) {
return '=' return '='
} else if ( } else if (
[UITypes.SingleSelect, UITypes.Collaborator, UITypes.LinkToAnotherRecord, UITypes.Date, UITypes.DateTime].includes( [
fieldUiType, UITypes.SingleSelect,
) UITypes.Collaborator,
UITypes.LinkToAnotherRecord,
UITypes.Date,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.DateTime,
].includes(fieldUiType)
) { ) {
return 'is' return 'is'
} }
@ -17,9 +23,15 @@ const getNeqText = (fieldUiType: UITypes) => {
if (isNumericCol(fieldUiType) || fieldUiType === UITypes.Time) { if (isNumericCol(fieldUiType) || fieldUiType === UITypes.Time) {
return '!=' return '!='
} else if ( } else if (
[UITypes.SingleSelect, UITypes.Collaborator, UITypes.LinkToAnotherRecord, UITypes.Date, UITypes.DateTime].includes( [
fieldUiType, UITypes.SingleSelect,
) UITypes.Collaborator,
UITypes.LinkToAnotherRecord,
UITypes.Date,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.DateTime,
].includes(fieldUiType)
) { ) {
return 'is not' return 'is not'
} }
@ -41,28 +53,28 @@ const getNotLikeText = (fieldUiType: UITypes) => {
} }
const getGtText = (fieldUiType: UITypes) => { const getGtText = (fieldUiType: UITypes) => {
if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { if ([UITypes.Date, UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(fieldUiType)) {
return 'is after' return 'is after'
} }
return '>' return '>'
} }
const getLtText = (fieldUiType: UITypes) => { const getLtText = (fieldUiType: UITypes) => {
if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { if ([UITypes.Date, UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(fieldUiType)) {
return 'is before' return 'is before'
} }
return '<' return '<'
} }
const getGteText = (fieldUiType: UITypes) => { const getGteText = (fieldUiType: UITypes) => {
if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { if ([UITypes.Date, UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(fieldUiType)) {
return 'is on or after' return 'is on or after'
} }
return '>=' return '>='
} }
const getLteText = (fieldUiType: UITypes) => { const getLteText = (fieldUiType: UITypes) => {
if ([UITypes.Date, UITypes.DateTime].includes(fieldUiType)) { if ([UITypes.Date, UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(fieldUiType)) {
return 'is on or before' return 'is on or before'
} }
return '<=' return '<='
@ -131,6 +143,8 @@ export const comparisonOpList = (
UITypes.Collaborator, UITypes.Collaborator,
UITypes.Date, UITypes.Date,
UITypes.DateTime, UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Time, UITypes.Time,
...numericUITypes, ...numericUITypes,
], ],
@ -149,6 +163,8 @@ export const comparisonOpList = (
UITypes.Collaborator, UITypes.Collaborator,
UITypes.Date, UITypes.Date,
UITypes.DateTime, UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Time, UITypes.Time,
...numericUITypes, ...numericUITypes,
], ],
@ -170,6 +186,8 @@ export const comparisonOpList = (
UITypes.Lookup, UITypes.Lookup,
UITypes.Date, UITypes.Date,
UITypes.DateTime, UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Time, UITypes.Time,
...numericUITypes, ...numericUITypes,
], ],
@ -191,6 +209,8 @@ export const comparisonOpList = (
UITypes.Lookup, UITypes.Lookup,
UITypes.Date, UITypes.Date,
UITypes.DateTime, UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Time, UITypes.Time,
...numericUITypes, ...numericUITypes,
], ],
@ -213,6 +233,8 @@ export const comparisonOpList = (
UITypes.Lookup, UITypes.Lookup,
UITypes.Date, UITypes.Date,
UITypes.DateTime, UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Time, UITypes.Time,
], ],
}, },
@ -234,6 +256,8 @@ export const comparisonOpList = (
UITypes.Lookup, UITypes.Lookup,
UITypes.Date, UITypes.Date,
UITypes.DateTime, UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Time, UITypes.Time,
], ],
}, },
@ -304,7 +328,14 @@ export const comparisonOpList = (
text: getLteText(fieldUiType), text: getLteText(fieldUiType),
value: 'lte', value: 'lte',
ignoreVal: false, ignoreVal: false,
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], includedTypes: [
...numericUITypes,
UITypes.Date,
UITypes.DateTime,
UITypes.Time,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
],
}, },
{ {
text: 'is within', text: 'is within',

Loading…
Cancel
Save