aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionTimeView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-02-22 21:06:34 -0500
committerbobzel <zzzman@gmail.com>2023-02-22 21:06:34 -0500
commitac8a292b2ac077cb530b926824594efab2228a16 (patch)
treed7509392b2b6b8c2d303c4402ae4882e8ebc796c /src/client/views/collections/CollectionTimeView.tsx
parentb6cab6b3c47751b1d77297b7d150d8f227524592 (diff)
fixed hiding doc decorations when clicking on a nested doc. finished removing old view spec code in favor of saving and restoring anchor data.
Diffstat (limited to 'src/client/views/collections/CollectionTimeView.tsx')
-rw-r--r--src/client/views/collections/CollectionTimeView.tsx75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index 8ec683e6d..e6f29ec37 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -7,7 +7,7 @@ import { ObjectField } from '../../../fields/ObjectField';
import { RichTextField } from '../../../fields/RichTextField';
import { listSpec } from '../../../fields/Schema';
import { ComputedField, ScriptField } from '../../../fields/ScriptField';
-import { Cast, NumCast, StrCast } from '../../../fields/Types';
+import { BoolCast, Cast, NumCast, StrCast } from '../../../fields/Types';
import { emptyFunction, returnEmptyString, returnFalse, returnTrue, setupMoveUpEvents } from '../../../Utils';
import { Docs } from '../../documents/Documents';
import { DocumentType } from '../../documents/DocumentTypes';
@@ -21,6 +21,8 @@ import { CollectionFreeFormView } from './collectionFreeForm/CollectionFreeFormV
import { CollectionSubView } from './CollectionSubView';
import './CollectionTimeView.scss';
import React = require('react');
+import { DocFocusOptions } from '../nodes/DocumentView';
+import { PresBox } from '../nodes/trails';
@observer
export class CollectionTimeView extends CollectionSubView() {
@@ -31,17 +33,27 @@ export class CollectionTimeView extends CollectionSubView() {
@observable _viewDefDivClick: Opt<ScriptField>;
@observable _focusPivotField: Opt<string>;
+ async componentDidMount() {
+ this.props.setContentView?.(this);
+ //const detailView = (await DocCastAsync(this.props.Document.childClickedOpenTemplateView)) || DocUtils.findTemplate("detailView", StrCast(this.rootDoc.type), "");
+ ///const childText = "const alias = getAlias(self); switchView(alias, detailView); alias.dropAction='alias'; useRightSplit(alias, shiftKey); ";
+ runInAction(() => {
+ this._childClickedScript = ScriptField.MakeScript('openInLightbox(self)', { this: Doc.name });
+ this._viewDefDivClick = ScriptField.MakeScript('pivotColumnClick(this,payload)', { payload: 'any' });
+ });
+ }
+
+ get pivotField() {
+ return this._focusPivotField || StrCast(this.layoutDoc._pivotField);
+ }
+
getAnchor = (addAsAnnotation: boolean) => {
const anchor = Docs.Create.HTMLAnchorDocument([], {
title: ComputedField.MakeFunction(`"${this.pivotField}"])`) as any,
annotationOn: this.rootDoc,
});
-
- // save view spec information for anchor
- const proto = Doc.GetProto(anchor);
- proto.pivotField = this.pivotField;
- proto.docFilters = ObjectField.MakeCopy(this.layoutDoc._docFilters as ObjectField) || new List<string>([]);
- proto.docRangeFilters = ObjectField.MakeCopy(this.layoutDoc._docRangeFilters as ObjectField) || new List<string>([]);
+ anchor.presPinPivotField = this.pivotField; // should be captured in pinDocView below
+ PresBox.pinDocView(anchor, { pinData: { viewType: true, filters: true } }, this.rootDoc);
if (addAsAnnotation) {
// when added as an annotation, links to anchors can be found as links to the document even if the anchors are not rendered
@@ -54,34 +66,33 @@ export class CollectionTimeView extends CollectionSubView() {
return anchor;
};
- async componentDidMount() {
- this.props.setContentView?.(this);
- //const detailView = (await DocCastAsync(this.props.Document.childClickedOpenTemplateView)) || DocUtils.findTemplate("detailView", StrCast(this.rootDoc.type), "");
- ///const childText = "const alias = getAlias(self); switchView(alias, detailView); alias.dropAction='alias'; useRightSplit(alias, shiftKey); ";
- runInAction(() => {
- this._childClickedScript = ScriptField.MakeScript('openInLightbox(self)', { this: Doc.name });
- this._viewDefDivClick = ScriptField.MakeScript('pivotColumnClick(this,payload)', { payload: 'any' });
- });
- }
-
- get pivotField() {
- return this._focusPivotField || StrCast(this.layoutDoc._pivotField);
- }
@action
- setViewSpec = (anchor: Doc, preview: boolean) => {
- if (preview) {
+ scrollFocus = (anchor: Doc, options: DocFocusOptions) => {
+ if (options.preview) {
// if in preview, then override document's fields with view spec
- this._focusFilters = StrListCast(Doc.GetProto(anchor).docFilters);
- this._focusRangeFilters = StrListCast(Doc.GetProto(anchor).docRangeFilters);
- this._focusPivotField = StrCast(anchor.pivotField);
- } else if (anchor.pivotField !== undefined) {
- // otherwise set document's fields based on anchor view spec
- this.layoutDoc._prevFilterIndex = 1;
- this.layoutDoc._pivotField = StrCast(anchor.pivotField);
- this.layoutDoc._docFilters = new List<string>(StrListCast(anchor.docFilters));
- this.layoutDoc._docRangeFilters = new List<string>(StrListCast(anchor.docRangeFilters));
+ this._focusFilters = StrListCast(anchor.presPinDocFilters);
+ this._focusRangeFilters = StrListCast(anchor.presPinDocRangeFilters);
+ this._focusPivotField = StrCast(anchor.presPinPivotField);
+ return undefined;
}
- return 0;
+ const focusSpeed = options.instant ? 0 : options.zoomTime ?? 500;
+
+ // should be part of restoreTargetDocView
+ this.layoutDoc._prevFilterIndex = 1;
+ this.layoutDoc._pivotField = anchor.presPinPivotField;
+
+ return PresBox.restoreTargetDocView(
+ this.props.DocumentView?.(), //
+ { pinDocLayout: BoolCast(anchor.presPinLayout) },
+ anchor,
+ focusSpeed,
+ {
+ viewType: anchor.presPinViewType ? true : false,
+ filters: anchor.presPinDocFilters || anchor.presPinDocRangeFilters ? true : false,
+ }
+ )
+ ? focusSpeed
+ : undefined;
};
layoutEngine = () => this._layoutEngine;