From ee5f4ad5348f10d9e76eaf2962295a6968e7a4d0 Mon Sep 17 00:00:00 2001 From: monikahedman Date: Fri, 23 Aug 2019 23:02:47 -0400 Subject: THINGS ARE GREAT --- src/client/views/linking/LinkFollowBox.tsx | 95 +++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/client/views/linking/LinkFollowBox.tsx b/src/client/views/linking/LinkFollowBox.tsx index da04b1292..5cf14cf58 100644 --- a/src/client/views/linking/LinkFollowBox.tsx +++ b/src/client/views/linking/LinkFollowBox.tsx @@ -24,8 +24,8 @@ enum FollowModes { } enum FollowOptions { - ZOOM = "zoom", - NOZOOM = "no zoom", + ZOOM = "Zoom", + NOZOOM = "No Zoom", } @observer @@ -42,6 +42,7 @@ export class LinkFollowBox extends React.Component { @observable selectedContextString: string = ""; @observable sourceView: DocumentView | undefined = undefined; @observable canPan: boolean = false; + @observable shouldUseOnlyParentContext = false; @observable private _docs: { col: Doc, target: Doc }[] = []; @observable private _otherDocs: { col: Doc, target: Doc }[] = []; @@ -84,6 +85,8 @@ export class LinkFollowBox extends React.Component { LinkFollowBox.sourceDoc = undefined; LinkFollowBox.destinationDoc = undefined; this.sourceView = undefined; + this.canPan = false; + this.shouldUseOnlyParentContext = false; } async fetchDocuments() { @@ -301,6 +304,14 @@ export class LinkFollowBox extends React.Component { handleModeChange = (e: React.ChangeEvent) => { let target = e.target as HTMLInputElement; this.selectedMode = target.value; + + this.shouldUseOnlyParentContext = (this.selectedMode === FollowModes.INPLACE || this.selectedMode === FollowModes.PAN); + if (this.shouldUseOnlyParentContext) { + if (this.sourceView && this.sourceView.props.ContainingCollectionView) { + this.selectedContext = this.sourceView.props.ContainingCollectionView.props.Document; + this.selectedContextString = (StrCast(this.sourceView.props.ContainingCollectionView.props.Document.title)); + } + } } @action @@ -315,10 +326,6 @@ export class LinkFollowBox extends React.Component { this.selectedContextString = target.value; } - // async canPan() { - - // } - @computed get canOpenInPlace() { if (this.sourceView && this.sourceView.props.ContainingCollectionView) { @@ -388,38 +395,68 @@ export class LinkFollowBox extends React.Component { @computed get availableContexts() { return ( -
+ this.shouldUseOnlyParentContext ? + : +
+
- {[...this._docs, ...this._otherDocs].map(doc => { - if (doc && doc.target) { - return

; - } - })} -
+ {[...this._docs, ...this._otherDocs].map(doc => { + if (doc && doc.target) { + return

; + } + })} +
); } @computed get availableOptions() { + let shouldShowZoom = (this.shouldUseOnlyParentContext || this.selectedContextString !== "self"); return ( -
- -
+ shouldShowZoom ? +
+
+
+
+ : + null ); } -- cgit v1.2.3-70-g09d2