-
Notifications
You must be signed in to change notification settings - Fork 356
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
Do not enable disabled button when items are selected #1031
Do not enable disabled button when items are selected #1031
Conversation
f6a6db2
to
13d918b
Compare
13d918b
to
1b20a94
Compare
enabled = !disabled? | ||
self[:enabled] = enabled if self[:enabled].nil? | ||
|
||
unless self[:enabled] || enabled |
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.
self[:enabled].nil?
would be better here, so it's clear, we are testing it for nil
presence.
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.
:enable | disabled? | :enabled | :title | :onwhen |
---|---|---|---|---|
true | true/false | unchanged | unchenged | unchanged |
false | true | false | error | nil |
false | false | false | unchenged | unchanged |
nil | true | false | error | nil |
nil | false | true | unchenged | unchanged |
@romanblanco
we change :enable
only if it's nil
but we change :title and :onwhen on nil or false
but yes it's not nice, I can't change is to .nil?
but can we do something else to make it better ?
my main problem is the :enable == false is not really false it's false unless :onwhen is true :-(
def calculate_properties | ||
self[:enabled] = !disabled? if self[:enabled].nil? | ||
self[:title] = @error_message if @error_message.present? | ||
enabled = !disabled? |
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 changes are nice! But the code is still a bit unreadable, can you add some comments here?
# returns enabled state and sets @error_message
self[:enabled] = enabled if self[:enabled].nil? | ||
|
||
unless self[:enabled] || enabled | ||
self[:onwhen] = nil |
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.
# button will be visible and disabled, but won't be possible to enable it by javascript
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.
👍 on it, it is really unreadable now, @enoodle just comment on it too :-)
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.
@romanblanco added some comments PTAL
c1db244
to
8f7dcd3
Compare
@dclarizio @h-kataria since this is core can you take care of the proper labels/BZs for which this is targeted to? |
@miq-bot add_label toolbars |
Checked commits yaacov/manageiq-ui-classic@1b20a94~...36d1ae3 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
Looks good now 👍 🌞
…when-items-are-selected Do not enable disabled button when items are selected (cherry picked from commit ccd29a5) https://bugzilla.redhat.com/show_bug.cgi?id=1440566
Fine backport details:
|
Description
Currently the
:onwhen
property override thedisabled?
method of a button. If a disabled button has the:onwhen
set, it will become enabled if user select an item from the list.Currently the
disabled?
method is not called ifself[:enabled].nil?
is false, so the@error_message
variable is not being set, and does not replace the:title
.This PR:
a. Remove the
:onwhen
property of a disabled itemb. Calls the
disabled?
method, to set the@error_message
variableScreenshots
Bug
![screenshot-localhost 3000-2017-04-13-10-54-21](https://cloud.githubusercontent.com/assets/2181522/24996166/7b06e00a-203a-11e7-8c9a-3bb17467c8a9.png)
Fix
![screenshot from 2017-04-13 11-04-53](https://cloud.githubusercontent.com/assets/2181522/24996178/89efffde-203a-11e7-912a-41f35b882905.jpg)
Fix when
![screenshot from 2017-04-13 11-18-40](https://cloud.githubusercontent.com/assets/2181522/24996329/17bd09f6-203b-11e7-9ac3-fd22b499a9c6.jpg)
disabled?
is falseDuplicate of:
#943
Fixes a bug related to this BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1438248
Closes #943