Browse Source

fix: global search, group by, filter

pull/7373/head
mertmit 11 months ago
parent
commit
542b3f135d
  1. 2
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  2. 9
      packages/nc-gui/components/smartsheet/toolbar/FilterInput.vue
  3. 2
      packages/nc-gui/composables/useMultiSelect/index.ts
  4. 8
      packages/nc-gui/composables/useViewGroupBy.ts
  5. 3
      packages/nocodb/src/db/conditionV2.ts

2
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -169,7 +169,7 @@ const parseKey = (group: Group) => {
return [parseStringDateTime(key, timeFormats[0], false)] return [parseStringDateTime(key, timeFormats[0], false)]
} }
if (key && group.column?.uidt === UITypes.User) { if (key && [UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(group.column?.uidt as UITypes)) {
try { try {
const parsedKey = JSON.parse(key) const parsedKey = JSON.parse(key)
return [parsedKey] return [parsedKey]

9
packages/nc-gui/components/smartsheet/toolbar/FilterInput.vue

@ -19,6 +19,7 @@ import {
isPercent, isPercent,
isRating, isRating,
isReadonlyDateTime, isReadonlyDateTime,
isReadonlyUser,
isSingleSelect, isSingleSelect,
isTextArea, isTextArea,
isTime, isTime,
@ -87,6 +88,7 @@ const checkTypeFunctions = {
isTextArea, isTextArea,
isLinks: (col: ColumnType) => col.uidt === UITypes.Links, isLinks: (col: ColumnType) => col.uidt === UITypes.Links,
isUser, isUser,
isReadonlyUser,
} }
type FilterType = keyof typeof checkTypeFunctions type FilterType = keyof typeof checkTypeFunctions
@ -155,6 +157,7 @@ const componentMap: Partial<Record<FilterType, any>> = computed(() => {
isFloat: Float, isFloat: Float,
isLinks: Integer, isLinks: Integer,
isUser: User, isUser: User,
isReadonlyUser: User,
} }
}) })
@ -181,6 +184,12 @@ const componentProps = computed(() => {
case 'isUser': { case 'isUser': {
return { forceMulti: true } return { forceMulti: true }
} }
case 'isReadonlyUser': {
if (['anyof', 'nanyof'].includes(props.filter.comparison_op!)) {
return { forceMulti: true }
}
return {}
}
default: { default: {
return {} return {}
} }

2
packages/nc-gui/composables/useMultiSelect/index.ts

@ -112,7 +112,7 @@ export function useMultiSelect(
textToCopy = !!textToCopy textToCopy = !!textToCopy
} }
if (columnObj.uidt === UITypes.User || columnObj.uidt === UITypes.CreatedBy || columnObj.uidt === UITypes.LastModifiedBy) { if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(columnObj.uidt as UITypes)) {
if (textToCopy && Array.isArray(textToCopy)) { if (textToCopy && Array.isArray(textToCopy)) {
textToCopy = textToCopy textToCopy = textToCopy
.map((user: UserFieldRecordType) => { .map((user: UserFieldRecordType) => {

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

@ -90,7 +90,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
return value ? GROUP_BY_VARS.TRUE : GROUP_BY_VARS.FALSE return value ? GROUP_BY_VARS.TRUE : GROUP_BY_VARS.FALSE
} }
if (col.uidt === UITypes.User || col.uidt === UITypes.CreatedBy || col.uidt === UITypes.LastModifiedBy) { if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(col.uidt as UITypes)) {
if (!value) { if (!value) {
return GROUP_BY_VARS.NULL return GROUP_BY_VARS.NULL
} }
@ -161,11 +161,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
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].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 ( } else if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(curr.column_uidt as UITypes)) {
curr.column_uidt === UITypes.User ||
curr.column_uidt === UITypes.CreatedBy ||
curr.column_uidt === UITypes.LastModifiedBy
) {
try { try {
const value = JSON.parse(curr.key) const value = JSON.parse(curr.key)
acc += `${acc.length ? '~and' : ''}(${curr.title},gb_eq,${value.map((v: any) => v.id).join(',')})` acc += `${acc.length ? '~and' : ''}(${curr.title},gb_eq,${value.map((v: any) => v.id).join(',')})`

3
packages/nocodb/src/db/conditionV2.ts

@ -458,6 +458,9 @@ const parseConditionV2 = async (
) && ) &&
['like', 'nlike'].includes(filter.comparison_op) ['like', 'nlike'].includes(filter.comparison_op)
) { ) {
// get column name for CreatedBy, LastModifiedBy
column.column_name = await getColumnName(column);
const baseUsers = await BaseUser.getUsersList({ const baseUsers = await BaseUser.getUsersList({
base_id: column.base_id, base_id: column.base_id,
}); });

Loading…
Cancel
Save