From 8d00d85a31dffd5f4206ddc7729eb6f7a3c4acdf Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 6 Jan 2024 08:47:49 +0000 Subject: [PATCH] fix: group by and copy for RO user fields --- .../nc-gui/composables/useMultiSelect/index.ts | 14 ++++++++------ packages/nc-gui/composables/useViewGroupBy.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/composables/useMultiSelect/index.ts b/packages/nc-gui/composables/useMultiSelect/index.ts index e8974573e1..7388e851f2 100644 --- a/packages/nc-gui/composables/useMultiSelect/index.ts +++ b/packages/nc-gui/composables/useMultiSelect/index.ts @@ -113,12 +113,14 @@ export function useMultiSelect( } if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(columnObj.uidt as UITypes)) { - if (textToCopy && Array.isArray(textToCopy)) { - textToCopy = textToCopy - .map((user: UserFieldRecordType) => { - return user.email - }) - .join(', ') + if (textToCopy) { + textToCopy = Array.isArray(textToCopy) + ? textToCopy + : [textToCopy] + .map((user: UserFieldRecordType) => { + return user.email + }) + .join(', ') } } diff --git a/packages/nc-gui/composables/useViewGroupBy.ts b/packages/nc-gui/composables/useViewGroupBy.ts index 8574c84018..ff099c8166 100644 --- a/packages/nc-gui/composables/useViewGroupBy.ts +++ b/packages/nc-gui/composables/useViewGroupBy.ts @@ -164,8 +164,12 @@ export const useViewGroupBy = (view: Ref, where?: Computed } else if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(curr.column_uidt as UITypes)) { try { const value = JSON.parse(curr.key) - acc += `${acc.length ? '~and' : ''}(${curr.title},gb_eq,${value.map((v: any) => v.id).join(',')})` - } catch (e) {} + acc += `${acc.length ? '~and' : ''}(${curr.title},gb_eq,${(Array.isArray(value) ? value : [value]) + .map((v: any) => v.id) + .join(',')})` + } catch (e) { + console.error(e) + } } else { acc += `${acc.length ? '~and' : ''}(${curr.title},gb_eq,${curr.key})` }