diff options
author | bobzel <zzzman@gmail.com> | 2023-03-23 21:04:33 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-03-23 21:04:33 -0400 |
commit | 00150352f45e474705f7c4ebe7ce375e59b1f45a (patch) | |
tree | e86b0ca59662c3cba56229a93b7acfaf8a5801f9 /src | |
parent | 01ef278b60020d4dafc8f7a217d6de0bf2b3bf89 (diff) |
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..
Diffstat (limited to 'src')
3 files changed, 11 insertions, 16 deletions
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<Doc>(); + @computed get _selectedDocs() { + return new Set(SelectionManager.Docs().filter(doc => Doc.AreProtosEqual(DocCast(doc.context), this.props.Document))); + } @observable _rowEles: ObservableMap = new ObservableMap<Doc, HTMLDivElement>(); @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(); - })}> + }}> <div className="schema-header-row" style={{ height: CollectionSchemaView._rowHeight }}> <div className="row-menu" style={{ width: CollectionSchemaView._rowMenuWidth }}> <div @@ -933,7 +929,7 @@ export class CollectionSchemaView extends CollectionSubView() { </div> {this._columnMenuIndex !== undefined && this.renderColumnMenu} {this._filterColumnIndex !== undefined && this.renderFilterMenu} - <div className="schema-table-content" onPointerDown={e => e.stopPropagation()}> + <div className="schema-table-content"> {this.childDocs.map((doc: Doc, index: number) => { const dataDoc = !doc.isTemplateDoc && !doc.isTemplateForField && !doc.PARAMS ? undefined : this.props.DataDoc; let dref: Opt<DocumentView>; 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<FieldViewProps>() { @@ -40,6 +38,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() { @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<DocumentViewInternalProps <div className="documentView-contentsView" style={{ - pointerEvents: this.pointerEvents === 'visiblePainted' ? 'none' : this.pointerEvents, + pointerEvents: (this.pointerEvents === 'visiblePainted' ? 'none' : this.pointerEvents) ?? 'all', height: this.headerMargin ? `calc(100% - ${this.headerMargin}px)` : undefined, }}> {!this._retryThumb || !this.thumbShown() ? null : ( |