From 7b7374c4b20a0488c74b49cdc50daa6867dce2a9 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 5 Aug 2022 10:51:55 -0400
Subject: fixed undo of adding column in notetaking view

---
 .../views/collections/CollectionNoteTakingView.tsx | 25 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 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 e0c79a265..c07473ee1 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -44,8 +44,8 @@ export type collectionNoteTakingViewProps = {
 export class CollectionNoteTakingView extends CollectionSubView<Partial<collectionNoteTakingViewProps>>() {
     _disposers: { [key: string]: IReactionDisposer } = {};
     _masonryGridRef: HTMLDivElement | null = null;
-    _draggerRef = React.createRef<HTMLDivElement>();
-    @observable columnStartXCoords: number[] = [];
+    _draggerRef = React.createRef<HTMLDivElement>(); // change to relative widths for deleting.  change storage from columnStartXCoords to columnHeaders (schemaHeaderFields has a widgth alrady)
+    @observable columnStartXCoords: number[] = []; // columnHeaders -- SchemaHeaderField -- widht
     @observable docsDraggedRowCol: number[] = [];
     @observable _cursor: CursorProperty = 'grab';
     @observable _scroll = 0; // used to force the document decoration to update when scrolling
@@ -58,6 +58,22 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
         const needsUnsetCategory = docs.some(d => {
             return !d[this.notetakingCategoryField] && !columnHeaders.find(sh => sh.heading === 'unset');
         });
+
+        //  @#Oberable draggedColIndex = ...
+        //@observable cloneDivXYcoords
+        // @observable clonedDiv...
+
+        // render() {
+        //    { this.clonedDiv ? <div clone styule={{transform: clonedDivXYCoords}} : null}
+        // }
+
+        //  in NoteatakinView Column code, add a poinerDown handler that calls setupMoveUpEvents() which will clone the column div
+        //    and re-render it under the cursor during move events.
+        //    that move move event will update 2 observales -- the draggedColIndex up above, and the location of the clonedDiv so that the render in this view will know where to render the cloned div
+        // add observable variable that tells drag column to rnder in a different location than where the schemaHeaderFiel sa y ot.
+        // if (col 1 is where col 3) {
+        //     return 3 2 1 4 56
+        // }
         if (needsUnsetCategory) {
             columnHeaders.push(new SchemaHeaderField('unset'));
         }
@@ -98,8 +114,6 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
         if (this.columnHeaders === undefined) {
             this.dataDoc.columnHeaders = new List<SchemaHeaderField>([new SchemaHeaderField('New Column')]);
             // add all of the docs that have not been added to a column to this new column
-        } else {
-            this.resizeColumns(this.columnHeaders.length);
         }
     }
 
@@ -573,6 +587,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
     };
 
     // called when adding a new columnHeader
+    @undoBatch
     @action
     addGroup = (value: string) => {
         if (value && this.columnHeaders) {
@@ -618,7 +633,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
         //     sections = this.layoutDoc._columnsSort ? entries.sort(this.sortFunc) : entries;
         // }
         const entries = Array.from(this.Sections.entries());
-        const sections = entries.sort(this.sortFunc);
+        const sections = entries; //.sort(this.sortFunc);
         const eles: JSX.Element[] = [];
         for (let i = 0; i < sections.length; i++) {
             const col = this.sectionNoteTaking(sections[i][0], sections[i][1]);
-- 
cgit v1.2.3-70-g09d2

