|
|
@ -121,7 +121,7 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState( |
|
|
|
rowMeta: {}, |
|
|
|
rowMeta: {}, |
|
|
|
})) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
const valueToTitle = (value: string, col: ColumnType) => { |
|
|
|
const valueToTitle = (value: string, col: ColumnType, displayValueProp?: string) => { |
|
|
|
if (col.uidt === UITypes.Checkbox) { |
|
|
|
if (col.uidt === UITypes.Checkbox) { |
|
|
|
return value ? GROUP_BY_VARS.TRUE : GROUP_BY_VARS.FALSE |
|
|
|
return value ? GROUP_BY_VARS.TRUE : GROUP_BY_VARS.FALSE |
|
|
|
} |
|
|
|
} |
|
|
@ -132,6 +132,10 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord && displayValueProp && value && typeof value === 'object') { |
|
|
|
|
|
|
|
return value[displayValueProp] ?? GROUP_BY_VARS.NULL |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// convert to JSON string if non-string value
|
|
|
|
// convert to JSON string if non-string value
|
|
|
|
if (value && typeof value === 'object') { |
|
|
|
if (value && typeof value === 'object') { |
|
|
|
value = JSON.stringify(value) |
|
|
|
value = JSON.stringify(value) |
|
|
@ -238,6 +242,14 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState( |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (groupby.column.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
|
|
|
|
const relatedTableMeta = await getMeta( |
|
|
|
|
|
|
|
(groupby.column.colOptions as LinkToAnotherRecordType).fk_related_model_id as string, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
if (!relatedTableMeta) return |
|
|
|
|
|
|
|
group.displayValueProp = (relatedTableMeta.columns?.find((c) => c.pv) || relatedTableMeta.columns?.[0])?.title || '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const response = !isPublic |
|
|
|
const response = !isPublic |
|
|
|
? await api.dbViewRow.groupBy('noco', base.value.id, view.value.fk_model_id, view.value.id, { |
|
|
|
? await api.dbViewRow.groupBy('noco', base.value.id, view.value.fk_model_id, view.value.id, { |
|
|
|
offset: ((group.paginationData.page ?? 0) - 1) * (group.paginationData.pageSize ?? groupByGroupLimit.value), |
|
|
|
offset: ((group.paginationData.page ?? 0) - 1) * (group.paginationData.pageSize ?? groupByGroupLimit.value), |
|
|
@ -464,7 +476,10 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState( |
|
|
|
if (group.nested) { |
|
|
|
if (group.nested) { |
|
|
|
const child = group.children?.find((g) => { |
|
|
|
const child = group.children?.find((g) => { |
|
|
|
if (!groupBy.value[nestLevel].column.title) return undefined |
|
|
|
if (!groupBy.value[nestLevel].column.title) return undefined |
|
|
|
return g.key === valueToTitle(row.row[groupBy.value[nestLevel].column.title!], groupBy.value[nestLevel].column) |
|
|
|
return ( |
|
|
|
|
|
|
|
g.key === |
|
|
|
|
|
|
|
valueToTitle(row.row[groupBy.value[nestLevel].column.title!], groupBy.value[nestLevel].column, group.displayValueProp) |
|
|
|
|
|
|
|
) |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (child) { |
|
|
|
if (child) { |
|
|
|
return findGroupForRow(row, child, nestLevel + 1) |
|
|
|
return findGroupForRow(row, child, nestLevel + 1) |
|
|
|