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,
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)) {

15
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);

Loading…
Cancel
Save