From 119f90cc5c4ef773133f1bfd18a813dde9487f94 Mon Sep 17 00:00:00 2001
From: Sam Wilkins <samwilkins333@gmail.com>
Date: Tue, 21 Jan 2020 10:26:45 -0500
Subject: buxton templating fixes

---
 .../views/collections/CollectionTreeView.tsx       | 29 +++++++++++++---------
 1 file changed, 17 insertions(+), 12 deletions(-)

(limited to 'src/client/views/collections/CollectionTreeView.tsx')

diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 3a208038c..4a6dffc1c 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -634,22 +634,27 @@ export class CollectionTreeView extends CollectionSubView(Document) {
         }
         ContextMenu.Instance.addItem({
             description: "Buxton Layout", icon: "eye", event: () => {
-                const { TextDocument, ImageDocument } = Docs.Create;
+                const { TextDocument, ImageDocument, MulticolumnDocument } = Docs.Create;
+                const { Document } = this.props;
+                const fallback = "http://www.cs.brown.edu/~bcz/face.gif";
                 const wrapper = Docs.Create.StackingDocument([
-                    ImageDocument("http://www.cs.brown.edu/~bcz/face.gif", { title: "hero" }),
+                    ImageDocument(fallback, { title: "hero" }),
+                    MulticolumnDocument([], { title: "data", height: 100 }),
                     ...["short_description", "year", "company", "degrees_of_freedom"].map(key => TextDocument({ title: key }))
                 ], { autoHeight: true, chromeStatus: "disabled" });
                 wrapper.disableLOD = true;
-                makeTemplate(wrapper, true);
-                const detailedLayout = Doc.MakeAlias(wrapper);
-                const cardLayout = ImageBox.LayoutString("hero");
-                this.childLayoutPairs.forEach(({ layout }) => {
-                    const proto = Doc.GetProto(layout);
-                    proto.layout = cardLayout;
-                    proto.layout_detailed = detailedLayout;
-                    layout.showTitle = "title";
-                    layout.showTitleHover = "titlehover";
-                });
+                wrapper.isTemplateDoc = makeTemplate(wrapper, true);
+
+                const cardLayout = ImageDocument(fallback);
+                const proto = Doc.GetProto(cardLayout);
+                proto.layout = ImageBox.LayoutString("hero");
+                cardLayout.showTitle = "title";
+                cardLayout.showTitleHover = "titlehover";
+                cardLayout.isTemplateField = true; // make this document act like a template field
+                cardLayout.isTemplateDoc = true; // but it's also a template doc itself... a little weird
+
+                Document.childLayout = cardLayout;
+                Document.childDetailed = wrapper;
             }
         });
         const existingOnClick = ContextMenu.Instance.findByDescription("OnClick...");
-- 
cgit v1.2.3-70-g09d2

