From 1638527259a072dfc2ab286bd27bbb1751e8434e Mon Sep 17 00:00:00 2001
From: ljungster <parkerljung@gmail.com>
Date: Fri, 5 Aug 2022 08:30:35 -0500
Subject: stashing to look at master

---
 .../views/collections/CollectionNoteTakingView.tsx | 27 ++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

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

diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 9519e9aaa..3e2b8b762 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -74,7 +74,8 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
           this.layoutDoc._columnHeaders = new List<SchemaHeaderField>([new SchemaHeaderField('New Column')]);
           this.columnStartXCoords = [0]
           // add all of the docs that have not been added to a column to this new column
-        } else {
+        } 
+        else {
           const numHeaders = this.columnHeaders.length
           this.resizeColumns(numHeaders)
         }
@@ -457,6 +458,27 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
         return true;
     }
 
+    // Used in CollectionNoteTakingView to delete a column when the user clicks the delete button
+    // @action
+    // @undoBatch
+    // deleteColumn = (headingObject: SchemaHeaderField | undefined, docList: Doc[]) => {
+    //     if (!this.columnHeaders) {
+    //       return
+    //     }
+    //     if (headingObject) {
+    //       const index = this.columnHeaders.indexOf(headingObject);
+    //       const newIndex = index == 0 ? 1 : index - 1
+    //       const newHeader = this.columnHeaders[newIndex];
+    //       docList.forEach(d => d[this.pivotField] = newHeader.heading.toString())
+    //       // this.props.columnHeaders.splice(index, 1);
+    //       const newHeaders = this.columnHeaders;
+    //       newHeaders.splice(index, 1);
+    //       const test = this.layoutDoc._columnHeaders;
+    //       this.columnHeaders = newHeaders;
+    //       this.resizeColumns(newHeaders.length)
+    //     }
+    // }
+
     // when dropping outside of the current noteTaking context (like a new tab, freeform view, etc...)
     @undoBatch
     @action
@@ -554,12 +576,13 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
 
     // called when adding a new columnHeader
     @action
+    @undoBatch
     addGroup = (value: string) => {
         if (value && this.columnHeaders) {
-            this.resizeColumns(this.columnHeaders.length + 1)
             const schemaHdrField = new SchemaHeaderField(value);
             this.columnHeaders.push(schemaHdrField);
             DocUtils.addFieldEnumerations(undefined, this.pivotField, [{ title: value, _backgroundColor: "schemaHdrField.color" }]);
+            this.resizeColumns(this.columnHeaders.length + 1)
             return true;
         }
         return false;
-- 
cgit v1.2.3-70-g09d2

