From 14a938e8bf543ddaf7b8a9ae0c35cd725b5bdb77 Mon Sep 17 00:00:00 2001 From: mehekj Date: Thu, 18 Aug 2022 14:28:58 -0400 Subject: col widths update on add/remove --- .../collectionSchema/CollectionSchemaView.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') 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(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(currWidths); }; @undoBatch @@ -84,6 +93,15 @@ export class CollectionSchemaView extends CollectionSubView() { let currKeys = this.columnKeys; currKeys.splice(index, 1); this.layoutDoc.columnKeys = new List(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(currWidths); }; @action @@ -123,7 +141,6 @@ export class CollectionSchemaView extends CollectionSubView() { return true; }; - // @undoBatch @action finishResize = () => { console.log('finished'); -- cgit v1.2.3-70-g09d2