diff options
Diffstat (limited to 'src/client/views/collections/CollectionNoteTakingView.tsx')
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingView.tsx | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 0aa1b6839..447e1f0c8 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -368,18 +368,27 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti return Math.min(childHeight, maxHeight, panelHeight); } - // called when a column is either added or deleted. This function creates n evenly spaced columns + // called when a column is either added or deleted. + // TODO: this needs help still @action - resizeColumns = (n: number, isAdd: boolean) => { + resizeColumns = (isAdd: boolean, colWidth: number, colIndex: number) => { + const n = this.columnHeaders.length; if (n == 1) { - this.columnHeaders[0].setWidth(1); - return; + this.columnHeaders[0].setWidth(1); + return true; } - let scaleFactor = isAdd ? (n - 1) / n : (n + 1) / n; - // if (isAdd && n == 1) scaleFactor = 1; - this.columnHeaders.forEach(h => { - h.width < 0 ? h.setWidth(1 / n) : h.setWidth(h.width * scaleFactor); + const scaleFactor = isAdd ? 1 - colWidth : 1 / (1 - colWidth); + this.columnHeaders.forEach((h, i) => { + if (!(isAdd && i == colIndex)) { + h.width < 0 ? h.setWidth(1 / n) : h.setWidth(h.width * scaleFactor); + } }); + return true; + // let scaleFactor = isAdd ? (n - 1) / n : (n + 1) / n; + // // if (isAdd && n == 1) scaleFactor = 1; + // this.columnHeaders.forEach(h => { + // h.width < 0 ? h.setWidth(1 / n) : h.setWidth(h.width * scaleFactor); + // }); // if we're adding, need to // const newColXCoords: number[] = []; @@ -638,9 +647,8 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti @undoBatch addGroup = (value: string) => { const columnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null); - // const colWidth = (this.PanelWidth - this.numGroupColumns * this.dividerWidth) / (this.numGroupColumns + 1); - this.resizeColumns(this.numGroupColumns + 1, true); - return value && columnHeaders?.push(new SchemaHeaderField(value, undefined, undefined, 1 / (this.numGroupColumns + 1))) ? true : false; + const newColWidth = 1 / (this.numGroupColumns + 1); + return value && columnHeaders?.push(new SchemaHeaderField(value, undefined, undefined, newColWidth)) && this.resizeColumns(true, newColWidth, this.columnHeaders.length - 1) ? true : false; }; sortFunc = (a: [SchemaHeaderField, Doc[]], b: [SchemaHeaderField, Doc[]]): 1 | -1 => { |