-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: set_item action: optionally target an index or id #2215
Conversation
src/app/shared/components/template/components/data-items/data-items.component.ts
Outdated
Show resolved
Hide resolved
Happy with this for now. One reason why |
As mentioned in the comment, all items already have a readonly
I like the look of this, although I would again refer to So assuming syntax something like:
I would also be tempted to let the user pick an item by id, e.g.
And updating the logic to first extract The benefit of doing things this way is we could then use pretty much identical syntax when adding support for updating items from outside the item list itself (currently not supported but expect a nice-to-have). |
Remove unnecessary hardcoded data and add additional public method tests
Thanks for adding the necessary scaffolding and starting to build out the item tests - agreed the service really isn't set up very well for long term maintainability (lots of complex code and weird caveats - which probably makes testing more important but beyond scope of this PR for sure). I've added 149c868 to try and tidy up a little and add a few more basic public method tests, but will stop there as fair chance we'll want to do a larger refactor at some point in the future. But at least for now it covers the new introduced behaviour so I think should be good to go if you're happy with the changes to 149c868 @jfmcquade |
PR Checklist
Description
Adds two new optional parameters for the
set_item
action:_id
and_index
. These are used to target a specific item in the data items loop to set the a value on, for example,click | set_item | _index: 2, completed: true
orclick | set_item | _id: my_some_id, completed: true
._index
NB, the index supplied is evaluated in terms of the standard 0-based indexing of arrays, where the first element of an array has index 0, the second element has index 1, and so on.
JS expressions can be used to specify the target index. Trivially
1 + 2
, for example, to target the item at index3
, but also these expressions can use the@item._index
to refer to the index of the current item in the loop. For example,set_item: @item._index + 1
will target the item that appears after the current item in the data items iterator.Testing
Experiment with Example 4 in the the comp_data_items template – this isn't the prettiest example, but should demonstrate the functionality. And with the example_task_group_stepper template. See screenshots below.
Git Issues
Closes #
Screenshots/Videos
Action
Updated comp_data_items
Use case demo
example_task_group_stepper template and demo. This is our use case for this new feature.
example_task_group_stepper.mov
New tests passing