Browse Source

feat(nc-gui): set a default grouping field in kanban creation

pull/3818/head
Wing-Kam Wong 2 years ago
parent
commit
5f53c3a820
  1. 1
      packages/nocodb/src/lib/models/KanbanView.ts
  2. 15
      packages/nocodb/src/lib/models/View.ts

1
packages/nocodb/src/lib/models/KanbanView.ts

@ -43,6 +43,7 @@ export default class KanbanView implements KanbanType {
project_id: view.project_id, project_id: view.project_id,
base_id: view.base_id, base_id: view.base_id,
fk_view_id: view.fk_view_id, fk_view_id: view.fk_view_id,
grp_column_id: view.grp_column_id,
// TODO: more // TODO: more
}; };
if (!(view.project_id && view.base_id)) { if (!(view.project_id && view.base_id)) {

15
packages/nocodb/src/lib/models/View.ts

@ -273,6 +273,10 @@ export default class View implements ViewType {
`${CacheScope.VIEW}:${view_id}` `${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 // insert view metadata based on view type
switch (view.type) { switch (view.type) {
case ViewTypes.GRID: case ViewTypes.GRID:
@ -306,6 +310,13 @@ export default class View implements ViewType {
); );
break; break;
case ViewTypes.KANBAN: 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( await KanbanView.insert(
{ {
...(copyFromView?.view || {}), ...(copyFromView?.view || {}),
@ -317,10 +328,6 @@ export default class View implements ViewType {
break; break;
} }
let columns: any[] = await (
await Model.getByIdOrName({ id: view.fk_model_id }, ncMeta)
).getColumns(ncMeta);
if (copyFromView) { if (copyFromView) {
const sorts = await copyFromView.getSorts(ncMeta); const sorts = await copyFromView.getSorts(ncMeta);
const filters = await copyFromView.getFilters(ncMeta); const filters = await copyFromView.getFilters(ncMeta);

Loading…
Cancel
Save