Browse Source

fix: support Date filter operations in where query params for Created/LastModified time fields

pull/7834/head
Pranav C 4 months ago
parent
commit
6823ab5006
  1. 10
      packages/nc-gui/components/smartsheet/Form.vue
  2. 2
      packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue
  3. 2
      packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue
  4. 2
      packages/nc-gui/components/smartsheet/calendar/MonthView.vue
  5. 2
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue
  6. 2
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue
  7. 4
      packages/nc-gui/composables/useViewGroupBy.ts
  8. 9
      packages/nocodb-sdk/src/lib/helperFunctions.ts
  9. 11
      packages/nocodb/src/db/BaseModelSqlv2.ts

10
packages/nc-gui/components/smartsheet/Form.vue

@ -1088,7 +1088,10 @@ useEventListener(
</div>
<!-- Field Header -->
<div v-if="activeRow === element.title" class="w-full flex gap-3 items-center px-3 py-2 bg-gray-50 border-b-1 border-gray-200">
<div
v-if="activeRow === element.title"
class="w-full flex gap-3 items-center px-3 py-2 bg-gray-50 border-b-1 border-gray-200"
>
<component
:is="iconMap.drag"
class="nc-form-field-drag-handler flex-none cursor-move !h-4 !w-4 text-gray-600"
@ -1272,7 +1275,10 @@ useEventListener(
</div>
<!-- Limit options -->
<div v-if="isSelectTypeCol(element.uidt)" class="px-3 py-2 border-1 border-gray-200 rounded-lg bg-white">
<div
v-if="isSelectTypeCol(element.uidt)"
class="px-3 py-2 border-1 border-gray-200 rounded-lg bg-white"
>
<div class="flex items-center gap-3">
<a-switch
v-model:checked="element.meta.isLimitOption"

2
packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue

@ -192,7 +192,7 @@ const newRecord = () => {
[calendarRange.value[0].fk_from_col!.title!]: selectedDate.value.format('YYYY-MM-DD HH:mm:ssZ'),
},
}
emit('newRecord', record)
emit('new-record', record)
}
</script>

2
packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue

@ -847,7 +847,7 @@ const newRecord = (hour: dayjs.Dayjs) => {
[calendarRange.value[0].fk_from_col!.title!]: hour.format('YYYY-MM-DD HH:mm:ssZ'),
},
}
emit('newRecord', record)
emit('new-record', record)
}
</script>

2
packages/nc-gui/components/smartsheet/calendar/MonthView.vue

@ -635,7 +635,7 @@ const addRecord = (date: dayjs.Dayjs) => {
[fromCol.title!]: date.format('YYYY-MM-DD HH:mm:ssZ'),
},
}
emit('newRecord', newRecord)
emit('new-record', newRecord)
}
</script>

2
packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue

@ -529,7 +529,7 @@ const addRecord = (date: dayjs.Dayjs) => {
[fromCol.title!]: date.format('YYYY-MM-DD HH:mm:ssZ'),
},
}
emits('newRecord', newRecord)
emits('new-record', newRecord)
}
</script>

2
packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue

@ -733,7 +733,7 @@ const addRecord = (date: dayjs.Dayjs) => {
[fromCol.title!]: date.format('YYYY-MM-DD HH:mm:ssZ'),
},
}
emits('newRecord', newRecord)
emits('new-record', newRecord)
}
</script>

4
packages/nc-gui/composables/useViewGroupBy.ts

@ -161,7 +161,9 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
acc += `${acc.length ? '~and' : ''}(${curr.title},gb_null)`
} else if (curr.column_uidt === UITypes.Checkbox) {
acc += `${acc.length ? '~and' : ''}(${curr.title},${curr.key === GROUP_BY_VARS.TRUE ? 'checked' : 'notchecked'})`
} else if ([UITypes.Date, UITypes.DateTime].includes(curr.column_uidt as UITypes)) {
} else if (
[UITypes.Date, UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(curr.column_uidt as UITypes)
) {
acc += `${acc.length ? '~and' : ''}(${curr.title},eq,exactDate,${curr.key})`
} else if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(curr.column_uidt as UITypes)) {
try {

9
packages/nocodb-sdk/src/lib/helperFunctions.ts

@ -70,7 +70,14 @@ const getAvailableRollupForUiType = (type: string) => {
'sumDistinct',
'avgDistinct',
];
} else if ([UITypes.Date, UITypes.DateTime].includes(type as UITypes)) {
} else if (
[
UITypes.Date,
UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
].includes(type as UITypes)
) {
return ['count', 'min', 'max', 'countDistinct'];
} else if (
[

11
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -6181,7 +6181,14 @@ function validateFilterComparison(uidt: UITypes, op: any, sub_op?: any) {
}
if (sub_op) {
if (![UITypes.Date, UITypes.DateTime].includes(uidt)) {
if (
![
UITypes.Date,
UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
].includes(uidt)
) {
NcError.badRequest(`'${sub_op}' is not supported for UI Type'${uidt}'.`);
}
if (!COMPARISON_SUB_OPS.includes(sub_op)) {
@ -6237,7 +6244,7 @@ export function extractCondition(
if (aliasColObjMap[alias]) {
if (
[UITypes.Date, UITypes.DateTime].includes(aliasColObjMap[alias].uidt)
[UITypes.Date, UITypes.DateTime, UITypes.LastModifiedTime, UITypes.CreatedTime].includes(aliasColObjMap[alias].uidt)
) {
value = value?.split(',');
// the first element would be sub_op

Loading…
Cancel
Save