aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionCardDeckView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-10-18 00:28:55 -0400
committerbobzel <zzzman@gmail.com>2024-10-18 00:28:55 -0400
commit0728e918e6d075c0eda738b7d2fdbf6095c714ae (patch)
tree24a3e316852922eb3a0a94c2c6e1a0d078d57825 /src/client/views/collections/CollectionCardDeckView.tsx
parent7b29d9c14cb1ea786e64655b33b245ed14bd2d9e (diff)
fixed following links/show document of items in tabs/carousel/card view to set options.didMove correctly so that toggleTarget works.
Diffstat (limited to 'src/client/views/collections/CollectionCardDeckView.tsx')
-rw-r--r--src/client/views/collections/CollectionCardDeckView.tsx42
1 files changed, 16 insertions, 26 deletions
diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx
index 60305244c..729a1585a 100644
--- a/src/client/views/collections/CollectionCardDeckView.tsx
+++ b/src/client/views/collections/CollectionCardDeckView.tsx
@@ -9,25 +9,24 @@ import { Animation, DocData } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { ScriptField } from '../../../fields/ScriptField';
-import { BoolCast, DateCast, DocCast, NumCast, RTFCast, ScriptCast, StrCast, toList } from '../../../fields/Types';
+import { BoolCast, DateCast, DocCast, NumCast, RTFCast, ScriptCast, StrCast } from '../../../fields/Types';
import { URLField } from '../../../fields/URLField';
import { gptImageLabel } from '../../apis/gpt/GPT';
import { DocumentType } from '../../documents/DocumentTypes';
+import { Docs } from '../../documents/Documents';
import { DragManager } from '../../util/DragManager';
import { dropActionType } from '../../util/DropActionTypes';
import { SnappingManager } from '../../util/SnappingManager';
import { Transform } from '../../util/Transform';
import { undoable } from '../../util/UndoManager';
+import { PinDocView } from '../PinFuncs';
import { StyleProp } from '../StyleProp';
import { TagItem } from '../TagsView';
import { DocumentView, DocumentViewProps } from '../nodes/DocumentView';
+import { FocusViewOptions } from '../nodes/FocusViewOptions';
import { GPTPopup, GPTPopupMode } from '../pdf/GPTPopup/GPTPopup';
import './CollectionCardDeckView.scss';
import { CollectionSubView, SubCollectionViewProps } from './CollectionSubView';
-import { FocusViewOptions } from '../nodes/FocusViewOptions';
-import { Docs } from '../../documents/Documents';
-import { PinDocView } from '../PinFuncs';
-import { OpenWhere, OpenWhereMod } from '../nodes/OpenWhere';
enum cardSortings {
Time = 'time',
@@ -599,22 +598,21 @@ export class CollectionCardView extends CollectionSubView() {
});
focus = action((anchor: Doc, options: FocusViewOptions): Opt<number> => {
- const docs = DocListCast(this.Document[this.fieldKey ?? Doc.LayoutFieldKey(this.Document)]);
- if (anchor.type !== DocumentType.CONFIG && !docs.includes(anchor)) return undefined;
- options.didMove = true;
- const target = DocCast(anchor.annotationOn) ?? anchor;
- const index = docs.indexOf(target);
- index !== -1 && (this._curDoc = target);
+ const docs = DocListCast(this.Document[this.fieldKey]);
+ if (anchor.type === DocumentType.CONFIG || docs.includes(anchor)) {
+ const foundDoc = DocCast(
+ anchor.config_curDoc,
+ docs.find(doc => doc === DocCast(anchor.annotationOn, anchor))
+ );
+ options.didMove = foundDoc !== this.curDoc() ? true : false;
+ options.didMove && (this._curDoc = foundDoc);
+ }
return undefined;
});
getAnchor = (addAsAnnotation: boolean) => {
- const anchor = Docs.Create.ConfigDocument({ annotationOn: this.Document });
- anchor.config_curDoc = this.curDoc();
+ const anchor = Docs.Create.ConfigDocument({ annotationOn: this.Document, config_curDoc: this.curDoc() });
PinDocView(anchor, { pinData: { type_collection: true, filters: true } }, this.Document);
- 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
- Doc.AddDocToList(this.dataDoc, this._props.fieldKey + '_annotations', anchor);
- }
+ addAsAnnotation && Doc.AddDocToList(this.dataDoc, this.fieldKey + '_annotations', anchor); // when added as an annotation, links to anchors can be found as links to the document even if the anchors are not rendered
return anchor;
};
// pinned / linked anchor doc includes selected rows, graph titles, and graph colors
@@ -625,15 +623,7 @@ export class CollectionCardView extends CollectionSubView() {
}
return false;
};
- addDocTab = (docsIn: Doc | Doc[], location: OpenWhere) => {
- const doc = toList(docsIn).lastElement();
- const where = location.split(':')[0];
- if (where === OpenWhere.lightbox && (this.childDocList?.includes(doc) || this.childLayoutPairs.map(pair => pair.layout)?.includes(doc))) {
- if (doc.hidden) doc.hidden = false;
- if (!location.includes(OpenWhereMod.always)) return true;
- }
- return this._props.addDocTab(docsIn, location);
- };
+ addDocTab = this.addLinkedDocTab;
/**
* Actually renders all the cards