aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2020-01-29 17:32:44 -0500
committerbob <bcz@cs.brown.edu>2020-01-29 17:32:44 -0500
commitc6dfa681ab54fff5abbbe1f317bda85638f496e7 (patch)
tree08e4f1c50a82f13a255dcc763e6302e4aa5a0fe9 /src/client/views/nodes
parent7c27e6502037caf1aee3eb9e30b4e0572ce095a1 (diff)
added support for applying layouts to create slide-like narratives.
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r--src/client/views/nodes/DocumentView.tsx13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index f75184b42..095b60a76 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -523,7 +523,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
})();
}
- static makeCustomViewClicked = (doc: Doc, dataDoc: Opt<Doc>, creator: (documents: Array<Doc>, options: DocumentOptions, id?: string) => Doc, name: string = "custom") => {
+ static makeCustomViewClicked = (doc: Doc, dataDoc: Opt<Doc>, creator: (documents: Array<Doc>, options: DocumentOptions, id?: string) => Doc, name: string = "custom", docLayoutTemplate?: Doc) => {
const batch = UndoManager.StartBatch("CustomViewClicked");
const customName = "layout_" + name;
if (!StrCast(doc.title).endsWith(name)) doc.title = doc.title + "_" + name;
@@ -552,7 +552,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
fieldTemplate._autoHeight = true;
}
- const docTemplate = creator(fieldTemplate ? [fieldTemplate] : [], { title: customName + "(" + doc.title + ")", isTemplateDoc: true, _width: _width + 20, _height: Math.max(100, _height + 45) });
+ const docTemplate = docLayoutTemplate || creator(fieldTemplate ? [fieldTemplate] : [], { title: customName + "(" + doc.title + ")", isTemplateDoc: true, _width: _width + 20, _height: Math.max(100, _height + 45) });
fieldTemplate && Doc.MakeMetadataFieldTemplate(fieldTemplate, Doc.GetProto(docTemplate));
Doc.ApplyTemplateTo(docTemplate, dataDoc || doc, customName, undefined);
@@ -653,7 +653,14 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
Doc.MakeMetadataFieldTemplate(this.props.Document, this.props.ContainingCollectionView.props.Document);
} else if (custom) {
DocumentView.makeNativeViewClicked(this.props.Document, StrCast(this.props.Document.layoutKey).split("_")[1]);
- DocumentView.makeCustomViewClicked(this.props.Document, this.props.DataDoc, Docs.Create.StackingDocument, layout);
+
+ let foundLayout: Opt<Doc> = undefined;
+ DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => {
+ if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) {
+ foundLayout = btnDoc.dragFactory as Doc;
+ }
+ })
+ DocumentView.makeCustomViewClicked(this.props.Document, this.props.DataDoc, Docs.Create.StackingDocument, layout, foundLayout);
} else {
DocumentView.makeNativeViewClicked(this.props.Document, StrCast(this.props.Document.layoutKey).split("_")[1]);
}