diff --git a/app/client/models/DocModel.ts b/app/client/models/DocModel.ts index 2be93e81..c1d7eee2 100644 --- a/app/client/models/DocModel.ts +++ b/app/client/models/DocModel.ts @@ -32,7 +32,6 @@ import {createFilterRec, FilterRec} from 'app/client/models/entities/FilterRec'; import {createPageRec, PageRec} from 'app/client/models/entities/PageRec'; import {createTabBarRec, TabBarRec} from 'app/client/models/entities/TabBarRec'; import {createTableRec, TableRec} from 'app/client/models/entities/TableRec'; -import {createTableViewRec, TableViewRec} from 'app/client/models/entities/TableViewRec'; import {createValidationRec, ValidationRec} from 'app/client/models/entities/ValidationRec'; import {createViewFieldRec, ViewFieldRec} from 'app/client/models/entities/ViewFieldRec'; import {createViewRec, ViewRec} from 'app/client/models/entities/ViewRec'; @@ -46,7 +45,6 @@ export {FilterRec} from 'app/client/models/entities/FilterRec'; export {PageRec} from 'app/client/models/entities/PageRec'; export {TabBarRec} from 'app/client/models/entities/TabBarRec'; export {TableRec} from 'app/client/models/entities/TableRec'; -export {TableViewRec} from 'app/client/models/entities/TableViewRec'; export {ValidationRec} from 'app/client/models/entities/ValidationRec'; export {ViewFieldRec} from 'app/client/models/entities/ViewFieldRec'; export {ViewRec} from 'app/client/models/entities/ViewRec'; @@ -108,7 +106,6 @@ export class DocModel { public views: MTM = this._metaTableModel("_grist_Views", createViewRec); public viewSections: MTM = this._metaTableModel("_grist_Views_section", createViewSectionRec); public viewFields: MTM = this._metaTableModel("_grist_Views_section_field", createViewFieldRec); - public tableViews: MTM = this._metaTableModel("_grist_TableViews", createTableViewRec); public tabBar: MTM = this._metaTableModel("_grist_TabBar", createTabBarRec); public validations: MTM = this._metaTableModel("_grist_Validations", createValidationRec); public pages: MTM = this._metaTableModel("_grist_Pages", createPageRec); diff --git a/app/client/models/entities/TableRec.ts b/app/client/models/entities/TableRec.ts index 5d7cadd3..3a2e56fa 100644 --- a/app/client/models/entities/TableRec.ts +++ b/app/client/models/entities/TableRec.ts @@ -1,6 +1,6 @@ import {KoArray} from 'app/client/lib/koArray'; import {DocModel, IRowModel, recordSet, refRecord} from 'app/client/models/DocModel'; -import {ColumnRec, TableViewRec, ValidationRec, ViewRec} from 'app/client/models/DocModel'; +import {ColumnRec, ValidationRec, ViewRec} from 'app/client/models/DocModel'; import {MANUALSORT} from 'app/common/gristTypes'; import * as ko from 'knockout'; import toUpper = require('lodash/toUpper'); @@ -12,7 +12,6 @@ export interface TableRec extends IRowModel<"_grist_Tables"> { validations: ko.Computed>; primaryView: ko.Computed; - tableViewItems: ko.Computed>; summarySource: ko.Computed; // A Set object of colRefs for all summarySourceCols of table. @@ -38,7 +37,6 @@ export function createTableRec(this: TableRec, docModel: DocModel): void { this.validations = recordSet(this, docModel.validations, 'tableRef'); this.primaryView = refRecord(docModel.views, this.primaryViewId); - this.tableViewItems = recordSet(this, docModel.tableViews, 'tableRef', {sortBy: 'viewRef'}); this.summarySource = refRecord(docModel.tables, this.summarySourceTable); // A Set object of colRefs for all summarySourceCols of this table. diff --git a/app/client/models/entities/TableViewRec.ts b/app/client/models/entities/TableViewRec.ts deleted file mode 100644 index 9f8cb80b..00000000 --- a/app/client/models/entities/TableViewRec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {DocModel, IRowModel, refRecord, TableRec, ViewRec} from 'app/client/models/DocModel'; -import * as ko from 'knockout'; - -// Used in old-style list of views grouped by table. -export interface TableViewRec extends IRowModel<"_grist_TableViews"> { - table: ko.Computed; - view: ko.Computed; -} - -export function createTableViewRec(this: TableViewRec, docModel: DocModel): void { - this.table = refRecord(docModel.tables, this.tableRef); - this.view = refRecord(docModel.views, this.viewRef); -} diff --git a/app/client/models/entities/ViewRec.ts b/app/client/models/entities/ViewRec.ts index b4fc5490..176749e4 100644 --- a/app/client/models/entities/ViewRec.ts +++ b/app/client/models/entities/ViewRec.ts @@ -1,14 +1,13 @@ import {KoArray} from 'app/client/lib/koArray'; import * as koUtil from 'app/client/lib/koUtil'; import {DocModel, IRowModel, recordSet, refRecord} from 'app/client/models/DocModel'; -import {TabBarRec, TableViewRec, ViewSectionRec} from 'app/client/models/DocModel'; +import {TabBarRec, ViewSectionRec} from 'app/client/models/DocModel'; import * as modelUtil from 'app/client/models/modelUtil'; import * as ko from 'knockout'; // Represents a view (now also referred to as a "page") containing one or more view sections. export interface ViewRec extends IRowModel<"_grist_Views"> { viewSections: ko.Computed>; - tableViewItems: ko.Computed>; tabBarItem: ko.Computed>; layoutSpecObj: modelUtil.ObjObservable; @@ -26,7 +25,6 @@ export interface ViewRec extends IRowModel<"_grist_Views"> { export function createViewRec(this: ViewRec, docModel: DocModel): void { this.viewSections = recordSet(this, docModel.viewSections, 'parentId'); - this.tableViewItems = recordSet(this, docModel.tableViews, 'viewRef', {sortBy: 'tableRef'}); this.tabBarItem = recordSet(this, docModel.tabBar, 'viewRef'); this.layoutSpecObj = modelUtil.jsonObservable(this.layoutSpec); diff --git a/sandbox/grist/docmodel.py b/sandbox/grist/docmodel.py index f32f2c69..f0858a7b 100644 --- a/sandbox/grist/docmodel.py +++ b/sandbox/grist/docmodel.py @@ -52,7 +52,6 @@ class MetaTableExtras(object): class _grist_Tables(object): columns = _record_set('_grist_Tables_column', 'parentId', sort_by='parentPos') viewSections = _record_set('_grist_Views_section', 'tableRef') - tableViews = _record_set('_grist_TableViews', 'tableRef') summaryTables = _record_set('_grist_Tables', 'summarySourceTable') def summaryKey(rec, table): @@ -100,7 +99,6 @@ class MetaTableExtras(object): class _grist_Views(object): viewSections = _record_set('_grist_Views_section', 'parentId') tabBarItems = _record_set('_grist_TabBar', 'viewRef') - tableViewItems = _record_set('_grist_TableViews', 'viewRef') primaryViewTable = _record_inverse('_grist_Tables', 'primaryViewId') pageItems = _record_set('_grist_Pages', 'viewRef') @@ -153,7 +151,6 @@ class DocModel(object): self.doc_info = self._prep_table("_grist_DocInfo") self.tables = self._prep_table("_grist_Tables") self.columns = self._prep_table("_grist_Tables_column") - self.table_views = self._prep_table("_grist_TableViews") self.tab_bar = self._prep_table("_grist_TabBar") self.views = self._prep_table("_grist_Views") self.view_sections = self._prep_table("_grist_Views_section") diff --git a/sandbox/grist/schema.py b/sandbox/grist/schema.py index f41b94aa..19ec4fc4 100644 --- a/sandbox/grist/schema.py +++ b/sandbox/grist/schema.py @@ -128,7 +128,7 @@ def schema_create_actions(): make_column("tableName", "Text"), ]), - # Document tabs that represent a cross-reference between Tables and Views + # DEPRECATED: Document tabs that represent a cross-reference between Tables and Views actions.AddTable("_grist_TableViews", [ make_column("tableRef", "Ref:_grist_Tables"), make_column("viewRef", "Ref:_grist_Views"), diff --git a/sandbox/grist/test_table_actions.py b/sandbox/grist/test_table_actions.py index 1b488937..0659cd43 100644 --- a/sandbox/grist/test_table_actions.py +++ b/sandbox/grist/test_table_actions.py @@ -263,12 +263,7 @@ class TestTableActions(test_engine.EngineTestCase): self.assertEqual(out_actions.retValues[0]["viewRef"], 5) self.apply_user_action(["CreateViewSection", 4, 5, 'detail', None]) - # See what's in TableViews and TabBar tables, to verify after we remove a table. - self.assertTableData('_grist_TableViews', data=[ - ["id", "tableRef", "viewRef"], - [1, 1, 3], - [2, 1, 5], - ]) + # See what's in TabBar table, to verify after we remove a table. self.assertTableData('_grist_TabBar', cols="subset", data=[ ["id", "viewRef"], [1, 1], @@ -281,11 +276,7 @@ class TestTableActions(test_engine.EngineTestCase): # Remove two tables, ensure certain views get removed. self.apply_user_action(["BulkRemoveRecord", "_grist_Tables", [1, 4]]) - # See that some TableViews/TabBar entries disappear, or tableRef gets unset. - self.assertTableData('_grist_TableViews', data=[ - ["id", "tableRef", "viewRef"], - [1, 0, 3], - ]) + # See that some TabBar entries disappear, or tableRef gets unset. self.assertTableData('_grist_TabBar', cols="subset", data=[ ["id", "viewRef"], [2, 2], diff --git a/sandbox/grist/test_useractions.py b/sandbox/grist/test_useractions.py index f179e200..87118ede 100644 --- a/sandbox/grist/test_useractions.py +++ b/sandbox/grist/test_useractions.py @@ -284,7 +284,7 @@ class TestUserActions(test_engine.EngineTestCase): #---------------------------------------------------------------------- def init_views_sample(self): - # Add a new table and a view, to get some Views/Sections/Fields, and TableView/TabBar items. + # Add a new table and a view, to get some Views/Sections/Fields, and TabBar items. self.apply_user_action(['AddTable', 'Schools', [ {'id': 'city', 'type': 'Text'}, {'id': 'state', 'type': 'Text'}, @@ -361,11 +361,6 @@ class TestUserActions(test_engine.EngineTestCase): ]), ]), ]) - self.assertTableData('_grist_TableViews', data=[ - ["id", "tableRef", "viewRef"], - [1, 1, 2], - [2, 1, 3], - ]) self.assertTableData('_grist_TabBar', cols="subset", data=[ ["id", "viewRef"], [1, 1], @@ -422,9 +417,6 @@ class TestUserActions(test_engine.EngineTestCase): ]), ]), ]) - self.assertTableData('_grist_TableViews', data=[ - ["id", "tableRef", "viewRef"], - ]) self.assertTableData('_grist_TabBar', cols="subset", data=[ ["id", "viewRef"], [1, 1], diff --git a/sandbox/grist/useractions.py b/sandbox/grist/useractions.py index fd7444d0..7fb0253a 100644 --- a/sandbox/grist/useractions.py +++ b/sandbox/grist/useractions.py @@ -822,11 +822,9 @@ class UserActions(object): # application-level relationships; it is not tested by testscript (nor should be, most likely; # it should have much simpler tests). - # Remove any views that no longer have view sections. We scan through TableViews (i.e. left - # side-pane entries) for this table, so Views under other tables or under "other views" will - # be unaffected to avoid confusing the user by deleteing views they are not interacting with. - views_to_remove = [tv.viewRef for t in remove_table_recs for tv in t.tableViews - if not tv.viewRef.viewSections] + # Remove any views that no longer have view sections. + views_to_remove = [view for view in self._docmodel.views.all + if not view.viewSections] # Also delete the primary views for tables being deleted, even if it has remaining sections. for t in remove_table_recs: if t.primaryViewId and t.primaryViewId not in views_to_remove: @@ -918,9 +916,8 @@ class UserActions(object): """ view_recs = [rec for i, rec in self._bulk_action_iter(table_id, row_ids)] - # Remove all the tabBar and tableView items, and the view sections. + # Remove all the tabBar items, and the view sections. self._docmodel.remove(t for v in view_recs for t in v.tabBarItems) - self._docmodel.remove(t for v in view_recs for t in v.tableViewItems) self._docmodel.remove(vs for v in view_recs for vs in v.viewSections) # Remove all the pages and fixes indentation @@ -1425,11 +1422,6 @@ class UserActions(object): Creates records for a View """ result = self.doAddView(table_id, view_type, name) - table_row_id = self._engine.tables['_grist_Tables'].get(tableId=table_id) - self.AddRecord('_grist_TableViews', None, { - 'tableRef': table_row_id, - 'viewRef': result["id"] - }) return result def doAddView(self, table_id, view_type, name):