aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-07-23 19:07:08 -0400
committerbob <bcz@cs.brown.edu>2019-07-23 19:07:08 -0400
commit6d25848a9e8614c1debc8550e42fc706f77883db (patch)
tree3141bebfea498f45132caa1750f3e12b4c51f7fb /src/new_fields
parent86971952237b8bd01a23b52db662740126bd8477 (diff)
more template stuff
Diffstat (limited to 'src/new_fields')
-rw-r--r--src/new_fields/Doc.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 5ae0753d8..e4bf4a6c1 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -337,11 +337,15 @@ export namespace Doc {
return Doc.MakeDelegate(doc); // bcz?
}
- export function expandTemplateLayout(templateLayoutDoc: Doc, dataDoc?: Doc) {
+ export function WillExpandTemplateLayout(templateLayoutDoc: Doc, dataDoc?: Doc) {
let resolvedDataDoc = (templateLayoutDoc !== dataDoc) ? dataDoc : undefined;
if (!dataDoc || !(templateLayoutDoc && !(Cast(templateLayoutDoc.layout, Doc) instanceof Doc) && resolvedDataDoc && resolvedDataDoc !== templateLayoutDoc)) {
- return templateLayoutDoc;
+ return false;
}
+ return true;
+ }
+ export function expandTemplateLayout(templateLayoutDoc: Doc, dataDoc?: Doc) {
+ if (!WillExpandTemplateLayout(templateLayoutDoc, dataDoc) || !dataDoc) 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.
@@ -433,6 +437,7 @@ export namespace Doc {
layoutDelegate.layout = layout;
fieldTemplate.title = metaKey;
+ fieldTemplate.templateField = metaKey;
fieldTemplate.layout = layoutDelegate !== fieldTemplate ? layoutDelegate : layout;
fieldTemplate.backgroundLayout = backgroundLayout;
fieldTemplate.nativeWidth = nw;