IDEMSInternational / open-app-builder

PLH App Frontend
GNU General Public License v3.0
5 stars 24 forks source link

[FEATURE] Process answer lists within the parser #2210

Closed jfmcquade closed 2 months ago

jfmcquade commented 4 months ago

What? Following on from #2204, it was agreed that it would be sensible to parse answer lists to object-arrays as part of the parser code, rather than handling at runtime. From this comment:

the answerlist is usually stored in an intermediate local variable which is an array (auto converted by parser for anything with _list in name), but whose elements are formatted string. So when the dynamic variables are replaced they are dropped into something like ["name: @local.name | text: @local.text"] -> ["name: undefined | text:undefined"]

So what would actually be better would be to process these within the parser to convert the string-array into an object-array. That way when replacing the localVariable it could already be formatted as:

[{ "name": "@local.name", "text": "@local.text" }] Which when converted should replace the variables (local, data, field or anything else) it should be able to assign the proper value.

I think would make sense to merge what's here now to fix the issue in the short term, and then I'll try make a quick follow-up pr/issue to see if possible to update the parser as needed.