-
Notifications
You must be signed in to change notification settings - Fork 898
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
Add multiselect option to dropdowns #10270
Conversation
@d-m-u Changes look good. You still need to handle processing an array of values when passing to automate. You can see an example of that here: app/models/dialog_field_tag_control.rb#L70 I did not test with a Also, it would be good if the service dialog preview screen worked as a mult-select control. |
@@ -31,7 +31,15 @@ | |||
= render(:partial => "shared/dialogs/dialog_field_radio_button", :locals => locals) | |||
|
|||
- when "DialogFieldDropDownList" | |||
= render(:partial => "shared/dialogs/dialog_field_drop_down_list", :locals => locals) | |||
- category_tags = field.values.collect(&:reverse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category_tags
is probably not an accurate description of the values being collected here.
Also, is there a reason we're blindly reversing the collection? Shouldn't field.values
already return the values in the correct order based on what the sort_order
is set to?
I know the methods you added code to in
|
end | ||
|
||
def automate_key_name | ||
MiqAeEngine.create_automation_attribute_array_key(super) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs the same return super unless multi_value?
as the automate_output_value
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K, does it also need the def value_from_dialog_fields(dialog_values) that's in tagControl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe it does. Hoping @eclarizio can help you with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already in the parent DialogField
class, so I don't think we need def value_from_dialog_fields
in this file. The one that is in the tag control does something special with classifications.
@miq-bot remove_label wip |
@@ -1,7 +1,13 @@ | |||
- if edit | |||
- select_values = field.values.collect(&:reverse) | |||
- select_values = field.values.collect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the (&:reverse) seems to be important, without that, the names and ids in the selectboxes have switched
@miq-bot add_label wip |
@d-m-u could you chrry-pick this commit Ladas@8c88baa I made it on top of your commits https://github.com/Ladas/manageiq/commits/multiselect These are the fixes I needed, to make multiselectboxes work. When have multiple dynamic multiselectboxes, it throws various failures, without that commit. After that, it works nicely. :-) |
@value.blank? ? [] : @value.chomp.split(',') | ||
end | ||
automate_values = a.first.kind_of?(Integer) ? a.map(&:to_i) : a | ||
MiqAeEngine.create_automation_attribute_array_value(automate_values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkanoor Can you verify that this is going to pass data to the automate engine as expect? This is the last part before merging this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmcculloug @d-m-u
MiqAeEngine.create_automation_attribute_array_value([1,2,3]) => gives you back 1,2,3
For Automate to use it as an array the keyname should be prefixed with Array::
We have a helper method that does that
MiqAeEngine.create_automation_attribute_array_key("my_key")
which returns Array::my_key
You have to use the key and value together
In https://github.com/ManageIQ/manageiq/blob/master/app/models/dialog.rb#L50
We would have to detect that if it is a multi value field it should use
result[MiqAeEngine.create_automation_attribute_array_key(df.automate_key_name)] = df.automate_output_value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this Sunday at 8:05 Mahwah time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-m-u Along with overriding the automate_output_value
you need to override automate_key_name
like we do here app/models/dialog_field_tag_control.rb#L78.
You need the same check for force_multi_value
as above.
Something like this:
def automate_key_name
return super unless force_multi_value
MiqAeEngine.create_automation_attribute_array_key(super)
end
@miq-bot remove_label wip |
app/models/dialog.rb
Outdated
@@ -47,7 +47,9 @@ def dialog_resources | |||
end | |||
|
|||
def automate_values_hash | |||
dialog_fields.each_with_object({}) { |df, result| result[df.automate_key_name] = df.automate_output_value } | |||
dialog_fields.each_with_object({}) do |df, result| | |||
result[MiqAeEngine.create_automation_attribute_array_key(df.automate_key_name)] = df.automate_output_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-m-u Not every attribute is going to be an array type should this be done only for array types?
Checked commits d-m-u/manageiq@ab3412b~...390f8fa with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Wow, a labor of love. Tested last night after the key changes and data is being passed to the automate method as expected. Thanks @d-m-u! 🥇 |
Add multiselect option to dropdowns (cherry picked from commit fd5e8ac) https://bugzilla.redhat.com/show_bug.cgi?id=1430542
Euwe backport details:
|
Adds multiselect flag to dropdowns much like the existing single option for tag controls.
@miq-bot add_label ui
@miq-bot assign @gmcculloug
@miq-bot add_label wip