Browse Source

Merge pull request #7834 from nocodb/nc-fix/7826-created_at-filter

fix: support Date filter operations in where query params for Created…
pull/7835/head
Raju Udava 9 months ago committed by GitHub
parent
commit
b2cec8a6dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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> </div>
<!-- Field Header --> <!-- 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 <component
:is="iconMap.drag" :is="iconMap.drag"
class="nc-form-field-drag-handler flex-none cursor-move !h-4 !w-4 text-gray-600" class="nc-form-field-drag-handler flex-none cursor-move !h-4 !w-4 text-gray-600"
@ -1272,7 +1275,10 @@ useEventListener(
</div> </div>
<!-- Limit options --> <!-- 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"> <div class="flex items-center gap-3">
<a-switch <a-switch
v-model:checked="element.meta.isLimitOption" 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'), [calendarRange.value[0].fk_from_col!.title!]: selectedDate.value.format('YYYY-MM-DD HH:mm:ssZ'),
}, },
} }
emit('newRecord', record) emit('new-record', record)
} }
</script> </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'), [calendarRange.value[0].fk_from_col!.title!]: hour.format('YYYY-MM-DD HH:mm:ssZ'),
}, },
} }
emit('newRecord', record) emit('new-record', record)
} }
</script> </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'), [fromCol.title!]: date.format('YYYY-MM-DD HH:mm:ssZ'),
}, },
} }
emit('newRecord', newRecord) emit('new-record', newRecord)
} }
</script> </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'), [fromCol.title!]: date.format('YYYY-MM-DD HH:mm:ssZ'),
}, },
} }
emits('newRecord', newRecord) emits('new-record', newRecord)
} }
</script> </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'), [fromCol.title!]: date.format('YYYY-MM-DD HH:mm:ssZ'),
}, },
} }
emits('newRecord', newRecord) emits('new-record', newRecord)
} }
</script> </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)` acc += `${acc.length ? '~and' : ''}(${curr.title},gb_null)`
} else if (curr.column_uidt === UITypes.Checkbox) { } else if (curr.column_uidt === UITypes.Checkbox) {
acc += `${acc.length ? '~and' : ''}(${curr.title},${curr.key === GROUP_BY_VARS.TRUE ? 'checked' : 'notchecked'})` 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})` acc += `${acc.length ? '~and' : ''}(${curr.title},eq,exactDate,${curr.key})`
} else if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(curr.column_uidt as UITypes)) { } else if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(curr.column_uidt as UITypes)) {
try { try {

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

@ -70,7 +70,14 @@ const getAvailableRollupForUiType = (type: string) => {
'sumDistinct', 'sumDistinct',
'avgDistinct', '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']; return ['count', 'min', 'max', 'countDistinct'];
} else if ( } 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 (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}'.`); NcError.badRequest(`'${sub_op}' is not supported for UI Type'${uidt}'.`);
} }
if (!COMPARISON_SUB_OPS.includes(sub_op)) { if (!COMPARISON_SUB_OPS.includes(sub_op)) {
@ -6237,7 +6244,7 @@ export function extractCondition(
if (aliasColObjMap[alias]) { if (aliasColObjMap[alias]) {
if ( if (
[UITypes.Date, UITypes.DateTime].includes(aliasColObjMap[alias].uidt) [UITypes.Date, UITypes.DateTime, UITypes.LastModifiedTime, UITypes.CreatedTime].includes(aliasColObjMap[alias].uidt)
) { ) {
value = value?.split(','); value = value?.split(',');
// the first element would be sub_op // the first element would be sub_op

Loading…
Cancel
Save