diff --git a/packages/nocodb/src/lib/models/KanbanView.ts b/packages/nocodb/src/lib/models/KanbanView.ts index c85c65b08b..ee9258a1ff 100644 --- a/packages/nocodb/src/lib/models/KanbanView.ts +++ b/packages/nocodb/src/lib/models/KanbanView.ts @@ -43,6 +43,7 @@ export default class KanbanView implements KanbanType { project_id: view.project_id, base_id: view.base_id, fk_view_id: view.fk_view_id, + grp_column_id: view.grp_column_id, // TODO: more }; if (!(view.project_id && view.base_id)) { diff --git a/packages/nocodb/src/lib/models/View.ts b/packages/nocodb/src/lib/models/View.ts index fe887f0d3f..3c08d62681 100644 --- a/packages/nocodb/src/lib/models/View.ts +++ b/packages/nocodb/src/lib/models/View.ts @@ -273,6 +273,10 @@ export default class View implements ViewType { `${CacheScope.VIEW}:${view_id}` ); + let columns: any[] = await ( + await Model.getByIdOrName({ id: view.fk_model_id }, ncMeta) + ).getColumns(ncMeta); + // insert view metadata based on view type switch (view.type) { case ViewTypes.GRID: @@ -306,6 +310,13 @@ export default class View implements ViewType { ); break; case ViewTypes.KANBAN: + // Preset a grouping field by choosing the first single select field + // TODO: let users to choose in kanban create modal + const singleSelectColumns = columns.filter( + (c) => c.uidt === UITypes.SingleSelect + )[0]; + (view as KanbanView).grp_column_id = singleSelectColumns?.id; + await KanbanView.insert( { ...(copyFromView?.view || {}), @@ -317,10 +328,6 @@ export default class View implements ViewType { break; } - let columns: any[] = await ( - await Model.getByIdOrName({ id: view.fk_model_id }, ncMeta) - ).getColumns(ncMeta); - if (copyFromView) { const sorts = await copyFromView.getSorts(ncMeta); const filters = await copyFromView.getFilters(ncMeta);