(core) Create an extra raw data widget when creating a table

Summary: This is the first step towards raw data views, merely adding metadata without any UI. Every 'normal' table now has a widget referenced by `rawViewSectionRef`. It has no parent view/page and cannot actually be viewed for now. The widget is created during the AddTable user action, and the migration creates a widget for existing tables.

Test Plan: Many tests had to be updated, especially tests that listed all view sections and/or fields.

Reviewers: jarek, dsagal

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3232
This commit is contained in:
Alex Hall
2022-02-01 20:48:39 +02:00
parent fd957577d3
commit fa9e6eee88
16 changed files with 368 additions and 207 deletions

View File

@@ -914,7 +914,11 @@
"parentId": 1, "parentKey": "record", "sortColRefs": "[]", "title": "" }],
["AddRecord", "_grist_Views_section_field", 1,
{"parentId": 1, "colRef": 34, "parentPos": 1.0}],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1}],
// Raw data widget
["AddRecord", "_grist_Views_section", 2, {"borderWidth": 1, "defaultWidth": 100, "parentKey": "record", "tableRef": 4}],
["AddRecord", "_grist_Views_section_field", 2, {"colRef": 34, "parentId": 2, "parentPos": 2.0}],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1, "rawViewSectionRef": 2}],
// Actions generated from AddColumn.
["AddColumn", "Bar", "world",
@@ -923,9 +927,10 @@
{"colId": "world", "parentPos": 13.0,
"formula": "rec.hello.upper()", "parentId": 4, "type": "Text",
"isFormula": true, "label": "world", "widgetOptions": ""}],
["AddRecord", "_grist_Views_section_field", 2, {"colRef": 35, "parentId": 1, "parentPos": 2.0}]
["AddRecord", "_grist_Views_section_field", 3, {"colRef": 35, "parentId": 1, "parentPos": 3.0}],
["AddRecord", "_grist_Views_section_field", 4, {"colRef": 35, "parentId": 2, "parentPos": 4.0}]
],
"direct": [true, true,
"direct": [true, true, true, true, true,
true, true, true, true, true, true, true,
true, true, true],
"undo": [
@@ -937,10 +942,13 @@
["RemoveRecord", "_grist_Pages", 1],
["RemoveRecord", "_grist_Views_section", 1],
["RemoveRecord", "_grist_Views_section_field", 1],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0}],
["RemoveRecord", "_grist_Views_section", 2],
["RemoveRecord", "_grist_Views_section_field", 2],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0, "rawViewSectionRef": 0}],
["RemoveColumn", "Bar", "world"],
["RemoveRecord", "_grist_Tables_column", 35],
["RemoveRecord", "_grist_Views_section_field", 2]
["RemoveRecord", "_grist_Views_section_field", 3],
["RemoveRecord", "_grist_Views_section_field", 4]
],
"retValue": [
{
@@ -1249,13 +1257,16 @@
"parentId": 1, "parentKey": "record", "sortColRefs": "[]", "title": ""}],
["BulkAddRecord", "_grist_Views_section_field", [1,2],
{"parentId": [1,1], "colRef": [31,32], "parentPos": [1.0,2.0]}],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1}],
["RemoveRecord", "_grist_Views_section_field", 1],
["AddRecord", "_grist_Views_section", 2, {"borderWidth": 1, "defaultWidth": 100, "parentKey": "record", "tableRef": 4}],
["BulkAddRecord", "_grist_Views_section_field", [3, 4], {"colRef": [31, 32], "parentId": [2, 2], "parentPos": [3.0, 4.0]}],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1, "rawViewSectionRef": 2}],
["BulkRemoveRecord", "_grist_Views_section_field", [1, 3]],
["RemoveRecord", "_grist_Tables_column", 31],
["RemoveColumn", "ViewTest", "hello"]
],
"direct": [true, true, true, true, true, true, true, true, true,
true, true,
true, true, true],
"undo": [
["RemoveTable", "ViewTest"],
@@ -1266,9 +1277,10 @@
["RemoveRecord", "_grist_Pages", 1],
["RemoveRecord", "_grist_Views_section", 1],
["BulkRemoveRecord", "_grist_Views_section_field", [1,2]],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0}],
["AddRecord", "_grist_Views_section_field", 1,
{"parentId": 1, "colRef": 31, "parentPos": 1.0}],
["RemoveRecord", "_grist_Views_section", 2],
["BulkRemoveRecord", "_grist_Views_section_field", [3, 4]],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0, "rawViewSectionRef": 0}],
["BulkAddRecord", "_grist_Views_section_field", [1, 3], {"colRef": [31, 31], "parentId": [1, 2], "parentPos": [1.0, 3.0]}],
["AddRecord", "_grist_Tables_column", 31,
{"colId": "hello", "parentPos": 9.0,
"parentId": 4, "type": "Text"
@@ -2188,8 +2200,8 @@
["AddRecord", "_grist_Views_section", 1,
{"tableRef": 4, "defaultWidth": 100, "borderWidth": 1,
"parentId": 1, "parentKey": "record", "sortColRefs": "[]", "title": ""}],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1}],
["AddRecord", "_grist_Views_section", 2, {"borderWidth": 1, "defaultWidth": 100, "parentKey": "record", "tableRef": 4}],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1, "rawViewSectionRef": 2}],
["AddTable", "Bar", [
{"id": "manualSort", "formula": "", "isFormula": false, "type": "ManualSortPos"},
{"isFormula": false, "formula": "", "type": "Text", "id": "hello"},
@@ -2213,18 +2225,21 @@
{"type": "raw_data", "name": "Bar"}],
["AddRecord", "_grist_TabBar", 2, {"tabPos": 2.0, "viewRef": 2}],
["AddRecord", "_grist_Pages", 2, {"pagePos": 2.0, "viewRef": 2, "indentation": 0}],
["AddRecord", "_grist_Views_section", 2,
["AddRecord", "_grist_Views_section", 3,
{"tableRef": 5, "defaultWidth": 100, "borderWidth": 1,
"parentId": 2, "parentKey": "record", "sortColRefs": "[]", "title": ""}],
["BulkAddRecord", "_grist_Views_section_field", [1,2,3],
{"parentId": [2,2,2], "colRef": [32,33,34], "parentPos": [1.0,2.0,3.0]}],
["UpdateRecord", "_grist_Tables", 5, {"primaryViewId": 2}],
{"parentId": [3,3,3], "colRef": [32,33,34], "parentPos": [1.0,2.0,3.0]}],
["AddRecord", "_grist_Views_section", 4, {"borderWidth": 1, "defaultWidth": 100, "parentKey": "record", "tableRef": 5}],
["BulkAddRecord", "_grist_Views_section_field", [4, 5, 6], {"colRef": [32, 33, 34], "parentId": [4, 4, 4], "parentPos": [4.0, 5.0, 6.0]}],
["UpdateRecord", "_grist_Tables", 5, {"primaryViewId": 2, "rawViewSectionRef": 4}],
["AddRecord", "Bar", 1, {"foo": 0, "hello": "a", "manualSort": 1.0}],
["AddRecord", "Bar", 2, {"foo": 1, "hello": "b", "manualSort": 2.0}],
["AddRecord", "Bar", 3, {"foo": 1, "hello": "c", "manualSort": 3.0}],
["BulkUpdateRecord", "Bar", [1, 2, 3], {"world": ["A", "B", "C"]}]
],
"direct": [true, true, true, true, true, true, true, true,
true, true, true,
true, true, true, true, true, true, true, true, true,
true, true, true, false],
"undo": [
@@ -2235,16 +2250,19 @@
["RemoveRecord", "_grist_TabBar", 1],
["RemoveRecord", "_grist_Pages", 1],
["RemoveRecord", "_grist_Views_section", 1],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0}],
["RemoveRecord", "_grist_Views_section", 2],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0, "rawViewSectionRef": 0}],
["RemoveTable", "Bar"],
["RemoveRecord", "_grist_Tables", 5],
["BulkRemoveRecord", "_grist_Tables_column", [31,32,33,34]],
["RemoveRecord", "_grist_Views", 2],
["RemoveRecord", "_grist_TabBar", 2],
["RemoveRecord", "_grist_Pages", 2],
["RemoveRecord", "_grist_Views_section", 2],
["RemoveRecord", "_grist_Views_section", 3],
["BulkRemoveRecord", "_grist_Views_section_field", [1,2,3]],
["UpdateRecord", "_grist_Tables", 5, {"primaryViewId": 0}],
["RemoveRecord", "_grist_Views_section", 4],
["BulkRemoveRecord", "_grist_Views_section_field", [4, 5, 6]],
["UpdateRecord", "_grist_Tables", 5, {"primaryViewId": 0, "rawViewSectionRef": 0}],
["RemoveRecord", "Bar", 1],
["RemoveRecord", "Bar", 2],
["RemoveRecord", "Bar", 3]
@@ -2265,7 +2283,7 @@
"id": 5,
"columns": ["hello", "world", "foo"],
"views": [
{ "sections": [ 2 ], "id": 2 }
{ "sections": [ 3 ], "id": 2 }
]
},
// AddRecord retValues
@@ -2315,10 +2333,12 @@
["AddRecord", "_grist_Views_section", 1,
{"tableRef": 4, "defaultWidth": 100, "borderWidth": 1,
"parentId": 1, "parentKey": "record", "sortColRefs": "[]", "title": ""}],
// Raw data widget
["AddRecord", "_grist_Views_section", 2, {"borderWidth": 1, "defaultWidth": 100, "parentKey": "record", "tableRef": 4}],
// As part of adding a table, we also set the primaryViewId.
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1}]
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 1, "rawViewSectionRef": 2}]
],
"direct": [true, true, true, true, true, true, true, true],
"direct": [true, true, true, true, true, true, true, true, true],
"undo": [
["RemoveTable", "Foo"],
["RemoveRecord", "_grist_Tables", 4],
@@ -2327,7 +2347,8 @@
["RemoveRecord", "_grist_TabBar", 1],
["RemoveRecord", "_grist_Pages", 1],
["RemoveRecord", "_grist_Views_section", 1],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0}]
["RemoveRecord", "_grist_Views_section", 2],
["UpdateRecord", "_grist_Tables", 4, {"primaryViewId": 0, "rawViewSectionRef": 0}]
]
}
}],
@@ -2340,7 +2361,8 @@
"USER_ACTION": ["RemoveTable", "Foo"],
"ACTIONS": {
"stored": [
["RemoveRecord", "_grist_Views_section", 1],
["BulkRemoveRecord", "_grist_Views_section", [1, 2]],
["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 0}],
["RemoveRecord", "_grist_TabBar", 1],
["RemoveRecord", "_grist_Pages", 1],
["RemoveRecord", "_grist_Views", 1],
@@ -2349,11 +2371,12 @@
["RemoveRecord", "_grist_Tables", 4],
["RemoveTable", "Foo"]
],
"direct": [true, true, true, true, true, true, true, true],
"direct": [true, true, true, true, true, true, true, true, true],
"undo": [
["AddRecord", "_grist_Views_section", 1,
{"tableRef": 4, "defaultWidth": 100, "borderWidth": 1,
"parentId": 1, "parentKey": "record", "sortColRefs": "[]"}],
["BulkAddRecord", "_grist_Views_section", [1, 2],
{"borderWidth": [1, 1], "defaultWidth": [100, 100], "parentId": [1, 0],
"parentKey": ["record", "record"], "sortColRefs": ["[]", ""], "tableRef": [4, 4]}],
["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 2}],
["AddRecord", "_grist_TabBar", 1, {"tabPos": 1.0, "viewRef": 1}],
["AddRecord", "_grist_Pages", 1, {"pagePos": 1.0, "viewRef": 1}],
["AddRecord", "_grist_Views", 1, {"name": "Foo", "type": "raw_data"}],