Browse Source

Merge pull request #8381 from nocodb/nc-fix/link-creation

Nc fix/link creation
pull/8384/head
Ramesh Mane 8 months ago committed by GitHub
parent
commit
67dbe7c837
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 27
      packages/nocodb/src/models/View.ts
  2. 9
      tests/playwright/tests/db/columns/columnLinkToAnotherRecord.spec.ts

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

@ -545,6 +545,13 @@ export default class View implements ViewType {
}; };
const views = await this.list(param.fk_model_id, ncMeta); 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) { for (const view of views) {
const modifiedInsertObj = { const modifiedInsertObj = {
...insertObj, ...insertObj,
@ -553,6 +560,26 @@ export default class View implements ViewType {
if (param.column_show?.view_id === view.id) { if (param.column_show?.view_id === view.id) {
modifiedInsertObj.show = true; 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) { if (param.column_order?.view_id === view.id) {

9
tests/playwright/tests/db/columns/columnLinkToAnotherRecord.spec.ts

@ -59,8 +59,9 @@ test.describe('LTAR create & update', () => {
// Verify fields and toggle the visibility // Verify fields and toggle the visibility
await dashboard.grid.toolbar.clickFields(); await dashboard.grid.toolbar.clickFields();
for (const title of ['Sheet1', 'Sheet1s']) { for (const title of ['Sheet1', 'Sheet1s']) {
await dashboard.grid.toolbar.fields.verify({ title, checked: false }); // verify that fields are enabled
await dashboard.grid.toolbar.fields.click({ title, isLocallySaved: false }); await dashboard.grid.toolbar.fields.verify({ title, checked: true });
// await dashboard.grid.toolbar.fields.click({ title, isLocallySaved: false });
} }
await dashboard.grid.toolbar.clickFields(); await dashboard.grid.toolbar.clickFields();
@ -157,8 +158,8 @@ test.describe('LTAR create & update', () => {
// Verify fields and toggle the visibility // Verify fields and toggle the visibility
await dashboard.grid.toolbar.clickFields(); await dashboard.grid.toolbar.clickFields();
await dashboard.grid.toolbar.fields.verify({ title: 'Sheet2', checked: 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.fields.click({ title: 'Sheet2', isLocallySaved: false });
await dashboard.grid.toolbar.clickFields(); await dashboard.grid.toolbar.clickFields();
const expected2 = [ const expected2 = [

Loading…
Cancel
Save