diff options
author | mehekj <mehek.jethani@gmail.com> | 2022-08-18 14:28:58 -0400 |
---|---|---|
committer | mehekj <mehek.jethani@gmail.com> | 2022-08-18 14:28:58 -0400 |
commit | 14a938e8bf543ddaf7b8a9ae0c35cd725b5bdb77 (patch) | |
tree | 71aa0d903bff1646c5fafcf0991102b49a04a714 | |
parent | dd9f736e7b522be12267f34d35fe7e7993229afc (diff) |
col widths update on add/remove
-rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index a09d2722c..69a49598d 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -76,6 +76,15 @@ export class CollectionSchemaView extends CollectionSubView() { let currKeys = this.columnKeys; currKeys.splice(index, 0, 'title'); this.layoutDoc.columnKeys = new List<string>(currKeys); + + const newColWidth = this._minColWidth; + let currWidths = this.storedColumnWidths; + currWidths = currWidths.map(w => { + const proportion = w / (this.props.PanelWidth() - this._rowMenuWidth); + return proportion * (this.props.PanelWidth() - this._rowMenuWidth - newColWidth); + }); + currWidths.splice(index, 0, newColWidth); + this.layoutDoc.columnWidths = new List<number>(currWidths); }; @undoBatch @@ -84,6 +93,15 @@ export class CollectionSchemaView extends CollectionSubView() { let currKeys = this.columnKeys; currKeys.splice(index, 1); this.layoutDoc.columnKeys = new List<string>(currKeys); + + let currWidths = this.storedColumnWidths; + const removedColWidth = currWidths[index]; + currWidths = currWidths.map(w => { + const proportion = w / (this.props.PanelWidth() - this._rowMenuWidth - removedColWidth); + return proportion * (this.props.PanelWidth() - this._rowMenuWidth); + }); + currWidths.splice(index, 1); + this.layoutDoc.columnWidths = new List<number>(currWidths); }; @action @@ -123,7 +141,6 @@ export class CollectionSchemaView extends CollectionSubView() { return true; }; - // @undoBatch @action finishResize = () => { console.log('finished'); |