Closed shots47s closed 4 years ago
Hum. Ok, I'll have a look...
Is it possible the descriptor is wrong? It says "list" in its type, are you supposed to be able to select multiple values? In the command-line would it be -steps cross-sectional template
or what? If only one value is supposed to be selected, then the type is not supposed to be "list", just "string"....
No, it is a list of values selected from a list of acceptable values, so it can be a list made up of elements of only those three choices.
I can make it so that the form properly generates a list, but there is no way I can make it support multiple values, those custom selection boxes can only be used to select one value... :-(
I hear RoR can support multi select https://stackoverflow.com/questions/9280480/multiple-selection-in-ror-form-for
One of my first python task was adding Select 2 to a webapp. It was not as straightforward as I thought and took help of several people to addrss all the bugs and corner cases
Oh, we have lots of multiple selection inputs in CBRAIN, they're all supported fine by RoR; I'm talking about the task submission forms, which do not use standard elements, they built their own dropdowns and checkboxes.
So we would need to build a new element? This whole thing screams of "rewrite me". Where are the elements created?
All the HTML templates and associated javascript code is in https://github.com/aces/cbrain/blob/master/BrainPortal/lib/cbrain_task_generators/templates/task_params.html.erb.erb
I don't think we want to rewrite it all, it's at least one man-year of work. It's good, solid and tested code (see the unit tests in BrainPortal/spec/boutiques/boutiques_tester_spec.rb
and Bourreau/spec/boutiques/boutiques_tester_spec.rb
).
My changes to make it a list was this:
diff --git a/BrainPortal/lib/cbrain_task_generators/templates/task_params.html.erb.erb b/BrainPortal/lib/cbrain_task_generators/templates/task_params.html.erb.erb
index fe903c1..bde260f 100644
--- a/BrainPortal/lib/cbrain_task_generators/templates/task_params.html.erb.erb
+++ b/BrainPortal/lib/cbrain_task_generators/templates/task_params.html.erb.erb
@@ -319,7 +319,8 @@
<%- enum_vals = param["value-choices"] %>
<%- if not enum_vals.nil? -%>
# Enum value dropdown
- dropdown.(id, id,
+ name = id <%= list ? '+ "[]"' : '' %>
+ dropdown.(id, name,
<%= enum_vals.map { |v| [v, v] } %>,
optional: <%= opt %>,
default: <%= "\"#{defaults.find { |d| d['id']==id }['default-value']}\"" rescue "nil" %>
I have searched through all the boutiques descriptors in the CBRAIN service, and I have not find any other instances of a multi list like in the original issue description. I supposed it's a really really rare way of definining an input.
Can the tool be invoked with distinct -steps
arguments? E.g. -steps longitudinal -steps cross-sectional
? In that case I'd create three inputs, named steps1
steps2
and steps3
and allow the user to select one value from three drop downs... The advantage also is that it conserves order.
I looked at the code and I think it would not be too difficult to create a new dropdown for multi select lists. Basically it would look like the normal drop down but when selecting or deslecting an item, the params box would show the item list and a corresponding input
tag (one per item) would be disabled or enabled.
I think this issue should be combined with adding support for list-separator
in the boutiques descriptor (it could even be used in the form's params box).
I have made several implementation recommendations in a comment at the bottom of #861
@shots47s So do we keep this open until a multiselect dropdown widget has been coded? Have you looked at the code as described at bottom of #861 ?
I haven't had a chance, but yes, let's keep it open. I will try to take a look by the end of the week.
Fix by #911
The following Boutiques descriptor implement fails to produce a useful UI element in CBRAIN:
This should produce a list with each element being a select box to set. Right now one only gets a single select box and then if it is set, the task receives a single value and fails to validate against the schema.
Fails in the task with the following error: