From 00150352f45e474705f7c4ebe7ce375e59b1f45a Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 23 Mar 2023 21:04:33 -0400 Subject: fixed up pointer events so that schema and freeform items can be selected without selecting the collection. however, dragging the item drags the collection unless the collection is selected. cleaned up selected docs in schema to not keep a parallel observableSet to SelectionManager.. --- .../collections/collectionSchema/CollectionSchemaView.tsx | 14 +++++--------- .../views/collections/collectionSchema/SchemaRowBox.tsx | 11 +++++------ src/client/views/nodes/DocumentView.tsx | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index a5f5ca2ae..5f795c5ac 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -54,7 +54,9 @@ export class CollectionSchemaView extends CollectionSubView() { public static _previewDividerWidth: number = 4; @observable _lastSelectedRow: number | undefined; - @observable _selectedDocs: ObservableSet = new ObservableSet(); + @computed get _selectedDocs() { + return new Set(SelectionManager.Docs().filter(doc => Doc.AreProtosEqual(DocCast(doc.context), this.props.Document))); + } @observable _rowEles: ObservableMap = new ObservableMap(); @observable _colEles: HTMLDivElement[] = []; @observable _isDragging: boolean = false; @@ -322,7 +324,6 @@ export class CollectionSchemaView extends CollectionSubView() { @action addDocToSelection = (doc: Doc, extendSelection: boolean, index: number) => { - this._selectedDocs.add(doc); const rowDocView = DocumentManager.Instance.getDocumentView(doc); if (rowDocView) SelectionManager.SelectView(rowDocView, extendSelection); this._lastSelectedRow = index; @@ -330,7 +331,6 @@ export class CollectionSchemaView extends CollectionSubView() { @action removeDocFromSelection = (doc: Doc) => { - if (this._selectedDocs.has(doc)) this._selectedDocs.delete(doc); const rowDocView = DocumentManager.Instance.getDocumentView(doc); if (rowDocView) SelectionManager.DeselectView(rowDocView); if (this._selectedDocs.size === 0) { @@ -340,7 +340,6 @@ export class CollectionSchemaView extends CollectionSubView() { @action clearSelection = () => { - this._selectedDocs.clear(); SelectionManager.DeselectAll(); this._lastSelectedRow = undefined; }; @@ -898,10 +897,7 @@ export class CollectionSchemaView extends CollectionSubView() { className="schema-table" style={{ pointerEvents: this.isContentActive() ? 'all' : 'none', - }} - onPointerDown={action(() => { - this.clearSelection(); - })}> + }}>
{this._columnMenuIndex !== undefined && this.renderColumnMenu} {this._filterColumnIndex !== undefined && this.renderFilterMenu} -
e.stopPropagation()}> +
{this.childDocs.map((doc: Doc, index: number) => { const dataDoc = !doc.isTemplateDoc && !doc.isTemplateForField && !doc.PARAMS ? undefined : this.props.DataDoc; let dref: Opt; diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index 37999484d..aa69e2b9c 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -1,19 +1,17 @@ import React = require('react'); import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { action, computed, ObservableSet } from 'mobx'; +import { action, computed } from 'mobx'; import { observer } from 'mobx-react'; -import { Doc } from '../../../../fields/Doc'; +import { emptyFunction, setupMoveUpEvents } from '../../../../Utils'; +import { DragManager } from '../../../util/DragManager'; import { undoBatch } from '../../../util/UndoManager'; import { ViewBoxBaseComponent } from '../../DocComponent'; +import { Colors } from '../../global/globalEnums'; import { OpenWhere } from '../../nodes/DocumentView'; import { FieldView, FieldViewProps } from '../../nodes/FieldView'; import { CollectionSchemaView } from './CollectionSchemaView'; import './CollectionSchemaView.scss'; import { SchemaTableCell } from './SchemaTableCell'; -import { Colors } from '../../global/globalEnums'; -import { DocCast, StrCast } from '../../../../fields/Types'; -import { setupMoveUpEvents, emptyFunction } from '../../../../Utils'; -import { DragManager } from '../../../util/DragManager'; @observer export class SchemaRowBox extends ViewBoxBaseComponent() { @@ -40,6 +38,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent() { @action onRowPointerDown = (e: React.PointerEvent) => { + if (!this.isContentActive()) return; setupMoveUpEvents(this, e, e => this.schemaView?.startDrag(e, this.rootDoc, this.rowIndex) ?? true, emptyFunction, emptyFunction, false); }; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index d7a61a797..c13934945 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -1128,7 +1128,7 @@ export class DocumentViewInternal extends DocComponent {!this._retryThumb || !this.thumbShown() ? null : ( -- cgit v1.2.3-70-g09d2