Closed vedina closed 9 years ago
The current UI widget supports this, it makes AJAX request as the user types and populates the autocomplete list with values from a JSON like this:
[
{ "value": "1", "text": "Alan J. Heeger (United States)" },
{ "value": "2", "text": "Alan G. MacDiarmid (United States, New Zealand)" }
]
The exact JSON fields are confugarble, the name of the search query param is also configurable.
How can I specify URI for the AJAX request and be able to prepopulate the list with already assigned users (another ajax request)
/myaccount/users?q=Ni&media=application/json
/myaccount/users?bundle_uri=BUNDLEURI&media=application/json&mode=R|W
See the current implementation with tokeninput JS library
For update - what is the preferred approach ?
Is there existing (POST/PUT) query supported by the library ?
To prepopulate the list we will make a request before initializing the widget, fill the select
with option
s and select them. When we are initializing the widget, we should provide the URL for searching users as an option, the same as the current implementation.
For updating there is no build-in functionality, because the general use of such widgets is in forms that will be submitted as a whole - there is a select
element with multiple
attribute, which sends all the selected items. We can go either way - updating all rights at once will save some requests to the server.
OK
Up to you to decide which tokenizer library to use, I'll update the JSON format accordingly. Currently /myaccount
queries only work for logged in users at /opentox
server.
If updating at once do we need a separate button to initiate the update?
Note: would be good if the access rights widget is a separate component; the reason is it will be hidden in some profiles (hence AJAX queries will be redundant) and also may be reused for resources other than bundles. It may take the URIs of the AJAX requests as parameters.
No, I don't think so, we can use the onblur
or onchange
event.
Let's do application/x-www-form-urlencoded POST , in addition to the multiselect field will need the bundle_uri and the mode options
curl -X POST -d "bundlenumberi=BUNDLE_UUID" -d “canWrite=username” -d “canWrite=username” "/myaccount/users"
curl -X POST -d "bundlenumberi=BUNDLE_UUID" -d “canRead=username” -d “canRead=username” "/myaccount/users"
Implemented. The users are updated on every add/remove, because it works better this way with the widget.
Could we use a tokenize library allowing to fill in the users dynamically (to extend #108).
If the current one supports this, what is the JSON format?