Browse Source

feat: skip showing if gallery/kanban have less than 3 visible non-system columns

pull/8381/head
Pranav C 6 months ago
parent
commit
09259068e0
  1. 26
      packages/nocodb/src/models/View.ts

26
packages/nocodb/src/models/View.ts

@ -545,6 +545,12 @@ export default class View implements ViewType {
};
const views = await this.list(param.fk_model_id, ncMeta);
const tableColumns = await Column.list(
{ fk_model_id: param.fk_model_id },
ncMeta,
);
const colIdMap = new Map(tableColumns.map((c) => [c.id, c]));
for (const view of views) {
const modifiedInsertObj = {
...insertObj,
@ -553,7 +559,25 @@ export default class View implements ViewType {
if (param.column_show?.view_id === view.id) {
modifiedInsertObj.show = true;
} else if (view.type !== ViewTypes.FORM && !view.uuid) {
} else if (view.uuid) {
// if view is shared, then keep the show state as it is
}
// if gallery/kanban view, show only 3 columns
else if (view.type === ViewTypes.GALLERY) {
const visibleColumnsCount = (
await GalleryViewColumn.list(view.id, ncMeta)
)?.filter(
(c) => c.show && !isSystemColumn(colIdMap.get(c.fk_column_id)),
).length;
modifiedInsertObj.show = visibleColumnsCount < 3;
} else if (view.type === ViewTypes.KANBAN) {
const visibleColumnsCount = (
await KanbanViewColumn.list(view.id, ncMeta)
)?.filter(
(c) => c.show && !isSystemColumn(colIdMap.get(c.fk_column_id)),
).length;
modifiedInsertObj.show = visibleColumnsCount < 3;
} else if (view.type !== ViewTypes.FORM) {
modifiedInsertObj.show = true;
}

Loading…
Cancel
Save