aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Doc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r--src/fields/Doc.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index b3a17de8f..a9bc5ee70 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -44,7 +44,7 @@ export namespace Field {
* @param showComputedValue whether copmuted function should display its value instead of its function
* @returns string representation of the field
*/
- export function toKeyValueString(doc: Doc, key: string, showComputedValue?: boolean): string {
+ export function toKeyValueString(doc: Doc, key: string, showComputedValue?: boolean, schemaCell?: boolean): string {
const isOnDelegate = !Doc.IsDataProto(doc) && Object.keys(doc).includes(key.replace(/^_/, ''));
const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key]));
const valFunc = (field: FieldType): string => {
@@ -55,7 +55,7 @@ export namespace Field {
? `:=${field.script.originalScript.replace(/dashCallChat\(_setCacheResult_, this, `(.*)`\)/, '(($1))')}`
: field instanceof ScriptField
? `$=${field.script.originalScript}`
- : Field.toScriptString(field);
+ : Field.toScriptString(field, schemaCell);
const resStr = (res + '').replace(/^`(.*)`$/, '$1');
return typeof field === 'string' && (+resStr).toString() !== resStr && !Array.from('+-*/.').some(k => Array.from(resStr).includes(k))
? resStr
@@ -65,10 +65,10 @@ export namespace Field {
};
return !Field.IsField(cfield) ? (key.startsWith('_') ? '=' : '') : (isOnDelegate ? '=' : '') + valFunc(cfield);
}
- export function toScriptString(field: FieldType) {
+ export function toScriptString(field: FieldType, schemaCell?: boolean) {
switch (typeof field) {
case 'string': if (field.startsWith('{"')) return `'${field}'`; // bcz: hack ... want to quote the string the right way. if there are nested "'s, then use ' instead of ". In this case, test for the start of a JSON string of the format {"property": ... } and use outer 's instead of "s
- return !field.includes('`') ? `\`${field}\`` : `"${field}"`;
+ return !field.includes('`') ? schemaCell ? `${field}` : `\`${field}\`` : `"${field}"`;
case 'number':
case 'boolean':return String(field);
default: return field?.[ToScriptString]?.() ?? 'null';
@@ -216,7 +216,7 @@ export class Doc extends RefField {
public static DeleteLink: (link: Doc) => void;
public static Links: (link: Doc | undefined) => Doc[];
public static getOppositeAnchor: (linkDoc: Doc, anchor: Doc) => Doc | undefined;
- // KeyValue SetField
+ // KeyValueBox SetField (defined there)
public static SetField: (doc: Doc, key: string, value: string, forceOnDelegate?: boolean, setResult?: (value: FieldResult) => void) => boolean;
// UserDoc "API"
public static get MySharedDocs() { return DocCast(Doc.UserDoc().mySharedDocs); } // prettier-ignore
@@ -1062,12 +1062,13 @@ export namespace Doc {
const target = Doc.MakeDelegate(proto);
const targetKey = StrCast(templateDoc.layout_fieldKey, 'layout');
const applied = ApplyTemplateTo(templateDoc, target, targetKey, templateDoc.title + '(...' + _applyCount++ + ')');
- target.layout_fieldKey = targetKey;
+ target.layout_fieldKey = targetKey; //this and line above
applied && (Doc.GetProto(applied).type = templateDoc.type);
return applied;
}
return undefined;
}
+
export function ApplyTemplateTo(templateDoc: Doc, target: Doc, targetKey: string, titleTarget: string | undefined) {
if (!Doc.AreProtosEqual(target[targetKey] as Doc, templateDoc)) {
if (target.resolvedDataDoc) {