aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-08-24 10:08:50 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-08-24 10:08:50 -0400
commit21c02362a9b658459054a7880aa011e6262f3ae7 (patch)
tree32ae14dd6f47dc4635bbef37981c86d2ca8e72e4 /src/new_fields/Doc.ts
parent4ab81702c2c78ae20c1984985aaef880d21aef9e (diff)
parentd237c67b236ce66e9bc711931e4c283a8c1e95f2 (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.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index f6114d476..6f1ef38d1 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -525,13 +525,23 @@ export namespace Doc {
return otherdoc;
}
export function ApplyTemplateTo(templateDoc: Doc, target: Doc, targetData?: Doc) {
+ if (!templateDoc) {
+ target.layout = undefined;
+ target.nativeWidth = undefined;
+ target.nativeHeight = undefined;
+ target.onClick = undefined;
+ target.type = undefined;
+ return;
+ }
let temp = Doc.MakeDelegate(templateDoc);
target.nativeWidth = Doc.GetProto(target).nativeWidth = undefined;
target.nativeHeight = Doc.GetProto(target).nativeHeight = undefined;
+ !templateDoc.nativeWidth && (target.nativeWidth = 0);
+ !templateDoc.nativeHeight && (target.nativeHeight = 0);
target.width = templateDoc.width;
target.height = templateDoc.height;
target.onClick = templateDoc.onClick instanceof ObjectField && templateDoc.onClick[Copy]();
- Doc.GetProto(target).type = DocumentType.TEMPLATE;
+ target.type = DocumentType.TEMPLATE;
if (targetData && targetData.layout === target) {
targetData.layout = temp;
targetData.miniLayout = StrCast(templateDoc.miniLayout);
@@ -541,8 +551,6 @@ export namespace Doc {
target.miniLayout = StrCast(templateDoc.miniLayout);
target.detailedLayout = target.layout;
}
- !templateDoc.nativeWidth && (target.nativeWidth = 0);
- !templateDoc.nativeHeight && (target.nativeHeight = 0);
}
export function MakeTemplate(fieldTemplate: Doc, metaKey: string, templateDataDoc: Doc) {
@@ -581,7 +589,8 @@ export namespace Doc {
let miniLayout = await PromiseValue(d.miniLayout);
let detailLayout = await PromiseValue(d.detailedLayout);
d.layout !== miniLayout ? miniLayout && (d.layout = d.miniLayout) : detailLayout && (d.layout = detailLayout);
- if (d.layout === detailLayout) Doc.GetProto(d).nativeWidth = Doc.GetProto(d).nativeHeight = undefined;
+ if (d.layout === detailLayout) d.nativeWidth = d.nativeHeight = 0;
+ if (StrCast(d.layout) !== "") d.nativeWidth = d.nativeHeight = undefined;
});
}
export function UseDetailLayout(d: Doc) {
@@ -627,4 +636,5 @@ export namespace Doc {
}
Scripting.addGlobal(function renameAlias(doc: any, n: any) { return StrCast(doc.title).replace(/\([0-9]*\)/, "") + `(${n})`; });
Scripting.addGlobal(function getProto(doc: any) { return Doc.GetProto(doc); });
-Scripting.addGlobal(function copyField(field: any) { return ObjectField.MakeCopy(field); }); \ No newline at end of file
+Scripting.addGlobal(function copyField(field: any) { return ObjectField.MakeCopy(field); });
+Scripting.addGlobal(function aliasDocs(field: any) { return new List<Doc>(field.map((d: any) => Doc.MakeAlias(d))); }); \ No newline at end of file