From b9686678573ee601da90b07d62da175a2f64c40c Mon Sep 17 00:00:00 2001
From: ljungster <parkerljung@gmail.com>
Date: Wed, 22 Jun 2022 11:54:09 -0500
Subject: working but not persistent

---
 .../views/collections/CollectionNoteTakingView.tsx | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 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 302e7c890..dfee1b173 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -363,11 +363,11 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
           pos0 = pos1
         })
         // we alter the pivot fields of the docs in case they are moved to a new column.
-        // const colIndex = this.getColumnFromXCoord(xCoord)
-        // const colHeader = StrCast(this.columnHeaders[colIndex].heading)
-        // DragManager.docsBeingDragged.forEach(d => d[this.pivotField] = colHeader)
+        const colIndex = this.getColumnFromXCoord(xCoord)
+        const colHeader = StrCast(this.columnHeaders[colIndex].heading)
+        DragManager.docsBeingDragged.forEach(d => d[this.pivotField] = colHeader)
         // used to notify sections to re-render
-        console.log([dropInd, this.getColumnFromXCoord(xCoord)])
+        // console.log([dropInd, this.getColumnFromXCoord(xCoord)])
         this.docsDraggedRowCol = [dropInd, this.getColumnFromXCoord(xCoord)]
       }
     }
@@ -375,8 +375,8 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
     // returns the column index for a given x-coordinate
     getColumnFromXCoord = (xCoord: number): number => {
         const numColumns = this.columnHeaders.length
-        const coords = this.columnStartXCoords
-        coords.push(this.props.PanelWidth())
+        const coords = this.columnStartXCoords.slice()
+        coords.push(this.PanelWidth)
         let colIndex = 0
         for (let i = 0; i < numColumns; i++) {
             if (xCoord > coords[i] && xCoord < coords[i + 1]) {
@@ -412,7 +412,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
         if (de.complete.docDragData) {
             if (super.onInternalDrop(e, de)) {
               DragManager.docsBeingDragged = []
-              this.docsDraggedRowCol = []
+              // this.docsDraggedRowCol = []
               // filter out the currently dragged docs from the child docs, since we will insert them later
               const rowCol = this.docsDraggedRowCol
               const droppedDocs = this.childDocs.slice().filter((d: Doc, ind: number) => ind >= this.childDocs.length); // if the drop operation adds something to the end of the list, then use that as the new document (may be different than what was dropped e.g., in the case of a button which is dropped but which creates say, a note).
@@ -422,14 +422,14 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
               if (docs && newDocs.length) {
                 // remove the dragged documents from the childDocList
                 newDocs.filter(d => docs.indexOf(d) !== -1).forEach(d => docs.splice(docs.indexOf(d), 1))
-                // if the doc starts a columnm (or the drop index is undefined), we can just push it to the back. Otherwise we need to add it to the column properly
+                // if the doc starts a columnm (or the drop index is undefined), we can just push it to the front. Otherwise we need to add it to the column properly
+                //TODO: you need to update childDocList instead. It seems that childDocs is a copy of the actual array we want to modify
                 if (rowCol[0] <= 0) {
-                  docs.splice(docs.length - 1, 0, ...newDocs)
+                  docs.unshift(...newDocs)
                 } else {
                   const colDocs = this.getDocsFromXCoord(de.x)
                   const previousDoc = colDocs[rowCol[0] - 1]
-                  const previousDocIndex = this.childDocs.findIndex(d => {d[Id] == previousDoc[Id]})
-                  //TODO: removing the doc instead of doing what we expect it to do
+                  const previousDocIndex = docs.indexOf(previousDoc)
                   docs.splice(previousDocIndex, 0, ...newDocs)
                 }
               }
-- 
cgit v1.2.3-70-g09d2

