venmo/business-rules-ui

Generated actions are not loadable

Opened this issue · 1 comments

Unless I'm missing something, while the conditions are loadable in their exported format, actions are not loadable in their exported format.

Example -

Using the demo, if you add an action and click 'pretend submit' the following JSON is created -
[{"name":"put_on_sale","params":{"sale_percentage":"5"}}]

However if you try to load that JSON back in to actionsBuilder, it does not populate the UI. For example -

var data = { actions: [ { name: "put_on_sale", label: "Put On Sale", params: [{name: "sale_percentage", label: "Sale Percentage", fieldType : "numeric"}]}, { name: "order_more", label: "Order More", params: [{name: "number_to_order", label: "Number To Order", fieldType : "numeric"}]} ], data: [{"name":"put_on_sale","params":{"sale_percentage":"5"}}] }; actions.actionsBuilder(data);

Nothing is generated in the UI. But if you use a different input format found elsewhere in the documentation it does generate the saved fields in the UI, e.g. -

data: [ {name: "action-select", value: "put_on_sale", params: [ {name: "sale_percentage", value: 10} ]}, {name: "action-select", value: "order_more", params: [ {name: "number_to_order", value: 50} ]} ]

A little confusing since the conditions portion will accept what is exported. Am I missing something?

Specifically, if you try to import the json that was exported an error is thrown

actions-builder.js:189 Uncaught TypeError: Cannot read property 'length' of undefined.

I've spent some time debugging can't figure out where the discrepancy is.