diff options
| author | bobzel <zzzman@gmail.com> | 2024-05-10 14:05:01 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-05-10 14:05:01 -0400 |
| commit | 4b4d77f99bd55e6de0593c3acd1cf5798ae038bf (patch) | |
| tree | 0fa27b0344c4252833b9d36dbe69f172141b846e /src/client/views/collections | |
| parent | e12f79e188c32787b5749eba54183002f270f998 (diff) | |
added an always option for OpenWhere lightbox. cleaned up/fixed making collections capable of being a lightbox.
Diffstat (limited to 'src/client/views/collections')
4 files changed, 9 insertions, 16 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 8fb2b30f1..a723dc69d 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -634,7 +634,7 @@ export class CollectionDockingView extends CollectionSubView() { ScriptingGlobals.add( // eslint-disable-next-line prefer-arrow-callback function openInLightbox(doc: any) { - CollectionDockingView.Instance?._props.addDocTab(doc, OpenWhere.lightbox); + CollectionDockingView.Instance?._props.addDocTab(doc, OpenWhere.lightboxAlways); }, 'opens up document in a lightbox', '(doc: any)' diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index afd584154..46f61290e 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -549,15 +549,7 @@ export class TabDocView extends ObservableReactComponent<TabDocViewProps> { // prettier-ignore switch (whereFields[0]) { case undefined: - case OpenWhere.lightbox: if (this.layoutDoc?._isLightbox) { - const lightboxView = !docs[0].annotationOn && DocCast(docs[0].embedContainer) ? DocumentView.getFirstDocumentView(DocCast(docs[0].embedContainer)) : undefined; - const data = lightboxView?.dataDoc[Doc.LayoutFieldKey(lightboxView.Document)]; - if (lightboxView && (!data || data instanceof List)) { - lightboxView.layoutDoc[Doc.LayoutFieldKey(lightboxView.Document)] = new List<Doc>(docs); - return true; - } - } - return LightboxView.Instance.AddDocTab(docs[0], OpenWhere.lightbox); + case OpenWhere.lightbox: return LightboxView.Instance.AddDocTab(docs[0], location); case OpenWhere.close: return CollectionDockingView.CloseSplit(docs[0], whereMods); case OpenWhere.replace: return CollectionDockingView.ReplaceTab(docs[0], whereMods, this.stack, panelName, undefined, keyValue); case OpenWhere.toggle: return CollectionDockingView.ToggleSplit(docs[0], whereMods, this.stack, TabDocView.DontSelectOnActivate, keyValue); diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx index 3a187171a..bc12d1c28 100644 --- a/src/client/views/collections/TreeView.tsx +++ b/src/client/views/collections/TreeView.tsx @@ -231,7 +231,7 @@ export class TreeView extends ObservableReactComponent<TreeViewProps> { } else { // choose an appropriate embedding or make one. --- choose the first embedding that (1) user owns, (2) has no context field ... otherwise make a new embedding const bestEmbedding = docView.Document.author === ClientUtils.CurrentUserEmail() && !Doc.IsDataProto(docView.Document) ? docView.Document : Doc.BestEmbedding(docView.Document); - this._props.addDocTab(bestEmbedding, OpenWhere.lightbox); + this._props.addDocTab(bestEmbedding, OpenWhere.lightboxAlways); } }; diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index dbd9fb11f..92e29e94a 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -42,7 +42,7 @@ import { DocumentView } from '../../nodes/DocumentView'; import { FieldViewProps } from '../../nodes/FieldView'; import { FocusViewOptions } from '../../nodes/FocusViewOptions'; import { FormattedTextBox } from '../../nodes/formattedText/FormattedTextBox'; -import { OpenWhere } from '../../nodes/OpenWhere'; +import { OpenWhere, OpenWhereMod } from '../../nodes/OpenWhere'; import { PinDocView, PinProps } from '../../PinFuncs'; import { StyleProp } from '../../StyleProp'; import { CollectionSubView } from '../CollectionSubView'; @@ -1066,9 +1066,10 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection /> ); } - addDocTab = action((docsIn: Doc | Doc[], where: OpenWhere) => { + addDocTab = action((docsIn: Doc | Doc[], location: OpenWhere) => { const docs = toList(docsIn); - if (this._props.isAnnotationOverlay) return this._props.addDocTab(docs, where); + if (this._props.isAnnotationOverlay) return this._props.addDocTab(docs, location); + const where = location.split(':')[0]; switch (where) { case OpenWhere.inParent: return this._props.addDocument?.(docs) || false; @@ -1095,13 +1096,13 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection } if (firstDoc === this.Document || this.childDocList?.includes(firstDoc) || this.childLayoutPairs.map(pair => pair.layout)?.includes(firstDoc)) { if (firstDoc.hidden) firstDoc.hidden = false; - return true; + if (!location.includes(OpenWhereMod.always)) return true; } } break; default: } - return this._props.addDocTab(docs, where); + return this._props.addDocTab(docs, location); }); getCalculatedPositions(pair: { layout: Doc; data?: Doc }): PoolData { |
