Browse Source

refactor: use title in group by request

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6489/head
Pranav C 1 year ago
parent
commit
c4c351a210
  1. 14
      packages/nc-gui/composables/useViewGroupBy.ts

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

@ -164,7 +164,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
const groupby = groupBy.value[group.nestedIn.length] const groupby = groupBy.value[group.nestedIn.length]
const nestedWhere = calculateNestedWhere(group.nestedIn, where?.value) const nestedWhere = calculateNestedWhere(group.nestedIn, where?.value)
if (!groupby || !(groupby.column.column_name || groupby.column.title)) return if (!groupby || !(groupby.column.title)) return
if (isPublic.value && !sharedView.value?.uuid) { if (isPublic.value && !sharedView.value?.uuid) {
return return
@ -179,7 +179,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
where: `${nestedWhere}`, where: `${nestedWhere}`,
sort: `${groupby.sort === 'desc' ? '-' : ''}${groupby.column.title}`, sort: `${groupby.sort === 'desc' ? '-' : ''}${groupby.column.title}`,
column_name: groupby.column.column_name || groupby.column.title, column_name: groupby.column.title,
} as any) } as any)
: await api.public.dataGroupBy(sharedView.value!.uuid!, { : await api.public.dataGroupBy(sharedView.value!.uuid!, {
offset: ((group.paginationData.page ?? 0) - 1) * (group.paginationData.pageSize ?? groupByLimit), offset: ((group.paginationData.page ?? 0) - 1) * (group.paginationData.pageSize ?? groupByLimit),
@ -187,7 +187,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
...params, ...params,
where: nestedWhere, where: nestedWhere,
sort: `${groupby.sort === 'desc' ? '-' : ''}${groupby.column.title}`, sort: `${groupby.sort === 'desc' ? '-' : ''}${groupby.column.title}`,
column_name: groupby.column.column_name || groupby.column.title, column_name: groupby.column.title,
sortsArr: sorts.value, sortsArr: sorts.value,
filtersArr: nestedFilters.value, filtersArr: nestedFilters.value,
}) })
@ -203,16 +203,16 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
} }
if (groupby.column.title && groupby.column.uidt) { if (groupby.column.title && groupby.column.uidt) {
acc.push({ acc.push({
key: valueToTitle(curr[(groupby.column.column_name || groupby.column.title)!], groupby.column), key: valueToTitle(curr[(groupby.column.title)!], groupby.column),
column: groupby.column, column: groupby.column,
count: +curr.count, count: +curr.count,
color: findKeyColor(curr[(groupby.column.column_name || groupby.column.title)!], groupby.column), color: findKeyColor(curr[(groupby.column.title)!], groupby.column),
nestedIn: [ nestedIn: [
...group!.nestedIn, ...group!.nestedIn,
{ {
title: groupby.column.title, title: groupby.column.title,
column_name: (groupby.column.column_name || groupby.column.title)!, column_name: (groupby.column.title)!,
key: valueToTitle(curr[(groupby.column.column_name || groupby.column.title)!], groupby.column), key: valueToTitle(curr[(groupby.column.title)!], groupby.column),
column_uidt: groupby.column.uidt, column_uidt: groupby.column.uidt,
}, },
], ],

Loading…
Cancel
Save