diff --git a/fastn-js/js/utils.js b/fastn-js/js/utils.js index 645eb2aa0..df917bf08 100644 --- a/fastn-js/js/utils.js +++ b/fastn-js/js/utils.js @@ -50,9 +50,9 @@ let fastn_utils = { return this.getStaticValue(obj.get()); } else if (obj instanceof fastn.mutableListClass) { return obj.getList(); - } else if (obj instanceof fastn.recordInstanceClass) { - return obj.toObject(); - } else { + } /*else if (obj instanceof fastn.recordInstanceClass) { + return obj.getAllFields(); + }*/ else { return obj; } }, @@ -107,15 +107,13 @@ let fastn_utils = { if (Array.isArray(staticValue)) { return staticValue.map(func => fastn_utils.getFlattenStaticValue(func.item)); - } /* - Todo: Make this work - else if (typeof staticValue === 'object' && fastn_utils.isNull(staticValue)) { + } else if (typeof staticValue === 'object' && fastn_utils.isNull(staticValue)) { return Object.fromEntries( Object.entries(staticValue).map(([k,v]) => [k, fastn_utils.getFlattenStaticValue(v)] ) ); - }*/ + } return staticValue; }, getter(value) { @@ -140,7 +138,15 @@ let fastn_utils = { const parts = notation.split('.'); return parts - .reduce((obj, key) => fastn_utils.getFlattenStaticValue(obj[key]), fastn_utils.getFlattenStaticValue(value)); + .reduce((obj, key) => { + const value = fastn_utils.getFlattenStaticValue(obj[key]); + + if(value instanceof fastn.recordInstanceClass) { + return value.getAllFields(); + } + + return value; + }, fastn_utils.getFlattenStaticValue(value)); }, setter(variable, value) { if (!fastn_utils.isNull(variable) && variable.set) { diff --git a/ftd/t/js/04-variable.html b/ftd/t/js/04-variable.html index 7336dc611..827932416 100644 --- a/ftd/t/js/04-variable.html +++ b/ftd/t/js/04-variable.html @@ -156,7 +156,7 @@ a: fastn.mutableList([]), ...args }; - return (ftd.append(__args__.a, __args__.v)); + return (ftd.append(fastn_utils.getValueByDotNotation(__args__, "a"), fastn_utils.getValueByDotNotation(__args__, "v"))); } finally { __fastn_package_name__ = __fastn_super_package_name__; } diff --git a/ftd/t/js/05-dynamic-dom-list.html b/ftd/t/js/05-dynamic-dom-list.html index 9a3fdf7fb..5c0ec9bd0 100644 --- a/ftd/t/js/05-dynamic-dom-list.html +++ b/ftd/t/js/05-dynamic-dom-list.html @@ -92,7 +92,7 @@ a: fastn.mutableList([]), ...args }; - return (ftd.append(__args__.a, __args__.v)); + return (ftd.append(fastn_utils.getValueByDotNotation(__args__, "a"), fastn_utils.getValueByDotNotation(__args__, "v"))); } finally { __fastn_package_name__ = __fastn_super_package_name__; } diff --git a/ftd/t/js/06-dynamic-dom-list-2.html b/ftd/t/js/06-dynamic-dom-list-2.html index dc0b07ec2..2791fc62a 100644 --- a/ftd/t/js/06-dynamic-dom-list-2.html +++ b/ftd/t/js/06-dynamic-dom-list-2.html @@ -66,7 +66,7 @@ a: fastn.mutableList([]), ...args }; - return (ftd.append(__args__.a, __args__.v)); + return (ftd.append(fastn_utils.getValueByDotNotation(__args__, "a"), fastn_utils.getValueByDotNotation(__args__, "v"))); } finally { __fastn_package_name__ = __fastn_super_package_name__; } @@ -81,7 +81,7 @@ __fastn_package_name__ = "foo"; try { let __args__ = args; - let fastn_utils_val___args___a = fastn_utils.clone(__args__.v); + let fastn_utils_val___args___a = fastn_utils.clone(fastn_utils.getValueByDotNotation(__args__, "v")); if (fastn_utils_val___args___a instanceof fastn.mutableClass) { fastn_utils_val___args___a = fastn_utils_val___args___a.get(); } diff --git a/ftd/t/js/07-dynamic-dom-record-list.html b/ftd/t/js/07-dynamic-dom-record-list.html index 768527371..c6765166d 100644 --- a/ftd/t/js/07-dynamic-dom-record-list.html +++ b/ftd/t/js/07-dynamic-dom-record-list.html @@ -57,7 +57,7 @@ a: fastn.mutableList([]), ...args }; - return (ftd.append(__args__.a, __args__.v)); + return (ftd.append(fastn_utils.getValueByDotNotation(__args__, "a"), fastn_utils.getValueByDotNotation(__args__, "v"))); } finally { __fastn_package_name__ = __fastn_super_package_name__; } diff --git a/ftd/t/js/23-record-list.html b/ftd/t/js/23-record-list.html index fe0c1aacb..d146ab396 100644 --- a/ftd/t/js/23-record-list.html +++ b/ftd/t/js/23-record-list.html @@ -16,7 +16,7 @@ -
1
Ritesh
2
Ajinosaurus
1
Ritesh
+ + +
Log first day
Log github link
Log user name
+ +