Option to set or clear an array field
Closed this issue · 4 comments
Let's take questionnaire as an example. There is items
which is an array and there's enableWhen
, which is also an array, for each of those items. There are only 2 ways to manipulate these fields, get (getItem()/getEnableWhen()
) or add (addItem()/addEnableBehaviour()
). This is fine except for when we want to update something.
How I handle update is first fetching all data into an array and find the corresponding entry from it (Either by id or index) and then updating it. It's a lot of work but it works fine for most cases. When it comes to Questionnaire
, this approach faced an issue. In Questionnaire
we have to keep the questions in order that they will be attended in. So when we add a question in between, replacing data at the index of item works fine but then I have no way to clear the applied enableWhen
condition at that index. There is no option to insert at index either. It would be super helpful if there is also a function that can clear, set or insert on that field directly.
For now I know I can re build the JSON structure for that resource and clear it like that but then what's the point of using the classes 😄
Ah! I could have sworn I had this at one point! Thank you for the PR, I will review ASAP!
@dcarbone you do, but only for contained field. Which is common for all domain resources.
@Aravind-MJ: I've released v3.1.0, please let me know if this fits your need!
@dcarbone Yes it does. Thanks!