Accessing variables from the outer loop of nested loop in a form

1
0
-1

I have a list of user and a list of items with a reference to the user that it was created by. I want to display the list of users along with the items the user created.

My first thought was to create a container for the user list, and a nested container for the items and hide all of the items not created by the current user. To do this requires access to the user from the parent container. Is this possible, and how would it be done. From the AngularJS ngRepeat documentation it looks $parent should work but I was not able to get it to work.

Comments

Submitted by Sean McP on Wed, 04/13/2016 - 10:33

this question, reworded, would probably get a quicker answer on http://stackoverflow.com/ where you will find some very active AngularJS programmers.

Oh yes, you will probably need to do this in a custom widget. The basic table widget may not work to your satisfaction.

regards
Seán

1 answer

1
0
-1

I am not using a table widget, let me take another try to explain what I am trying to do. It should be relatively common but unfortunately the Bonitasoft UI development environment makes it a lot more difficult to explain than just pasting a piece of code in the forum.

For my data model I have a list of users, and a list of questions. I want to display the information about the user along with the questions they asked. I can't change my data model to put the questions a user asked in the user list, because the user the Bonitasoft user account.

The pseudo code looks like this

"users":[
{
"id":200,
"firstName":"George",
"lastName":"Jetson"
...
},
{
"id":201,
"firstName":"Elroy",
"lastName":"Jetson"
...
}
"questions":[
{
"userId":200,
"question":"Why me?",
...
....
},
{
"userId":201,
"question":"Why not me?",
...
....
}

Container collection users
{
Input field $item.firstName
Input field $item.lastName

Container collection questions
{
Container hidden $parent.id != $item.userId
{
Input field $item.question
}
}
}

My understanding from reading stackoverflow and AngularJS documentation is that $parent should reference the current item in the users list, but it is not working.

This is requirement is common enough that it should be included in the Bonitasoft documentation. I the spirit of open source how would I add it, or get it added to the documentation.

Notifications