diff options
| author | bobzel <zzzman@gmail.com> | 2024-04-28 13:08:09 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-04-28 13:08:09 -0400 |
| commit | 729114c0867e3cc8d8e0668bae451976b387cb34 (patch) | |
| tree | 210350ff6716651c542fb4ecf8782e68d4dda9a3 /src/client/views/collections | |
| parent | 33b52b9344768b4db034cceed3c1ccab9a30c949 (diff) | |
simplified explore mode implementation
Diffstat (limited to 'src/client/views/collections')
5 files changed, 16 insertions, 36 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 2ba6f5bf4..9212a6609 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -59,7 +59,7 @@ export class CollectionNoteTakingView extends CollectionSubView() { } @computed get chromeHidden() { - return !!(BoolCast(this.layoutDoc.chromeHidden) || this._props.onBrowseClickScript?.()); + return BoolCast(this.layoutDoc.chromeHidden) || SnappingManager.ExploreMode; } // columnHeaders returns the list of SchemaHeaderFields currently being used by the layout doc to render the columns @computed get colHeaderData() { @@ -283,7 +283,6 @@ export class CollectionNoteTakingView extends CollectionSubView() { layout_showTitle={this._props.childlayout_showTitle} dragAction={StrCast(this.layoutDoc.childDragAction) as dropActionType} onClickScript={this.onChildClickHandler} - onBrowseClickScript={this._props.onBrowseClickScript} onDoubleClickScript={this.onChildDoubleClickHandler} ScreenToLocalTransform={noteTakingDocTransform} focus={this.focusDocument} diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index b79d660c6..c47fe915a 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -338,7 +338,6 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection isContentActive={doc.onClick ? this.isChildButtonContentActive : this.isChildContentActive} onKey={this.onKeyDown} DataTransition={trans} - onBrowseClickScript={this._props.onBrowseClickScript} isDocumentActive={this.isContentActive} LayoutTemplate={this._props.childLayoutTemplate} LayoutTemplateString={this._props.childLayoutString} @@ -654,7 +653,6 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection addDocument={this._props.addDocument} moveDocument={this._props.moveDocument} addDocTab={this._props.addDocTab} - onBrowseClickScript={this._props.onBrowseClickScript} pinToPres={emptyFunction} rootSelected={this.rootSelected} removeDocument={this._props.removeDocument} diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index 5c16fecd0..e98e444ed 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -594,7 +594,6 @@ export class TabDocView extends ObservableReactComponent<TabDocViewProps> { hideTitle={this._props.keyValue} Document={this._document} TemplateDataDocument={!Doc.AreProtosEqual(this._document[DocData], this._document) ? this._document[DocData] : undefined} - onBrowseClickScript={DocumentView.exploreMode} waitForDoubleClickToClick={this.waitForDoubleClick} isContentActive={this.isContentActive} isDocumentActive={returnFalse} diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index fa4dbf9a2..d3998aee8 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -241,7 +241,6 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection this._keyframeEditing = set; }; getKeyFrameEditing = () => this._keyframeEditing; - onBrowseClickHandler = () => this._props.onBrowseClickScript?.() || ScriptCast(this.layoutDoc.onBrowseClick); onChildClickHandler = () => this._props.childClickScript || ScriptCast(this.Document.onChildClick); onChildDoubleClickHandler = () => this._props.childDoubleClickScript || ScriptCast(this.Document.onChildDoubleClick); elementFunc = () => this._layoutElements; @@ -726,11 +725,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection onClick = (e: React.MouseEvent) => { if (this._lightboxDoc) this._lightboxDoc = undefined; if (ClientUtils.isClick(e.pageX, e.pageY, this._downX, this._downY, this._downTime)) { - if (this.onBrowseClickHandler()) { - this.onBrowseClickHandler().script.run({ documentView: this.DocumentView?.(), clientX: e.clientX, clientY: e.clientY }); - e.stopPropagation(); - e.preventDefault(); - } else if (this.isContentActive() && e.shiftKey) { + if (this.isContentActive() && e.shiftKey) { // reset zoom of freeform view to 1-to-1 on a shift + double click this.zoomSmoothlyAboutPt(this.screenToFreeformContentsXf.transformPoint(e.clientX, e.clientY), 1); e.stopPropagation(); @@ -1256,7 +1251,6 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection onClickScript={this.onChildClickHandler} onKey={this.onKeyDown} onDoubleClickScript={this.onChildDoubleClickHandler} - onBrowseClickScript={this.onBrowseClickHandler} bringToFront={this.bringToFront} ScreenToLocalTransform={childLayout.z ? this.ScreenToLocalBoxXf : this.ScreenToContentsXf} PanelWidth={childLayout[Width]} @@ -1962,7 +1956,6 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection onClickScript={this.onChildClickHandler} onKey={this.onKeyDown} onDoubleClickScript={this.onChildDoubleClickHandler} - onBrowseClickScript={this.onBrowseClickHandler} childFilters={this.childDocFilters} childFiltersByRanges={this.childDocRangeFilters} searchFilterDocs={this.searchFilterDocs} @@ -1987,6 +1980,19 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection </div> ); } + browseTo = (clientX: number, clientY: number, browseTransitionTime: number): boolean => { + if (!this.Document.isGroup) { + const dfltScale = this.isAnnotationOverlay ? 1 : 0.5; + if (this.layoutDoc[this.scaleFieldKey] !== dfltScale) { + this.zoomSmoothlyAboutPt(this.screenToFreeformContentsXf.transformPoint(clientX, clientY), dfltScale, browseTransitionTime); + return true; + } + return !!this.DocumentView?.() + .containerViewPath?.() + ?.some(cont => cont.ComponentView?.browseTo?.(clientX, clientY, browseTransitionTime)); + } + return false; + }; } @observer @@ -1995,28 +2001,6 @@ class CollectionFreeFormOverlayView extends React.Component<{ elements: () => Vi return this.props.elements().filter(ele => ele.bounds?.z).map(ele => ele.ele); // prettier-ignore } } - -export function CollectionBrowseClick(dv: DocumentView, clientX: number, clientY: number) { - const browseTransitionTime = 500; - SelectionManager.DeselectAll(); - dv && - DocumentManager.Instance.showDocument(dv.Document, { zoomScale: 0.8, willZoomCentered: true }, (focused: boolean) => { - if (!focused) { - const selfFfview = !dv.Document.isGroup && dv.ComponentView instanceof CollectionFreeFormView ? dv.ComponentView : undefined; - const containers = dv.containerViewPath?.() ?? []; - let parFfview = dv.CollectionFreeFormView; - containers.forEach(cont => { - parFfview = parFfview ?? cont.CollectionFreeFormView; - }); - - while (parFfview?.Document.isGroup) parFfview = parFfview.DocumentView?.().CollectionFreeFormView; - const ffview = selfFfview && selfFfview.layoutDoc[selfFfview.scaleFieldKey] !== 0.5 ? selfFfview : parFfview; // if focus doc is a freeform that is not at it's default 0.5 scale, then zoom out on it. Otherwise, zoom out on the parent ffview - ffview?.zoomSmoothlyAboutPt(ffview.screenToFreeformContentsXf.transformPoint(clientX, clientY), ffview?.isAnnotationOverlay ? 1 : 0.5, browseTransitionTime); - Doc.linkFollowHighlight(dv?.Document, false); - } - }); -} -ScriptingGlobals.add(CollectionBrowseClick); // eslint-disable-next-line prefer-arrow-callback ScriptingGlobals.add(function nextKeyFrame(readOnly: boolean) { !readOnly && (SelectionManager.Views[0].ComponentView as CollectionFreeFormView)?.changeKeyFrame(); diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx index b89ca3614..dfef3aa48 100644 --- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx +++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx @@ -179,7 +179,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro case ColumnType.Image: return <SchemaImageCell {...this._props} />; case ColumnType.Boolean: return <SchemaBoolCell {...this._props} />; case ColumnType.RTF: return <SchemaRTFCell {...this._props} />; - case ColumnType.Enumeration: return <SchemaEnumerationCell {...this._props} options={this._props.getFinfo(this._props.fieldKey)?.values?.map(val => val.toString())} />; + case ColumnType.Enumeration: return <SchemaEnumerationCell {...this._props} options={this._props.getFinfo(this._props.fieldKey)?.values?.map(val => Field.toString(val))} />; case ColumnType.Date: return <SchemaDateCell {...this._props} />; default: return this.defaultCellContent; } |
