|
|
@ -1,4 +1,4 @@ |
|
|
|
import { UITypes, isNumericCol, numericUITypes } from 'nocodb-sdk' |
|
|
|
import { UITypes, isDateMonthFormat, isNumericCol, numericUITypes } from 'nocodb-sdk' |
|
|
|
|
|
|
|
|
|
|
|
const getEqText = (fieldUiType: UITypes) => { |
|
|
|
const getEqText = (fieldUiType: UITypes) => { |
|
|
|
if (isNumericCol(fieldUiType) || fieldUiType === UITypes.Time) { |
|
|
|
if (isNumericCol(fieldUiType) || fieldUiType === UITypes.Time) { |
|
|
@ -70,210 +70,215 @@ const getLteText = (fieldUiType: UITypes) => { |
|
|
|
|
|
|
|
|
|
|
|
export const comparisonOpList = ( |
|
|
|
export const comparisonOpList = ( |
|
|
|
fieldUiType: UITypes, |
|
|
|
fieldUiType: UITypes, |
|
|
|
|
|
|
|
dateFormat?: string, |
|
|
|
): { |
|
|
|
): { |
|
|
|
text: string |
|
|
|
text: string |
|
|
|
value: string |
|
|
|
value: string |
|
|
|
ignoreVal: boolean |
|
|
|
ignoreVal: boolean |
|
|
|
includedTypes?: UITypes[] |
|
|
|
includedTypes?: UITypes[] |
|
|
|
excludedTypes?: UITypes[] |
|
|
|
excludedTypes?: UITypes[] |
|
|
|
}[] => [ |
|
|
|
}[] => { |
|
|
|
{ |
|
|
|
const isDateMonth = dateFormat && isDateMonthFormat(dateFormat) |
|
|
|
text: 'is checked', |
|
|
|
return [ |
|
|
|
value: 'checked', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is checked', |
|
|
|
includedTypes: [UITypes.Checkbox], |
|
|
|
value: 'checked', |
|
|
|
}, |
|
|
|
ignoreVal: true, |
|
|
|
{ |
|
|
|
includedTypes: [UITypes.Checkbox], |
|
|
|
text: 'is not checked', |
|
|
|
}, |
|
|
|
value: 'notchecked', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is not checked', |
|
|
|
includedTypes: [UITypes.Checkbox], |
|
|
|
value: 'notchecked', |
|
|
|
}, |
|
|
|
ignoreVal: true, |
|
|
|
{ |
|
|
|
includedTypes: [UITypes.Checkbox], |
|
|
|
text: getEqText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'eq', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getEqText(fieldUiType), |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], |
|
|
|
value: 'eq', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], |
|
|
|
text: getNeqText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'neq', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getNeqText(fieldUiType), |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], |
|
|
|
value: 'neq', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.MultiSelect, UITypes.Attachment], |
|
|
|
text: getLikeText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'like', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getLikeText(fieldUiType), |
|
|
|
excludedTypes: [ |
|
|
|
value: 'like', |
|
|
|
UITypes.Checkbox, |
|
|
|
ignoreVal: false, |
|
|
|
UITypes.SingleSelect, |
|
|
|
excludedTypes: [ |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.Checkbox, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.SingleSelect, |
|
|
|
UITypes.Date, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.DateTime, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.Time, |
|
|
|
UITypes.Date, |
|
|
|
...numericUITypes, |
|
|
|
UITypes.DateTime, |
|
|
|
], |
|
|
|
UITypes.Time, |
|
|
|
}, |
|
|
|
...numericUITypes, |
|
|
|
{ |
|
|
|
], |
|
|
|
text: getNotLikeText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'nlike', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getNotLikeText(fieldUiType), |
|
|
|
excludedTypes: [ |
|
|
|
value: 'nlike', |
|
|
|
UITypes.Checkbox, |
|
|
|
ignoreVal: false, |
|
|
|
UITypes.SingleSelect, |
|
|
|
excludedTypes: [ |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.Checkbox, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.SingleSelect, |
|
|
|
UITypes.Date, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.DateTime, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.Time, |
|
|
|
UITypes.Date, |
|
|
|
...numericUITypes, |
|
|
|
UITypes.DateTime, |
|
|
|
], |
|
|
|
UITypes.Time, |
|
|
|
}, |
|
|
|
...numericUITypes, |
|
|
|
{ |
|
|
|
], |
|
|
|
text: 'is empty', |
|
|
|
}, |
|
|
|
value: 'empty', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is empty', |
|
|
|
excludedTypes: [ |
|
|
|
value: 'empty', |
|
|
|
UITypes.Checkbox, |
|
|
|
ignoreVal: true, |
|
|
|
UITypes.SingleSelect, |
|
|
|
excludedTypes: [ |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.Checkbox, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.SingleSelect, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.Date, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.DateTime, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Time, |
|
|
|
UITypes.Date, |
|
|
|
...numericUITypes, |
|
|
|
UITypes.DateTime, |
|
|
|
], |
|
|
|
UITypes.Time, |
|
|
|
}, |
|
|
|
...numericUITypes, |
|
|
|
{ |
|
|
|
], |
|
|
|
text: 'is not empty', |
|
|
|
}, |
|
|
|
value: 'notempty', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is not empty', |
|
|
|
excludedTypes: [ |
|
|
|
value: 'notempty', |
|
|
|
UITypes.Checkbox, |
|
|
|
ignoreVal: true, |
|
|
|
UITypes.SingleSelect, |
|
|
|
excludedTypes: [ |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.Checkbox, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.SingleSelect, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.Date, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.DateTime, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Time, |
|
|
|
UITypes.Date, |
|
|
|
...numericUITypes, |
|
|
|
UITypes.DateTime, |
|
|
|
], |
|
|
|
UITypes.Time, |
|
|
|
}, |
|
|
|
...numericUITypes, |
|
|
|
{ |
|
|
|
], |
|
|
|
text: 'is null', |
|
|
|
}, |
|
|
|
value: 'null', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is null', |
|
|
|
excludedTypes: [ |
|
|
|
value: 'null', |
|
|
|
...numericUITypes, |
|
|
|
ignoreVal: true, |
|
|
|
UITypes.Checkbox, |
|
|
|
excludedTypes: [ |
|
|
|
UITypes.SingleSelect, |
|
|
|
...numericUITypes, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.Checkbox, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.SingleSelect, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.Date, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.DateTime, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Time, |
|
|
|
UITypes.Date, |
|
|
|
], |
|
|
|
UITypes.DateTime, |
|
|
|
}, |
|
|
|
UITypes.Time, |
|
|
|
{ |
|
|
|
], |
|
|
|
text: 'is not null', |
|
|
|
}, |
|
|
|
value: 'notnull', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is not null', |
|
|
|
excludedTypes: [ |
|
|
|
value: 'notnull', |
|
|
|
...numericUITypes, |
|
|
|
ignoreVal: true, |
|
|
|
UITypes.Checkbox, |
|
|
|
excludedTypes: [ |
|
|
|
UITypes.SingleSelect, |
|
|
|
...numericUITypes, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.Checkbox, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.SingleSelect, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.MultiSelect, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.Collaborator, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Attachment, |
|
|
|
UITypes.Date, |
|
|
|
UITypes.LinkToAnotherRecord, |
|
|
|
UITypes.DateTime, |
|
|
|
UITypes.Lookup, |
|
|
|
UITypes.Time, |
|
|
|
UITypes.Date, |
|
|
|
], |
|
|
|
UITypes.DateTime, |
|
|
|
}, |
|
|
|
UITypes.Time, |
|
|
|
{ |
|
|
|
], |
|
|
|
text: 'contains all of', |
|
|
|
}, |
|
|
|
value: 'allof', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: 'contains all of', |
|
|
|
includedTypes: [UITypes.MultiSelect], |
|
|
|
value: 'allof', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [UITypes.MultiSelect], |
|
|
|
text: 'contains any of', |
|
|
|
}, |
|
|
|
value: 'anyof', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: 'contains any of', |
|
|
|
includedTypes: [UITypes.MultiSelect, UITypes.SingleSelect], |
|
|
|
value: 'anyof', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [UITypes.MultiSelect, UITypes.SingleSelect], |
|
|
|
text: 'does not contain all of', |
|
|
|
}, |
|
|
|
value: 'nallof', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: 'does not contain all of', |
|
|
|
includedTypes: [UITypes.MultiSelect], |
|
|
|
value: 'nallof', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [UITypes.MultiSelect], |
|
|
|
text: 'does not contain any of', |
|
|
|
}, |
|
|
|
value: 'nanyof', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: 'does not contain any of', |
|
|
|
includedTypes: [UITypes.MultiSelect, UITypes.SingleSelect], |
|
|
|
value: 'nanyof', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [UITypes.MultiSelect, UITypes.SingleSelect], |
|
|
|
text: getGtText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'gt', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getGtText(fieldUiType), |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
value: 'gt', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
text: getLtText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'lt', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getLtText(fieldUiType), |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
value: 'lt', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
text: getGteText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'gte', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getGteText(fieldUiType), |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
value: 'gte', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
text: getLteText(fieldUiType), |
|
|
|
}, |
|
|
|
value: 'lte', |
|
|
|
{ |
|
|
|
ignoreVal: false, |
|
|
|
text: getLteText(fieldUiType), |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
value: 'lte', |
|
|
|
}, |
|
|
|
ignoreVal: false, |
|
|
|
{ |
|
|
|
includedTypes: [...numericUITypes, UITypes.Date, UITypes.DateTime, UITypes.Time], |
|
|
|
text: 'is within', |
|
|
|
}, |
|
|
|
value: 'isWithin', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is within', |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
value: 'isWithin', |
|
|
|
}, |
|
|
|
ignoreVal: true, |
|
|
|
{ |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
text: 'is blank', |
|
|
|
}, |
|
|
|
value: 'blank', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is blank', |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.Links, UITypes.Rollup], |
|
|
|
value: 'blank', |
|
|
|
}, |
|
|
|
ignoreVal: true, |
|
|
|
{ |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.Links, UITypes.Rollup], |
|
|
|
text: 'is not blank', |
|
|
|
}, |
|
|
|
value: 'notblank', |
|
|
|
{ |
|
|
|
ignoreVal: true, |
|
|
|
text: 'is not blank', |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.Links, UITypes.Rollup], |
|
|
|
value: 'notblank', |
|
|
|
}, |
|
|
|
ignoreVal: true, |
|
|
|
] |
|
|
|
excludedTypes: [UITypes.Checkbox, UITypes.Links, UITypes.Rollup], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const comparisonSubOpList = ( |
|
|
|
export const comparisonSubOpList = ( |
|
|
|
// TODO: type
|
|
|
|
// TODO: type
|
|
|
|
comparison_op: string, |
|
|
|
comparison_op: string, |
|
|
|
|
|
|
|
dateFormat?: string, |
|
|
|
): { |
|
|
|
): { |
|
|
|
text: string |
|
|
|
text: string |
|
|
|
value: string |
|
|
|
value: string |
|
|
@ -281,6 +286,8 @@ export const comparisonSubOpList = ( |
|
|
|
includedTypes?: UITypes[] |
|
|
|
includedTypes?: UITypes[] |
|
|
|
excludedTypes?: UITypes[] |
|
|
|
excludedTypes?: UITypes[] |
|
|
|
}[] => { |
|
|
|
}[] => { |
|
|
|
|
|
|
|
const isDateMonth = dateFormat && isDateMonthFormat(dateFormat) |
|
|
|
|
|
|
|
|
|
|
|
if (comparison_op === 'isWithin') { |
|
|
|
if (comparison_op === 'isWithin') { |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
{ |
|
|
|
{ |
|
|
@ -338,31 +345,31 @@ export const comparisonSubOpList = ( |
|
|
|
text: 'today', |
|
|
|
text: 'today', |
|
|
|
value: 'today', |
|
|
|
value: 'today', |
|
|
|
ignoreVal: true, |
|
|
|
ignoreVal: true, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'tomorrow', |
|
|
|
text: 'tomorrow', |
|
|
|
value: 'tomorrow', |
|
|
|
value: 'tomorrow', |
|
|
|
ignoreVal: true, |
|
|
|
ignoreVal: true, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'yesterday', |
|
|
|
text: 'yesterday', |
|
|
|
value: 'yesterday', |
|
|
|
value: 'yesterday', |
|
|
|
ignoreVal: true, |
|
|
|
ignoreVal: true, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'one week ago', |
|
|
|
text: 'one week ago', |
|
|
|
value: 'oneWeekAgo', |
|
|
|
value: 'oneWeekAgo', |
|
|
|
ignoreVal: true, |
|
|
|
ignoreVal: true, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'one week from now', |
|
|
|
text: 'one week from now', |
|
|
|
value: 'oneWeekFromNow', |
|
|
|
value: 'oneWeekFromNow', |
|
|
|
ignoreVal: true, |
|
|
|
ignoreVal: true, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'one month ago', |
|
|
|
text: 'one month ago', |
|
|
@ -380,16 +387,16 @@ export const comparisonSubOpList = ( |
|
|
|
text: 'number of days ago', |
|
|
|
text: 'number of days ago', |
|
|
|
value: 'daysAgo', |
|
|
|
value: 'daysAgo', |
|
|
|
ignoreVal: false, |
|
|
|
ignoreVal: false, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'number of days from now', |
|
|
|
text: 'number of days from now', |
|
|
|
value: 'daysFromNow', |
|
|
|
value: 'daysFromNow', |
|
|
|
ignoreVal: false, |
|
|
|
ignoreVal: false, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [...(isDateMonth ? [] : [UITypes.Date, UITypes.DateTime])], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
text: 'exact date', |
|
|
|
text: isDateMonth ? 'exact month' : 'exact date', |
|
|
|
value: 'exactDate', |
|
|
|
value: 'exactDate', |
|
|
|
ignoreVal: false, |
|
|
|
ignoreVal: false, |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|
includedTypes: [UITypes.Date, UITypes.DateTime], |
|
|
|