mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Remove code related to _grist_TableViews
Summary: Removed some TS and python code interacting with this meta table. Not touching schema or migrations. This is not really necessary, just checking my understanding and cleaning up in preparation for raw data views. I can also remove _grist_TabItems code while I'm at it. Test Plan: this Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3161
This commit is contained in:
parent
3a52755d94
commit
be96db4689
@ -32,7 +32,6 @@ import {createFilterRec, FilterRec} from 'app/client/models/entities/FilterRec';
|
|||||||
import {createPageRec, PageRec} from 'app/client/models/entities/PageRec';
|
import {createPageRec, PageRec} from 'app/client/models/entities/PageRec';
|
||||||
import {createTabBarRec, TabBarRec} from 'app/client/models/entities/TabBarRec';
|
import {createTabBarRec, TabBarRec} from 'app/client/models/entities/TabBarRec';
|
||||||
import {createTableRec, TableRec} from 'app/client/models/entities/TableRec';
|
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 {createValidationRec, ValidationRec} from 'app/client/models/entities/ValidationRec';
|
||||||
import {createViewFieldRec, ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
|
import {createViewFieldRec, ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
|
||||||
import {createViewRec, ViewRec} from 'app/client/models/entities/ViewRec';
|
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 {PageRec} from 'app/client/models/entities/PageRec';
|
||||||
export {TabBarRec} from 'app/client/models/entities/TabBarRec';
|
export {TabBarRec} from 'app/client/models/entities/TabBarRec';
|
||||||
export {TableRec} from 'app/client/models/entities/TableRec';
|
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 {ValidationRec} from 'app/client/models/entities/ValidationRec';
|
||||||
export {ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
|
export {ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
|
||||||
export {ViewRec} from 'app/client/models/entities/ViewRec';
|
export {ViewRec} from 'app/client/models/entities/ViewRec';
|
||||||
@ -108,7 +106,6 @@ export class DocModel {
|
|||||||
public views: MTM<ViewRec> = this._metaTableModel("_grist_Views", createViewRec);
|
public views: MTM<ViewRec> = this._metaTableModel("_grist_Views", createViewRec);
|
||||||
public viewSections: MTM<ViewSectionRec> = this._metaTableModel("_grist_Views_section", createViewSectionRec);
|
public viewSections: MTM<ViewSectionRec> = this._metaTableModel("_grist_Views_section", createViewSectionRec);
|
||||||
public viewFields: MTM<ViewFieldRec> = this._metaTableModel("_grist_Views_section_field", createViewFieldRec);
|
public viewFields: MTM<ViewFieldRec> = this._metaTableModel("_grist_Views_section_field", createViewFieldRec);
|
||||||
public tableViews: MTM<TableViewRec> = this._metaTableModel("_grist_TableViews", createTableViewRec);
|
|
||||||
public tabBar: MTM<TabBarRec> = this._metaTableModel("_grist_TabBar", createTabBarRec);
|
public tabBar: MTM<TabBarRec> = this._metaTableModel("_grist_TabBar", createTabBarRec);
|
||||||
public validations: MTM<ValidationRec> = this._metaTableModel("_grist_Validations", createValidationRec);
|
public validations: MTM<ValidationRec> = this._metaTableModel("_grist_Validations", createValidationRec);
|
||||||
public pages: MTM<PageRec> = this._metaTableModel("_grist_Pages", createPageRec);
|
public pages: MTM<PageRec> = this._metaTableModel("_grist_Pages", createPageRec);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {KoArray} from 'app/client/lib/koArray';
|
import {KoArray} from 'app/client/lib/koArray';
|
||||||
import {DocModel, IRowModel, recordSet, refRecord} from 'app/client/models/DocModel';
|
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 {MANUALSORT} from 'app/common/gristTypes';
|
||||||
import * as ko from 'knockout';
|
import * as ko from 'knockout';
|
||||||
import toUpper = require('lodash/toUpper');
|
import toUpper = require('lodash/toUpper');
|
||||||
@ -12,7 +12,6 @@ export interface TableRec extends IRowModel<"_grist_Tables"> {
|
|||||||
validations: ko.Computed<KoArray<ValidationRec>>;
|
validations: ko.Computed<KoArray<ValidationRec>>;
|
||||||
|
|
||||||
primaryView: ko.Computed<ViewRec>;
|
primaryView: ko.Computed<ViewRec>;
|
||||||
tableViewItems: ko.Computed<KoArray<TableViewRec>>;
|
|
||||||
summarySource: ko.Computed<TableRec>;
|
summarySource: ko.Computed<TableRec>;
|
||||||
|
|
||||||
// A Set object of colRefs for all summarySourceCols of table.
|
// 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.validations = recordSet(this, docModel.validations, 'tableRef');
|
||||||
|
|
||||||
this.primaryView = refRecord(docModel.views, this.primaryViewId);
|
this.primaryView = refRecord(docModel.views, this.primaryViewId);
|
||||||
this.tableViewItems = recordSet(this, docModel.tableViews, 'tableRef', {sortBy: 'viewRef'});
|
|
||||||
this.summarySource = refRecord(docModel.tables, this.summarySourceTable);
|
this.summarySource = refRecord(docModel.tables, this.summarySourceTable);
|
||||||
|
|
||||||
// A Set object of colRefs for all summarySourceCols of this table.
|
// A Set object of colRefs for all summarySourceCols of this table.
|
||||||
|
@ -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<TableRec>;
|
|
||||||
view: ko.Computed<ViewRec>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createTableViewRec(this: TableViewRec, docModel: DocModel): void {
|
|
||||||
this.table = refRecord(docModel.tables, this.tableRef);
|
|
||||||
this.view = refRecord(docModel.views, this.viewRef);
|
|
||||||
}
|
|
@ -1,14 +1,13 @@
|
|||||||
import {KoArray} from 'app/client/lib/koArray';
|
import {KoArray} from 'app/client/lib/koArray';
|
||||||
import * as koUtil from 'app/client/lib/koUtil';
|
import * as koUtil from 'app/client/lib/koUtil';
|
||||||
import {DocModel, IRowModel, recordSet, refRecord} from 'app/client/models/DocModel';
|
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 modelUtil from 'app/client/models/modelUtil';
|
||||||
import * as ko from 'knockout';
|
import * as ko from 'knockout';
|
||||||
|
|
||||||
// Represents a view (now also referred to as a "page") containing one or more view sections.
|
// Represents a view (now also referred to as a "page") containing one or more view sections.
|
||||||
export interface ViewRec extends IRowModel<"_grist_Views"> {
|
export interface ViewRec extends IRowModel<"_grist_Views"> {
|
||||||
viewSections: ko.Computed<KoArray<ViewSectionRec>>;
|
viewSections: ko.Computed<KoArray<ViewSectionRec>>;
|
||||||
tableViewItems: ko.Computed<KoArray<TableViewRec>>;
|
|
||||||
tabBarItem: ko.Computed<KoArray<TabBarRec>>;
|
tabBarItem: ko.Computed<KoArray<TabBarRec>>;
|
||||||
|
|
||||||
layoutSpecObj: modelUtil.ObjObservable<any>;
|
layoutSpecObj: modelUtil.ObjObservable<any>;
|
||||||
@ -26,7 +25,6 @@ export interface ViewRec extends IRowModel<"_grist_Views"> {
|
|||||||
|
|
||||||
export function createViewRec(this: ViewRec, docModel: DocModel): void {
|
export function createViewRec(this: ViewRec, docModel: DocModel): void {
|
||||||
this.viewSections = recordSet(this, docModel.viewSections, 'parentId');
|
this.viewSections = recordSet(this, docModel.viewSections, 'parentId');
|
||||||
this.tableViewItems = recordSet(this, docModel.tableViews, 'viewRef', {sortBy: 'tableRef'});
|
|
||||||
this.tabBarItem = recordSet(this, docModel.tabBar, 'viewRef');
|
this.tabBarItem = recordSet(this, docModel.tabBar, 'viewRef');
|
||||||
|
|
||||||
this.layoutSpecObj = modelUtil.jsonObservable(this.layoutSpec);
|
this.layoutSpecObj = modelUtil.jsonObservable(this.layoutSpec);
|
||||||
|
@ -52,7 +52,6 @@ class MetaTableExtras(object):
|
|||||||
class _grist_Tables(object):
|
class _grist_Tables(object):
|
||||||
columns = _record_set('_grist_Tables_column', 'parentId', sort_by='parentPos')
|
columns = _record_set('_grist_Tables_column', 'parentId', sort_by='parentPos')
|
||||||
viewSections = _record_set('_grist_Views_section', 'tableRef')
|
viewSections = _record_set('_grist_Views_section', 'tableRef')
|
||||||
tableViews = _record_set('_grist_TableViews', 'tableRef')
|
|
||||||
summaryTables = _record_set('_grist_Tables', 'summarySourceTable')
|
summaryTables = _record_set('_grist_Tables', 'summarySourceTable')
|
||||||
|
|
||||||
def summaryKey(rec, table):
|
def summaryKey(rec, table):
|
||||||
@ -100,7 +99,6 @@ class MetaTableExtras(object):
|
|||||||
class _grist_Views(object):
|
class _grist_Views(object):
|
||||||
viewSections = _record_set('_grist_Views_section', 'parentId')
|
viewSections = _record_set('_grist_Views_section', 'parentId')
|
||||||
tabBarItems = _record_set('_grist_TabBar', 'viewRef')
|
tabBarItems = _record_set('_grist_TabBar', 'viewRef')
|
||||||
tableViewItems = _record_set('_grist_TableViews', 'viewRef')
|
|
||||||
primaryViewTable = _record_inverse('_grist_Tables', 'primaryViewId')
|
primaryViewTable = _record_inverse('_grist_Tables', 'primaryViewId')
|
||||||
pageItems = _record_set('_grist_Pages', 'viewRef')
|
pageItems = _record_set('_grist_Pages', 'viewRef')
|
||||||
|
|
||||||
@ -153,7 +151,6 @@ class DocModel(object):
|
|||||||
self.doc_info = self._prep_table("_grist_DocInfo")
|
self.doc_info = self._prep_table("_grist_DocInfo")
|
||||||
self.tables = self._prep_table("_grist_Tables")
|
self.tables = self._prep_table("_grist_Tables")
|
||||||
self.columns = self._prep_table("_grist_Tables_column")
|
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.tab_bar = self._prep_table("_grist_TabBar")
|
||||||
self.views = self._prep_table("_grist_Views")
|
self.views = self._prep_table("_grist_Views")
|
||||||
self.view_sections = self._prep_table("_grist_Views_section")
|
self.view_sections = self._prep_table("_grist_Views_section")
|
||||||
|
@ -128,7 +128,7 @@ def schema_create_actions():
|
|||||||
make_column("tableName", "Text"),
|
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", [
|
actions.AddTable("_grist_TableViews", [
|
||||||
make_column("tableRef", "Ref:_grist_Tables"),
|
make_column("tableRef", "Ref:_grist_Tables"),
|
||||||
make_column("viewRef", "Ref:_grist_Views"),
|
make_column("viewRef", "Ref:_grist_Views"),
|
||||||
|
@ -263,12 +263,7 @@ class TestTableActions(test_engine.EngineTestCase):
|
|||||||
self.assertEqual(out_actions.retValues[0]["viewRef"], 5)
|
self.assertEqual(out_actions.retValues[0]["viewRef"], 5)
|
||||||
self.apply_user_action(["CreateViewSection", 4, 5, 'detail', None])
|
self.apply_user_action(["CreateViewSection", 4, 5, 'detail', None])
|
||||||
|
|
||||||
# See what's in TableViews and TabBar tables, to verify after we remove a table.
|
# See what's in TabBar table, to verify after we remove a table.
|
||||||
self.assertTableData('_grist_TableViews', data=[
|
|
||||||
["id", "tableRef", "viewRef"],
|
|
||||||
[1, 1, 3],
|
|
||||||
[2, 1, 5],
|
|
||||||
])
|
|
||||||
self.assertTableData('_grist_TabBar', cols="subset", data=[
|
self.assertTableData('_grist_TabBar', cols="subset", data=[
|
||||||
["id", "viewRef"],
|
["id", "viewRef"],
|
||||||
[1, 1],
|
[1, 1],
|
||||||
@ -281,11 +276,7 @@ class TestTableActions(test_engine.EngineTestCase):
|
|||||||
# Remove two tables, ensure certain views get removed.
|
# Remove two tables, ensure certain views get removed.
|
||||||
self.apply_user_action(["BulkRemoveRecord", "_grist_Tables", [1, 4]])
|
self.apply_user_action(["BulkRemoveRecord", "_grist_Tables", [1, 4]])
|
||||||
|
|
||||||
# See that some TableViews/TabBar entries disappear, or tableRef gets unset.
|
# See that some TabBar entries disappear, or tableRef gets unset.
|
||||||
self.assertTableData('_grist_TableViews', data=[
|
|
||||||
["id", "tableRef", "viewRef"],
|
|
||||||
[1, 0, 3],
|
|
||||||
])
|
|
||||||
self.assertTableData('_grist_TabBar', cols="subset", data=[
|
self.assertTableData('_grist_TabBar', cols="subset", data=[
|
||||||
["id", "viewRef"],
|
["id", "viewRef"],
|
||||||
[2, 2],
|
[2, 2],
|
||||||
|
@ -284,7 +284,7 @@ class TestUserActions(test_engine.EngineTestCase):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
def init_views_sample(self):
|
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', [
|
self.apply_user_action(['AddTable', 'Schools', [
|
||||||
{'id': 'city', 'type': 'Text'},
|
{'id': 'city', 'type': 'Text'},
|
||||||
{'id': 'state', '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=[
|
self.assertTableData('_grist_TabBar', cols="subset", data=[
|
||||||
["id", "viewRef"],
|
["id", "viewRef"],
|
||||||
[1, 1],
|
[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=[
|
self.assertTableData('_grist_TabBar', cols="subset", data=[
|
||||||
["id", "viewRef"],
|
["id", "viewRef"],
|
||||||
[1, 1],
|
[1, 1],
|
||||||
|
@ -822,11 +822,9 @@ class UserActions(object):
|
|||||||
# application-level relationships; it is not tested by testscript (nor should be, most likely;
|
# application-level relationships; it is not tested by testscript (nor should be, most likely;
|
||||||
# it should have much simpler tests).
|
# it should have much simpler tests).
|
||||||
|
|
||||||
# Remove any views that no longer have view sections. We scan through TableViews (i.e. left
|
# Remove any views that no longer have view sections.
|
||||||
# side-pane entries) for this table, so Views under other tables or under "other views" will
|
views_to_remove = [view for view in self._docmodel.views.all
|
||||||
# be unaffected to avoid confusing the user by deleteing views they are not interacting with.
|
if not view.viewSections]
|
||||||
views_to_remove = [tv.viewRef for t in remove_table_recs for tv in t.tableViews
|
|
||||||
if not tv.viewRef.viewSections]
|
|
||||||
# Also delete the primary views for tables being deleted, even if it has remaining sections.
|
# Also delete the primary views for tables being deleted, even if it has remaining sections.
|
||||||
for t in remove_table_recs:
|
for t in remove_table_recs:
|
||||||
if t.primaryViewId and t.primaryViewId not in views_to_remove:
|
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)]
|
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.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)
|
self._docmodel.remove(vs for v in view_recs for vs in v.viewSections)
|
||||||
|
|
||||||
# Remove all the pages and fixes indentation
|
# Remove all the pages and fixes indentation
|
||||||
@ -1425,11 +1422,6 @@ class UserActions(object):
|
|||||||
Creates records for a View
|
Creates records for a View
|
||||||
"""
|
"""
|
||||||
result = self.doAddView(table_id, view_type, name)
|
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
|
return result
|
||||||
|
|
||||||
def doAddView(self, table_id, view_type, name):
|
def doAddView(self, table_id, view_type, name):
|
||||||
|
Loading…
Reference in New Issue
Block a user