diff options
author | bob <bcz@cs.brown.edu> | 2020-02-11 14:19:56 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2020-02-11 14:19:56 -0500 |
commit | be02a5529f472507512a127cd8de5cde300eff88 (patch) | |
tree | d614abe117cfa66a4188ad31be57e73ebd1eb4a9 /src/new_fields/Doc.ts | |
parent | 70c5fd31d58d77707debbb846049838a3940418e (diff) |
added ability to pass a Layout as a prop. changed presentations to use layout props. fixed creating a template for just an empty collection representing one field.
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 1636f4ee7..447dbe3b0 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -701,8 +701,11 @@ export namespace Doc { } // the document containing the view layout information - will be the Document itself unless the Document has - // a layout field. In that case, all layout information comes from there unless overriden by Document - export function Layout(doc: Doc): Doc { return doc[LayoutSym] || doc; } + // a layout field or 'layout' is given. + export function Layout(doc: Doc, layout?: Doc): Doc { + const overrideLayout = layout && Cast(doc["data-layout[" + layout[Id] + "]"], Doc, null); + return overrideLayout || doc[LayoutSym] || doc; + } export function SetLayout(doc: Doc, layout: Doc | string) { doc[StrCast(doc.layoutKey, "layout")] = layout; } export function LayoutField(doc: Doc) { return doc[StrCast(doc.layoutKey, "layout")]; } export function LayoutFieldKey(doc: Doc): string { return StrCast(Doc.Layout(doc).layout).split("'")[1]; } |