diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-03-27 23:30:03 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-03-27 23:30:03 -0400 |
commit | f80aee53be8582956a1f39519938700c3e90cb53 (patch) | |
tree | 8de6544a3970565fd8625fd4bf30292b6d88fe5f /src/new_fields/Doc.ts | |
parent | 692381503f2af93dba2a4f30495a17b7b4deed36 (diff) |
fixed up embedded document view layout references in text boxes to 1) create the template if it doesn't exist and 2) to allow parameters to be passed to templates
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 8447a4e93..2a7b08d44 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -463,7 +463,7 @@ export namespace Doc { // between the two. If so, the layoutDoc is expanded into a new document that inherits the properties // of the original layout while allowing for individual layout properties to be overridden in the expanded layout. // - export function expandTemplateLayout(templateLayoutDoc: Doc, targetDoc?: Doc) { + export function expandTemplateLayout(templateLayoutDoc: Doc, targetDoc?: Doc, templateParams?: string) { if (!WillExpandTemplateLayout(templateLayoutDoc, targetDoc) || !targetDoc) return templateLayoutDoc; const templateField = StrCast(templateLayoutDoc.isTemplateForField); // the field that the template renders @@ -484,6 +484,7 @@ export namespace Doc { if (!targetDoc[expandedLayoutFieldKey]) { const newLayoutDoc = Doc.MakeDelegate(templateLayoutDoc, undefined, "[" + templateLayoutDoc.title + "]"); newLayoutDoc.expandedTemplate = targetDoc; + newLayoutDoc.params = templateParams?.match(/\(([a-zA-Z0-9_-]*)\)/)?.[1]; targetDoc[expandedLayoutFieldKey] = newLayoutDoc; const dataDoc = Doc.GetProto(targetDoc); newLayoutDoc.resolvedDataDoc = dataDoc; |