diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-04-24 06:08:45 -0400 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-04-24 06:08:45 -0400 |
commit | 8d88cb8828ba338f203b2e90486e16afe1f7de68 (patch) | |
tree | bbe18f55f4802fc189f0fa31cb93fe14113a2381 | |
parent | 44b1b4f68a1385980b4f5fa6fbd6ffe6fb018fda (diff) |
nothing broke; column dragging visual update kind of works
-rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index e826a7f99..710556c8a 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -29,6 +29,7 @@ import './CollectionSchemaView.scss'; import { SchemaColumnHeader } from './SchemaColumnHeader'; import { SchemaRowBox } from './SchemaRowBox'; import { TbEmphasis } from 'react-icons/tb'; +import { collapseTextChangeRangesAcrossMultipleVersions } from 'typescript'; const { default: { SCHEMA_NEW_NODE_HEIGHT } } = require('../../global/globalCssVariables.module.scss'); // prettier-ignore export enum ColumnType { @@ -94,6 +95,7 @@ export class CollectionSchemaView extends CollectionSubView() { @observable _lowestSelectedIndex = -1; //lowest index among selected rows; used to properly sync dragged docs with cursor position @observable _relCursorIndex = -1; //cursor index relative to the current selected cells @observable _draggedColIndex = 0; + @observable _colBeingDragged = false; // target HTMLelement portal for showing a popup menu to edit cell values. public get MenuTarget() { @@ -383,6 +385,7 @@ export class CollectionSchemaView extends CollectionSubView() { @action dragColumn = (e: PointerEvent, index: number) => { this._draggedColIndex = index; + this._colBeingDragged = true; const dragData = new DragManager.ColumnDragData(index); const dragEles = [this._colEles[index]]; this.childDocs.forEach(doc => dragEles.push(this._rowEles.get(doc).children[1].children[index])); @@ -555,8 +558,8 @@ export class CollectionSchemaView extends CollectionSubView() { @computed get rowDropIndex(){ - let mouseY = this.ScreenToLocalBoxXf().transformPoint(this._mouseCoordinates.x, this._mouseCoordinates.y)[1]; - let index = this.findRowDropIndex(mouseY); + const mouseY = this.ScreenToLocalBoxXf().transformPoint(this._mouseCoordinates.x, this._mouseCoordinates.y)[1]; + const index = this.findRowDropIndex(mouseY); return index } @@ -575,12 +578,15 @@ export class CollectionSchemaView extends CollectionSubView() { }); }); + this._colBeingDragged = false; e.stopPropagation(); return true; } const draggedDocs = de.complete.docDragData?.draggedDocuments; if (draggedDocs && super.onInternalDrop(e, de) && !this.sortField) { + let map = draggedDocs?.map(doc => this.rowIndex(doc)) + console.log(map) this.dataDoc[this.fieldKey ?? 'data'] = new List<Doc>([...this.sortedDocs.docs]); this.clearSelection(); draggedDocs.forEach(doc => { @@ -960,9 +966,11 @@ export class CollectionSchemaView extends CollectionSubView() { if (DragManager.docsBeingDragged.length){ this._mouseCoordinates = { x: e.clientX, y: e.clientY }; } - // let newIndex = this.findColDropIndex(e.clientX); - // if (newIndex != this._draggedColIndex) this.moveColumn(this._draggedColIndex, newIndex ?? this._draggedColIndex); - // this._draggedColIndex = newIndex ? newIndex : this._draggedColIndex; + if (this._colBeingDragged){ + let newIndex = this.findColDropIndex(e.clientX); + if (newIndex != this._draggedColIndex) this.moveColumn(this._draggedColIndex, newIndex ?? this._draggedColIndex); + this._draggedColIndex = newIndex ? newIndex : this._draggedColIndex; + } } @computed get sortedDocs() { |