Skip to content

Commit

Permalink
Merge branch 'ts/renderer-refactor' of github.com:Microsoft/AdaptiveC…
Browse files Browse the repository at this point in the history
…ards into ts/renderer-refactor
  • Loading branch information
jwoo-msft committed May 8, 2020
2 parents 7cd9ef6 + 487d3b3 commit 858c7c0
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 165 deletions.
40 changes: 26 additions & 14 deletions source/nodejs/adaptivecards-designer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/nodejs/adaptivecards-designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"release": "npm run build && webpack --mode=production && npm run dts"
},
"dependencies": {
"adaptive-expressions": "^4.9.0-preview-117200",
"adaptive-expressions": "^4.9.0-rc5",
"adaptivecards": "^2.0.0-alpha.1",
"adaptivecards-controls": "^0.3.5",
"adaptivecards-templating": "^0.1.2-alpha.0",
Expand Down
12 changes: 7 additions & 5 deletions source/nodejs/adaptivecards-designer/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,14 @@ export class ObjectData extends DataType {
static deriveFrom(parent: FieldDefinition, input: object): ObjectData {
let result = new ObjectData(parent);

for (let key of Object.keys(input)) {
let field = new FieldDefinition(parent);
field.dataType = DataType.deriveFrom(field, input[key]);
field.name = key;
if (input !== null) {
for (let key of Object.keys(input)) {
let field = new FieldDefinition(parent);
field.dataType = DataType.deriveFrom(field, input[key]);
field.name = key;

result.fields.push(field);
result.fields.push(field);
}
}

return result;
Expand Down
68 changes: 0 additions & 68 deletions source/nodejs/adaptivecards-site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@
var dataUrl = getParameterByName("data", null);
if (dataUrl) {
var xhttp = new XMLHttpRequest();
xhttp.onload = function () {
if (xhttp.responseText && xhttp.responseText != "") {
var sampleData = JSON.parse(xhttp.responseText);
var dataXhttp = new XMLHttpRequest();
dataXhttp.onload = function () {
if (dataXhttp.responseText && dataXhttp.responseText != "") {
var sampleData = JSON.parse(dataXhttp.responseText);
designer.sampleData = sampleData;
}
};
Expand All @@ -147,10 +147,9 @@
// };
try {
xhttp.open("GET", dataUrl, true);
xhttp.send();
dataXhttp.open("GET", dataUrl, true);
dataXhttp.send();
} catch (e) {
}
} else {
// Add sample data
Expand All @@ -175,10 +174,10 @@
}
if (cardUrl) {
var xhttp = new XMLHttpRequest();
xhttp.onload = function () {
if (xhttp.responseText && xhttp.responseText != "") {
designer.setCard(JSON.parse(xhttp.responseText));
var cardXhttp = new XMLHttpRequest();
cardXhttp.onload = function () {
if (cardXhttp.responseText && cardXhttp.responseText != "") {
designer.setCard(JSON.parse(cardXhttp.responseText));
}
// TODO: Talk to David: I want to put the sampleData setter here but it was failing
Expand All @@ -192,8 +191,8 @@
// };
try {
xhttp.open("GET", cardUrl, true);
xhttp.send();
cardXhttp.open("GET", cardUrl, true);
cardXhttp.send();
} catch (e) {
}
} else {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -408,32 +408,9 @@ $(function () {

if (dataJson) {
var template = new ACData.Template(json);
var context = {
adaptiveCard.parse(template.expand({
$root: dataJson
}

// context.registerFunction("format", function(param0, param1) {
// switch (param1) {
// case ("%"):
// return (param0 * 100).toFixed(2) + "%";

// default:
// return "Unknown format: " + param1;
// }
// });

// context.registerFunction("parseDateFromEpoch", function(param) {
// try {
// let d = new Date(param);
// let timeZoneOffset = ("0" + new Date().getTimezoneOffset() / 60).slice(-2);
// return d.toISOString().substr(0, 19) + "-03:00";
// } catch(e) {
// return "Unable to parse epoch";
// }

// });

adaptiveCard.parse(template.expand(context));
}));
renderedCard = adaptiveCard.render();
} else {
adaptiveCard.parse(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Holds global settings that can be used to customize the way templates are expand

**getUndefinedFieldValueSubstitutionString**? : *function* = undefined

*Defined in [template-engine.ts:107](https://github.com/microsoft/AdaptiveCards/blob/62537c57c/source/nodejs/adaptivecards-templating/src/template-engine.ts#L107)*
*Defined in [template-engine.ts:107](https://github.com/microsoft/AdaptiveCards/blob/bf1bfa514/source/nodejs/adaptivecards-templating/src/template-engine.ts#L107)*

Callback invoked when expression evaluation needs the value of a field in the source data object
and that field is undefined or null. By default, expression evaluation will substitute an undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Represents a template that can be bound to data.

\+ **new Template**(`payload`: any): *[Template](template.md)*

*Defined in [template-engine.ts:385](https://github.com/microsoft/AdaptiveCards/blob/62537c57c/source/nodejs/adaptivecards-templating/src/template-engine.ts#L385)*
*Defined in [template-engine.ts:394](https://github.com/microsoft/AdaptiveCards/blob/bf1bfa514/source/nodejs/adaptivecards-templating/src/template-engine.ts#L394)*

Initializes a new Template instance based on the provided payload.
Once created, the instance can be bound to different data objects
Expand All @@ -46,7 +46,7 @@ Name | Type | Description |

**expand**(`context`: [IEvaluationContext](../interfaces/ievaluationcontext.md)): *any*

*Defined in [template-engine.ts:465](https://github.com/microsoft/AdaptiveCards/blob/62537c57c/source/nodejs/adaptivecards-templating/src/template-engine.ts#L465)*
*Defined in [template-engine.ts:474](https://github.com/microsoft/AdaptiveCards/blob/bf1bfa514/source/nodejs/adaptivecards-templating/src/template-engine.ts#L474)*

Expands the template using the provided context. Template expansion involves
evaluating the expressions used in the original template payload, as well as
Expand Down Expand Up @@ -127,7 +127,7 @@ ___

**parseInterpolatedString**(`interpolatedString`: string): *Expression | string*

*Defined in [template-engine.ts:212](https://github.com/microsoft/AdaptiveCards/blob/62537c57c/source/nodejs/adaptivecards-templating/src/template-engine.ts#L212)*
*Defined in [template-engine.ts:212](https://github.com/microsoft/AdaptiveCards/blob/bf1bfa514/source/nodejs/adaptivecards-templating/src/template-engine.ts#L212)*

Parses an interpolated string into an Expression object ready to evaluate.

Expand All @@ -147,7 +147,7 @@ ___

**tryEvaluateExpression**(`expression`: Expression, `context`: [IEvaluationContext](../interfaces/ievaluationcontext.md), `allowSubstitutions`: boolean): *object*

*Defined in [template-engine.ts:263](https://github.com/microsoft/AdaptiveCards/blob/62537c57c/source/nodejs/adaptivecards-templating/src/template-engine.ts#L263)*
*Defined in [template-engine.ts:263](https://github.com/microsoft/AdaptiveCards/blob/bf1bfa514/source/nodejs/adaptivecards-templating/src/template-engine.ts#L263)*

Tries to evaluate the provided expression using the provided context.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Holds the context used to expand a template.

**$root**: *any*

*Defined in [template-engine.ts:118](https://github.com/microsoft/AdaptiveCards/blob/62537c57c/source/nodejs/adaptivecards-templating/src/template-engine.ts#L118)*
*Defined in [template-engine.ts:118](https://github.com/microsoft/AdaptiveCards/blob/bf1bfa514/source/nodejs/adaptivecards-templating/src/template-engine.ts#L118)*

The root data object the template will bind to. Expressions that refer to $root in the template payload
map to this field. Initially, $data also maps to $root.
Loading

0 comments on commit 858c7c0

Please sign in to comment.