From 85c09a9e5df77ad00f3e00a2fb1e0f2e3449f97d Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 12 Dec 2023 14:39:09 -0500 Subject: cleaned up SelectionManager. fixed schema view --- .../collections/collectionSchema/SchemaRowBox.tsx | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src/client/views/collections/collectionSchema/SchemaRowBox.tsx') diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index 5a2926159..737d7e0f4 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import { IconButton, Size } from 'browndash-components'; -import { computed } from 'mobx'; +import { computed, makeObservable, override } from 'mobx'; import { observer } from 'mobx-react'; import { computedFn } from 'mobx-utils'; import { CgClose } from 'react-icons/cg'; import { FaExternalLinkAlt } from 'react-icons/fa'; import { Doc } from '../../../../fields/Doc'; import { BoolCast } from '../../../../fields/Types'; -import { emptyFunction, returnFalse, setupMoveUpEvents } from '../../../../Utils'; +import { copyProps, emptyFunction, returnFalse, setupMoveUpEvents } from '../../../../Utils'; import { DragManager } from '../../../util/DragManager'; import { SnappingManager } from '../../../util/SnappingManager'; import { Transform } from '../../../util/Transform'; @@ -28,17 +28,27 @@ export class SchemaRowBox extends ViewBoxBaseComponent this._ref?.getBoundingClientRect(); @computed get schemaView() { - return this.props.DocumentView?.()._props.docViewPath().lastElement()?.ComponentView as CollectionSchemaView; + return this._props.DocumentView?.()._props.docViewPath().lastElement()?.ComponentView as CollectionSchemaView; } @computed get schemaDoc() { - return this.props.DocumentView?.()._props.docViewPath().lastElement()?.Document; + return this._props.DocumentView?.()._props.docViewPath().lastElement()?.Document; } @computed get rowIndex() { @@ -46,7 +56,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent { @@ -54,12 +64,12 @@ export class SchemaRowBox extends ViewBoxBaseComponent { - if (SnappingManager.IsDragging && this.props.isContentActive()) { + if (SnappingManager.IsDragging && this._props.isContentActive()) { document.removeEventListener('pointermove', this.onPointerMove); document.addEventListener('pointermove', this.onPointerMove); } @@ -103,7 +113,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent { @@ -114,7 +124,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent { e.stopPropagation(); - this.props.removeDocument?.(this.Document); + this._props.removeDocument?.(this.Document); }, 'Delete Row') ) } @@ -145,7 +155,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent { e.stopPropagation(); - this.props.addDocTab(this.Document, OpenWhere.addRight); + this._props.addDocTab(this.Document, OpenWhere.addRight); }, 'Open schema Doc preview') ) } @@ -161,7 +171,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent { const ind = index === this.schemaView.columnKeys.length - 1 ? this.schemaView.columnKeys.length - 3 : index; const x = this.schemaView?.displayColumnWidths.reduce((p, c, i) => (i <= ind ? p + c : p), 0); - const y = (this.props.rowIndex ?? 0) * this.props.PanelHeight(); + const y = (this._props.rowIndex ?? 0) * this._props.PanelHeight(); return new Transform(x + CollectionSchemaView._rowMenuWidth, y, 1); }} /> -- cgit v1.2.3-70-g09d2