Skip to content

Commit

Permalink
Merge pull request #8381 from nocodb/nc-fix/link-creation
Browse files Browse the repository at this point in the history
Nc fix/link creation
  • Loading branch information
rameshmane7218 committed May 3, 2024
2 parents 061f7f5 + 6e3322d commit 67dbe7c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
27 changes: 27 additions & 0 deletions packages/nocodb/src/models/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ 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,
);
// keep a map of column id to column object for easy access
const colIdMap = new Map(tableColumns.map((c) => [c.id, c]));

for (const view of views) {
const modifiedInsertObj = {
...insertObj,
Expand All @@ -553,6 +560,26 @@ export default class View implements ViewType {

if (param.column_show?.view_id === view.id) {
modifiedInsertObj.show = true;
} else if (view.uuid) {
// if view is shared, then keep the show state as it is
}
// if gallery/kanban view, show only 3 columns(excluding system 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;
}

if (param.column_order?.view_id === view.id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ test.describe('LTAR create & update', () => {
// Verify fields and toggle the visibility
await dashboard.grid.toolbar.clickFields();
for (const title of ['Sheet1', 'Sheet1s']) {
await dashboard.grid.toolbar.fields.verify({ title, checked: false });
await dashboard.grid.toolbar.fields.click({ title, isLocallySaved: false });
// verify that fields are enabled
await dashboard.grid.toolbar.fields.verify({ title, checked: true });
// await dashboard.grid.toolbar.fields.click({ title, isLocallySaved: false });
}
await dashboard.grid.toolbar.clickFields();

Expand Down Expand Up @@ -157,8 +158,8 @@ test.describe('LTAR create & update', () => {

// Verify fields and toggle the visibility
await dashboard.grid.toolbar.clickFields();
await dashboard.grid.toolbar.fields.verify({ title: 'Sheet2', checked: false });
await dashboard.grid.toolbar.fields.click({ title: 'Sheet2', isLocallySaved: false });
await dashboard.grid.toolbar.fields.verify({ title: 'Sheet2', checked: true });
// await dashboard.grid.toolbar.fields.click({ title: 'Sheet2', isLocallySaved: false });
await dashboard.grid.toolbar.clickFields();

const expected2 = [
Expand Down

0 comments on commit 67dbe7c

Please sign in to comment.