diff options
| author | bobzel <zzzman@gmail.com> | 2024-10-18 00:28:55 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-10-18 00:28:55 -0400 |
| commit | 0728e918e6d075c0eda738b7d2fdbf6095c714ae (patch) | |
| tree | 24a3e316852922eb3a0a94c2c6e1a0d078d57825 /src/client/views/collections/CollectionCarousel3DView.tsx | |
| parent | 7b29d9c14cb1ea786e64655b33b245ed14bd2d9e (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/CollectionCarousel3DView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionCarousel3DView.tsx | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/client/views/collections/CollectionCarousel3DView.tsx b/src/client/views/collections/CollectionCarousel3DView.tsx index 81e921724..081e2fe5a 100644 --- a/src/client/views/collections/CollectionCarousel3DView.tsx +++ b/src/client/views/collections/CollectionCarousel3DView.tsx @@ -1,24 +1,23 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { computed, makeObservable } from 'mobx'; import { observer } from 'mobx-react'; +import { computedFn } from 'mobx-utils'; import * as React from 'react'; import { returnZero } from '../../../ClientUtils'; import { Utils } from '../../../Utils'; import { Doc, DocListCast, Opt } from '../../../fields/Doc'; import { Id } from '../../../fields/FieldSymbols'; -import { BoolCast, DocCast, NumCast, ScriptCast, StrCast, toList } from '../../../fields/Types'; +import { BoolCast, DocCast, NumCast, ScriptCast, StrCast } from '../../../fields/Types'; import { DocumentType } from '../../documents/DocumentTypes'; +import { Docs } from '../../documents/Documents'; import { DragManager } from '../../util/DragManager'; import { Transform } from '../../util/Transform'; +import { PinDocView } from '../PinFuncs'; import { StyleProp } from '../StyleProp'; import { DocumentView } from '../nodes/DocumentView'; import { FocusViewOptions } from '../nodes/FocusViewOptions'; import './CollectionCarousel3DView.scss'; import { CollectionSubView, SubCollectionViewProps } from './CollectionSubView'; -import { computedFn } from 'mobx-utils'; -import { Docs } from '../../documents/Documents'; -import { PinDocView } from '../PinFuncs'; -import { OpenWhere, OpenWhereMod } from '../nodes/OpenWhere'; // eslint-disable-next-line @typescript-eslint/no-require-imports const { CAROUSEL3D_CENTER_SCALE, CAROUSEL3D_SIDE_SCALE, CAROUSEL3D_TOP } = require('../global/globalCssVariables.module.scss'); @@ -94,22 +93,18 @@ export class CollectionCarousel3DView extends CollectionSubView() { .scale(1 / this.centerScale); focus = (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.layoutDoc._carousel_index = index); + const docs = DocListCast(this.Document[this.fieldKey]); + if (anchor.type === DocumentType.CONFIG || docs.includes(anchor)) { + const newIndex = anchor.config_carousel_index ?? docs.getIndex(DocCast(anchor.annotationOn, anchor)); + options.didMove = newIndex !== this.layoutDoc._carousel_index; + options.didMove && (this.layoutDoc._carousel_index = newIndex); + } return undefined; }; getAnchor = (addAsAnnotation: boolean) => { - const anchor = Docs.Create.ConfigDocument({ annotationOn: this.Document }); - anchor.config_carousel_index = this.layoutDoc._carousel_index; + const anchor = Docs.Create.ConfigDocument({ annotationOn: this.Document, config_carousel_index: this.layoutDoc._carousel_index as number }); 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 @@ -120,16 +115,7 @@ export class CollectionCarousel3DView 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; @computed get content() { const currentIndex = NumCast(this.layoutDoc._carousel_index); const displayDoc = (child: Doc, dxf: () => Transform) => ( |
