From 5425b61d62beef22d068e259ae3e2003f08e0c05 Mon Sep 17 00:00:00 2001
From: mehekj <mehek.jethani@gmail.com>
Date: Mon, 24 Oct 2022 15:06:47 -0400
Subject: switched drag element to show rows

---
 .../collectionSchema/CollectionSchemaView.tsx      | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

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

diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 69a49598d..84a69d4b9 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -1,5 +1,5 @@
 import React = require('react');
-import { action, computed, observable, ObservableSet } from 'mobx';
+import { action, computed, observable, ObservableMap, ObservableSet } from 'mobx';
 import { observer } from 'mobx-react';
 import { Doc, DocListCast } from '../../../../fields/Doc';
 import { Id } from '../../../../fields/FieldSymbols';
@@ -41,7 +41,7 @@ export class CollectionSchemaView extends CollectionSubView() {
     private _minColWidth: number = 120;
 
     @observable _rowMenuWidth: number = 100;
-    @observable _selectedDocs: ObservableSet = new ObservableSet<SchemaRowBox>();
+    @observable _selectedDocs: ObservableMap = new ObservableMap<SchemaRowBox, HTMLDivElement>();
     @observable _isDragging: boolean = false;
     @observable _displayColumnWidths: number[] | undefined;
 
@@ -149,7 +149,7 @@ export class CollectionSchemaView extends CollectionSubView() {
     };
 
     @action
-    selectRow = (e: React.PointerEvent, doc: Doc, index: number) => {
+    selectRow = (e: React.PointerEvent, doc: Doc, ref: HTMLDivElement, index: number) => {
         const ctrl = e.ctrlKey || e.metaKey;
         const shift = e.shiftKey;
         if (shift && this._lastSelectedRow !== undefined) {
@@ -157,19 +157,19 @@ export class CollectionSchemaView extends CollectionSubView() {
             const endRow = Math.max(this._lastSelectedRow, index);
             for (let i = startRow; i <= endRow; i++) {
                 const currDoc: Doc = this.childDocs[i];
-                if (!this._selectedDocs.has(currDoc)) this._selectedDocs.add(currDoc);
+                if (!this._selectedDocs.has(currDoc)) this._selectedDocs.set(currDoc, ref);
             }
             this._lastSelectedRow = endRow;
         } else if (ctrl) {
             if (!this._selectedDocs.has(doc)) {
-                this._selectedDocs.add(doc);
+                this._selectedDocs.set(doc, ref);
                 this._lastSelectedRow = index;
             } else {
                 this._selectedDocs.delete(doc);
             }
         } else {
             this._selectedDocs.clear();
-            this._selectedDocs.add(doc);
+            this._selectedDocs.set(doc, ref);
             this._lastSelectedRow = index;
         }
 
@@ -219,25 +219,25 @@ export class CollectionSchemaView extends CollectionSubView() {
     };
 
     @action
-    startDrag = (e: React.PointerEvent, doc: Doc) => {
+    startDrag = (e: React.PointerEvent, doc: Doc, ref: HTMLDivElement, index: number) => {
         if (!this._selectedDocs.has(doc)) {
             this._selectedDocs.clear();
-            this._selectedDocs.add(doc);
-            this._lastSelectedRow = this.childDocs.indexOf(doc);
+            this._selectedDocs.set(doc, ref);
+            this._lastSelectedRow = index;
             SelectionManager.SelectSchemaViewDoc(doc);
         }
         this._isDragging = true;
         this._selectedDocSortedArray = this.sortedSelectedDocs();
         const dragData = new DragManager.DocumentDragData(this._selectedDocSortedArray, 'move');
         dragData.moveDocument = this.props.moveDocument;
-        const dragItem: HTMLElement[] = [];
-        const dragDiv = document.createElement('div');
-        dragDiv.className = 'presItem-multiDrag';
-        dragDiv.innerText = 'Move ' + this._selectedDocs.size + '  row' + (this._selectedDocs.size > 1 ? 's' : '');
-        dragDiv.style.position = 'absolute';
-        dragDiv.style.top = e.clientY + 'px';
-        dragDiv.style.left = e.clientX - 50 + 'px';
-        dragItem.push(dragDiv);
+        const dragItem: HTMLElement[] = Array.from(this._selectedDocs.values());
+        // const dragDiv = document.createElement('div');
+        // dragDiv.className = 'presItem-multiDrag';
+        // dragDiv.innerText = 'Move ' + this._selectedDocs.size + '  row' + (this._selectedDocs.size > 1 ? 's' : '');
+        // dragDiv.style.position = 'absolute';
+        // dragDiv.style.top = e.clientY + 'px';
+        // dragDiv.style.left = e.clientX - 50 + 'px';
+        // dragItem.push(dragDiv);
 
         DragManager.StartDocumentDrag(
             dragItem.map(ele => ele),
-- 
cgit v1.2.3-70-g09d2

