aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-06-28 15:14:19 -0400
committeryipstanley <stanley_yip@brown.edu>2019-06-28 15:14:19 -0400
commitb02ce1a10d89fbf8768b93bf9d68c13cc0fb2752 (patch)
tree7ab99d6c40224270f4264c4a5134a7ff0c5654f7 /src/new_fields/Doc.ts
parent22c5ae30ab7835bfeae148642b182a2075760bc1 (diff)
parent09042b933c843d24a715e8c58414976133b19e41 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index d552ddd2d..27dcfba08 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -280,7 +280,15 @@ export namespace Doc {
return new Doc;
}
- export function expandTemplateLayout(templateLayoutDoc: Doc, dataDoc: Doc) {
+ export function expandTemplateLayout(templateLayoutDoc: Doc, dataDoc?: Doc) {
+ let resolvedDataDoc = (templateLayoutDoc !== dataDoc) ? dataDoc : undefined;
+ if (!dataDoc || !(templateLayoutDoc && !(Cast(templateLayoutDoc.layout, Doc) instanceof Doc) && resolvedDataDoc && resolvedDataDoc !== templateLayoutDoc)) {
+ return templateLayoutDoc;
+ }
+ // if we have a data doc that doesn't match the layout, then we're rendering a template.
+ // ... which means we change the layout to be an expanded view of the template layout.
+ // This allows the view override the template's properties and be referenceable as its own document.
+
let expandedTemplateLayout = templateLayoutDoc["_expanded_" + dataDoc[Id]];
if (expandedTemplateLayout instanceof Doc) {
return expandedTemplateLayout;