diff options
| author | mehekj <mehek.jethani@gmail.com> | 2022-11-14 10:22:29 -0500 |
|---|---|---|
| committer | mehekj <mehek.jethani@gmail.com> | 2022-11-14 10:22:29 -0500 |
| commit | c3d7e526247dd6225af5146e93a0001d56a84c29 (patch) | |
| tree | ca95eef5e516e8c486bfab28deecd12d5874c0f7 /src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | |
| parent | a73521cdbccf9bed1326d24522e133fad4a0de26 (diff) | |
added menu for creating new keys
Diffstat (limited to 'src/client/views/collections/collectionSchema/CollectionSchemaView.tsx')
| -rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 7516b95b8..0466ce343 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -79,26 +79,25 @@ export class CollectionSchemaView extends CollectionSubView() { @undoBatch @action - changeColumnKey = (index: number, newKey: string) => { + changeColumnKey = (index: number, newKey: string, defaultVal?: any) => { if (!this.documentKeys.includes(newKey)) { - this.addNewKey(newKey); + this.addNewKey(newKey, defaultVal); } let currKeys = this.columnKeys; currKeys[index] = newKey; this.layoutDoc.columnKeys = new List<string>(currKeys); - return true; }; @undoBatch @action - addColumn = (index: number, key: string) => { + addColumn = (index: number, key: string, defaultVal?: any) => { if (!this.documentKeys.includes(key)) { - this.addNewKey(key); + this.addNewKey(key, defaultVal); } - const newColWidth = this._minColWidth; let currWidths = this.storedColumnWidths; + const newColWidth = this.props.PanelWidth() / (currWidths.length + 1); currWidths = currWidths.map(w => { const proportion = w / (this.props.PanelWidth() - this._rowMenuWidth); return proportion * (this.props.PanelWidth() - this._rowMenuWidth - newColWidth); @@ -112,8 +111,9 @@ export class CollectionSchemaView extends CollectionSubView() { }; @action - addNewKey = (key: string) => { - this.childDocs.forEach(doc => (doc[key] = key + ' default val')); + addNewKey = (key: string, defaultVal: any) => { + console.log(defaultVal); + this.childDocs.forEach(doc => (doc[key] = defaultVal)); }; @undoBatch |
