ideaconsult / Toxtree.js

http://ideaconsult.github.io/Toxtree.js/
2 stars 3 forks source link

Dynamic retrieval of the user names for RA #115

Closed vedina closed 9 years ago

vedina commented 9 years ago

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?

gonzomir commented 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.

vedina commented 9 years ago

How can I specify URI for the AJAX request and be able to prepopulate the list with already assigned users (another ajax request)

image

 /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

vedina commented 9 years ago

For update - what is the preferred approach ?

Is there existing (POST/PUT) query supported by the library ?

gonzomir commented 9 years ago

To prepopulate the list we will make a request before initializing the widget, fill the select with options 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.

vedina commented 9 years ago

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.

gonzomir commented 9 years ago

No, I don't think so, we can use the onblur or onchange event.

vedina commented 9 years ago

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"

API-Docs

gonzomir commented 9 years ago

Implemented. The users are updated on every add/remove, because it works better this way with the widget.