From 862133dc5e45ac56b7d5389d08931a9aaa32301a Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 1 Mar 2023 15:23:21 -0500
Subject: fixed notetakingview - docs fitting in columns, resizing columns

---
 .../collections/CollectionNoteTakingViewColumn.tsx | 61 ++++++++++------------
 1 file changed, 28 insertions(+), 33 deletions(-)

(limited to 'src/client/views/collections/CollectionNoteTakingViewColumn.tsx')

diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index 84d1c0205..ec6a2bec8 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -44,8 +44,7 @@ interface CSVFieldColumnProps {
     observeHeight: (myref: any) => void;
     unobserveHeight: (myref: any) => void;
     editableViewProps: () => any;
-    resizeColumns: (isAdd: boolean, colWidth: number, colIndex: number) => boolean;
-    PanelWidth: number;
+    resizeColumns: (isAdd: boolean, headers: SchemaHeaderField[], colIndex: number) => boolean;
     maxColWidth: number;
     dividerWidth: number;
     availableWidth: number;
@@ -141,18 +140,12 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
     @undoBatch
     @action
     deleteColumn = () => {
-        const acolumnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null);
-        if (acolumnHeaders && this.props.headingObject) {
-            const index = acolumnHeaders.indexOf(this.props.headingObject);
-            const columnHeaders = acolumnHeaders; // new List<SchemaHeaderField>(acolumnHeaders.map(header => header[Copy]())); // needed for undo to work properly.  otherwise we end up changing field values in the undo stack since they are shared by reference
-            const newColIndex = index > 0 ? index - 1 : 1;
-            const newColHeader = this.props.columnHeaders ? this.props.columnHeaders[newColIndex] : undefined;
-            const newHeading = newColHeader ? newColHeader.heading : 'unset';
-            this.props.docList.forEach(d => (d[this.props.pivotField] = newHeading));
-            const colWidth = this.props.columnHeaders ? this.props.columnHeaders[index].width : 0;
+        const columnHeaders = Array.from(Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null));
+        if (this.props.headingObject) {
+            const index = columnHeaders.indexOf(this.props.headingObject);
+            this.props.docList.forEach(d => (d[this.props.pivotField] = undefined));
             columnHeaders.splice(index, 1);
-            //Doc.GetProto(this.props.Document).columnHeaders = columnHeaders;
-            this.props.resizeColumns(false, colWidth, index);
+            this.props.resizeColumns(false, columnHeaders, index);
         }
     };
 
@@ -262,28 +255,30 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
         return (
             <>
                 {headingView}
-                <div className="collectionNoteTakingView-columnStack">
-                    <div
-                        key={`${heading}-stack`}
-                        className={`collectionNoteTakingView-Nodes`}
-                        style={{
-                            padding: `${columnYMargin}px ${0}px ${this.props.yMargin}px ${0}px`,
-                            gridGap: this.props.gridGap,
-                            gridTemplateColumns: templatecols,
-                        }}>
-                        {this.props.renderChildren(this.props.docList)}
-                    </div>
+                <div className="collectionNoteTakingView-columnStackContainer">
+                    <div className="collectionNoteTakingView-columnStack">
+                        <div
+                            key={`${heading}-stack`}
+                            className={`collectionNoteTakingView-Nodes`}
+                            style={{
+                                padding: `${columnYMargin}px ${0}px ${this.props.yMargin}px ${0}px`,
+                                gridGap: this.props.gridGap,
+                                gridTemplateColumns: templatecols,
+                            }}>
+                            {this.props.renderChildren(this.props.docList)}
+                        </div>
 
-                    {!this.props.chromeHidden && type !== DocumentType.PRES ? (
-                        <div className="collectionNoteTakingView-DocumentButtons" style={{ marginBottom: 10 }}>
-                            <div key={`${heading}-add-document`} className="collectionNoteTakingView-addDocumentButton">
-                                <EditableView GetValue={returnEmptyString} SetValue={this.addNewTextDoc} textCallback={this.textCallback} placeholder={"Type ':' for commands"} contents={'+ New Node'} menuCallback={this.menuCallback} />
-                            </div>
-                            <div key={`${this.props.Document[Id]}-addGroup`} className="collectionNoteTakingView-addDocumentButton">
-                                <EditableView {...this.props.editableViewProps()} />
+                        {!this.props.chromeHidden && type !== DocumentType.PRES ? (
+                            <div className="collectionNoteTakingView-DocumentButtons" style={{ marginBottom: 10 }}>
+                                <div key={`${heading}-add-document`} className="collectionNoteTakingView-addDocumentButton">
+                                    <EditableView GetValue={returnEmptyString} SetValue={this.addNewTextDoc} textCallback={this.textCallback} placeholder={"Type ':' for commands"} contents={'+ New Node'} menuCallback={this.menuCallback} />
+                                </div>
+                                <div key={`${this.props.Document[Id]}-addGroup`} className="collectionNoteTakingView-addDocumentButton">
+                                    <EditableView {...this.props.editableViewProps()} />
+                                </div>
                             </div>
-                        </div>
-                    ) : null}
+                        ) : null}
+                    </div>
                 </div>
             </>
         );
-- 
cgit v1.2.3-70-g09d2


From 9c29092fc9df29c02cc83885e4ba5645b71867d4 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 1 Mar 2023 15:45:03 -0500
Subject: fix to notetakingiview resizing when deleting a column to force an
 unset column

---
 src/client/views/DocumentDecorations.tsx                     |  2 +-
 src/client/views/collections/CollectionNoteTakingView.tsx    | 12 ++++++------
 .../views/collections/CollectionNoteTakingViewColumn.tsx     |  7 +++----
 3 files changed, 10 insertions(+), 11 deletions(-)

(limited to 'src/client/views/collections/CollectionNoteTakingViewColumn.tsx')

diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index eeef01d17..2982f8a99 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -797,7 +797,7 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number; P
         const resizerScheme = colorScheme ? 'documentDecorations-resizer' + colorScheme : '';
 
         // Radius constants
-        const useRounding = seldocview.ComponentView instanceof ImageBox || seldocview.ComponentView instanceof FormattedTextBox;
+        const useRounding = seldocview.ComponentView instanceof ImageBox || seldocview.ComponentView instanceof FormattedTextBox || seldocview.ComponentView instanceof CollectionFreeFormView;
         const borderRadius = numberValue(StrCast(seldocview.rootDoc.borderRounding));
         const docMax = Math.min(NumCast(seldocview.rootDoc.width) / 2, NumCast(seldocview.rootDoc.height) / 2);
         const maxDist = Math.min((this.Bounds.r - this.Bounds.x) / 2, (this.Bounds.b - this.Bounds.y) / 2);
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index edd5ba96c..0e1601f35 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -55,11 +55,11 @@ export class CollectionNoteTakingView extends CollectionSubView() {
         const needsUnsetCategory = this.childDocs.some(d => !d[this.notetakingCategoryField] && !columnHeaders?.find(sh => sh.heading === 'unset'));
         if (needsUnsetCategory || columnHeaders === undefined || columnHeaders.length === 0) {
             setTimeout(() => {
-                const columnHeaders = Cast(this.dataDoc.columnHeaders, listSpec(SchemaHeaderField), null);
+                const columnHeaders = Array.from(Cast(this.dataDoc.columnHeaders, listSpec(SchemaHeaderField), null));
                 const needsUnsetCategory = this.childDocs.some(d => !d[this.notetakingCategoryField] && !columnHeaders?.find(sh => sh.heading === 'unset'));
-                if (needsUnsetCategory || columnHeaders === undefined || columnHeaders.length === 0) {
-                    if (columnHeaders) columnHeaders.push(new SchemaHeaderField('unset', undefined, undefined, 1));
-                    else this.dataDoc.columnHeaders = new List<SchemaHeaderField>();
+                if (needsUnsetCategory || columnHeaders.length === 0) {
+                    columnHeaders.push(new SchemaHeaderField('unset', undefined, undefined, 1));
+                    this.resizeColumns(columnHeaders);
                 }
             });
         }
@@ -321,7 +321,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
     // Removing example: column widths are [0.5, 0.30, 0.20] --> user deletes the final column --> column widths are [0.625, 0.375].
     // Adding example: column widths are [0.6, 0.4] --> user adds column at end --> column widths are [0.4, 0.267, 0.33]
     @action
-    resizeColumns = (isAdd: boolean, headers: SchemaHeaderField[], colIndex: number) => {
+    resizeColumns = (headers: SchemaHeaderField[]) => {
         const n = headers.length;
         const curWidths = headers.reduce((sum, hdr) => sum + Math.abs(hdr.width), 0);
         const scaleFactor = 1 / curWidths;
@@ -563,7 +563,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
         const columnHeaders = Array.from(Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null));
         const newColWidth = 1 / (this.numGroupColumns + 1);
         columnHeaders.push(new SchemaHeaderField(value, undefined, undefined, newColWidth));
-        value && this.resizeColumns(true, columnHeaders, this.columnHeaders.length - 1);
+        value && this.resizeColumns(columnHeaders);
         return true;
     };
 
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index ec6a2bec8..829d055e5 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -44,7 +44,7 @@ interface CSVFieldColumnProps {
     observeHeight: (myref: any) => void;
     unobserveHeight: (myref: any) => void;
     editableViewProps: () => any;
-    resizeColumns: (isAdd: boolean, headers: SchemaHeaderField[], colIndex: number) => boolean;
+    resizeColumns: (headers: SchemaHeaderField[]) => boolean;
     maxColWidth: number;
     dividerWidth: number;
     availableWidth: number;
@@ -142,10 +142,9 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
     deleteColumn = () => {
         const columnHeaders = Array.from(Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null));
         if (this.props.headingObject) {
-            const index = columnHeaders.indexOf(this.props.headingObject);
             this.props.docList.forEach(d => (d[this.props.pivotField] = undefined));
-            columnHeaders.splice(index, 1);
-            this.props.resizeColumns(false, columnHeaders, index);
+            columnHeaders.splice(columnHeaders.indexOf(this.props.headingObject), 1);
+            this.props.resizeColumns(columnHeaders);
         }
     };
 
-- 
cgit v1.2.3-70-g09d2

