Browse Source

Nc fix: kanban view issues (#9649)

* fix(nc-gui): don't update kanban view stack options if it is shared view

* fix(nocodb): update groupingFieldColumn from view meta on updating select field

* fix(nc-gui): error cannot read property map of undefined

* fix(nc-gui): don't remove record from uncategorizedStack in public view
pull/9659/head
Ramesh Mane 1 month ago committed by GitHub
parent
commit
53d5ecca8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      packages/nc-gui/composables/useKanbanViewStore.ts
  2. 24
      packages/nocodb/src/models/KanbanView.ts
  3. 34
      packages/nocodb/src/services/columns.service.ts

7
packages/nc-gui/composables/useKanbanViewStore.ts

@ -220,6 +220,10 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const { collapsed, ...rest } = stackMetaObj.value[fk_grp_col_id][idx] const { collapsed, ...rest } = stackMetaObj.value[fk_grp_col_id][idx]
if (!deepCompare(rest, option)) { if (!deepCompare(rest, option)) {
// Don't update stack meta if it is shared view and
// shared view meta grouping field options not matched with actual column options
if (isPublic.value) continue
// update the option in stackMetaObj // update the option in stackMetaObj
stackMetaObj.value[fk_grp_col_id][idx] = { stackMetaObj.value[fk_grp_col_id][idx] = {
...stackMetaObj.value[fk_grp_col_id][idx], ...stackMetaObj.value[fk_grp_col_id][idx],
@ -482,7 +486,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
// update to groupingField value to target value // update to groupingField value to target value
formattedData.value.set( formattedData.value.set(
stackTitle, stackTitle,
formattedData.value.get(stackTitle)!.map((o) => ({ (formattedData.value.get(stackTitle) || []).map((o) => ({
...o, ...o,
row: { row: {
...o.row, ...o.row,
@ -624,6 +628,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
} }
function removeRowFromUncategorizedStack() { function removeRowFromUncategorizedStack() {
if (isPublic.value) return
// remove the last record // remove the last record
formattedData.value.get(null)!.pop() formattedData.value.get(null)!.pop()
// decrease total count by 1 // decrease total count by 1

24
packages/nocodb/src/models/KanbanView.ts

@ -65,24 +65,20 @@ export default class KanbanView implements KanbanType {
return view && new KanbanView(view); return view && new KanbanView(view);
} }
public static async IsColumnBeingUsedAsGroupingField( public static async getViewsByGroupingColId(
context: NcContext, context: NcContext,
columnId: string, columnId: string,
ncMeta = Noco.ncMeta, ncMeta = Noco.ncMeta,
) { ) {
return ( return await ncMeta.metaList2(
( context.workspace_id,
await ncMeta.metaList2( context.base_id,
context.workspace_id, MetaTable.KANBAN_VIEW,
context.base_id, {
MetaTable.KANBAN_VIEW, condition: {
{ fk_grp_col_id: columnId,
condition: { },
fk_grp_col_id: columnId, },
},
},
)
).length > 0
); );
} }

34
packages/nocodb/src/services/columns.service.ts

@ -65,6 +65,7 @@ import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
import { MetaService } from '~/meta/meta.service'; import { MetaService } from '~/meta/meta.service';
import { parseMetaProp } from 'src/utils/modelUtils';
// todo: move // todo: move
export enum Altered { export enum Altered {
@ -1243,6 +1244,27 @@ export class ColumnsService {
await Column.update(context, param.columnId, { await Column.update(context, param.columnId, {
...colBody, ...colBody,
}); });
if (colBody.uidt === UITypes.SingleSelect) {
const kanbanViewsByColId = await KanbanView.getViewsByGroupingColId(
context,
column.id,
);
for (const kanbanView of kanbanViewsByColId) {
const view = await View.get(context, kanbanView.fk_view_id);
if (!view?.uuid) continue;
// Update groupingFieldColumn from view meta which will be used in shared kanban view
view.meta = parseMetaProp(view);
await View.update(context, view.id, {
...view,
meta: {
...view.meta,
groupingFieldColumn: colBody,
},
});
}
}
} else if (colBody.uidt === UITypes.User) { } else if (colBody.uidt === UITypes.User) {
// handle default value for user column // handle default value for user column
if (typeof colBody.cdf !== 'string') { if (typeof colBody.cdf !== 'string') {
@ -1517,6 +1539,15 @@ export class ColumnsService {
baseModel.getTnPath(table.table_name), baseModel.getTnPath(table.table_name),
column.column_name, column.column_name,
]); ]);
} else if (
column.uidt === UITypes.SingleSelect &&
column.uidt !== colBody.uidt &&
(await KanbanView.getViewsByGroupingColId(context, column.id)).length >
0
) {
NcError.badRequest(
`The column '${column.column_name}' is being used in Kanban View. Please update stack by field or delete Kanban View first.`,
);
} }
colBody = await getColumnPropsFromUIDT(colBody, source); colBody = await getColumnPropsFromUIDT(colBody, source);
@ -2585,7 +2616,8 @@ export class ColumnsService {
} }
case UITypes.SingleSelect: { case UITypes.SingleSelect: {
if ( if (
await KanbanView.IsColumnBeingUsedAsGroupingField(context, column.id) (await KanbanView.getViewsByGroupingColId(context, column.id))
.length > 0
) { ) {
NcError.badRequest( NcError.badRequest(
`The column '${column.column_name}' is being used in Kanban View. Please delete Kanban View first.`, `The column '${column.column_name}' is being used in Kanban View. Please delete Kanban View first.`,

Loading…
Cancel
Save