diff options
author | mehekj <mehek.jethani@gmail.com> | 2022-08-16 18:10:15 -0400 |
---|---|---|
committer | mehekj <mehek.jethani@gmail.com> | 2022-08-16 18:10:15 -0400 |
commit | fb1e291b1bed4b60a645030b4a79c0760ba73fdc (patch) | |
tree | 9ee64096b9231373743dc8714e2f6b891a14edce /src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | |
parent | a20a40b86bf5df9200218cb713f48e593c41b0ae (diff) |
add and remove columns (remove buggy for same named headers)
Diffstat (limited to 'src/client/views/collections/collectionSchema/CollectionSchemaView.tsx')
-rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index bcfa695f0..4d96d5f7e 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -55,8 +55,8 @@ export class CollectionSchemaView extends CollectionSubView() { ); } - @action @undoBatch + @action changeColumnKey = (index: number, newKey: string) => { let currKeys = this.columnKeys; currKeys[index] = newKey; @@ -64,6 +64,22 @@ export class CollectionSchemaView extends CollectionSubView() { return true; }; + @undoBatch + @action + addColumn = (index: number) => { + let currKeys = this.columnKeys; + currKeys.splice(index, 0, 'title'); + this.layoutDoc.columnKeys = new List<string>(currKeys); + }; + + @undoBatch + @action + removeColumn = (index: number) => { + let currKeys = this.columnKeys; + currKeys.splice(index, 1); + this.layoutDoc.columnKeys = new List<string>(currKeys); + }; + @action selectRow = (e: React.PointerEvent, doc: Doc, index: number) => { const ctrl = e.ctrlKey || e.metaKey; @@ -239,7 +255,7 @@ export class CollectionSchemaView extends CollectionSubView() { <div className="schema-table"> <div className="schema-header-row"> {this.columnKeys.map((key, index) => ( - <SchemaColumnHeader columnIndex={index} columnKeys={this.columnKeys} columnWidths={this.columnWidths} changeColumnKey={this.changeColumnKey} /> + <SchemaColumnHeader columnIndex={index} columnKeys={this.columnKeys} columnWidths={this.columnWidths} changeColumnKey={this.changeColumnKey} addColumn={this.addColumn} removeColumn={this.removeColumn} /> ))} </div> <div className="schema-table-content"> |