-
Notifications
You must be signed in to change notification settings - Fork 357
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
Make Save button respond properly on changes in NTP Servers section while editing a Zone #6162
Make Save button respond properly on changes in NTP Servers section while editing a Zone #6162
Conversation
@miq-bot add_label bug, ivanchuk/yes, hammer/yes |
e64c3d3
to
94d5617
Compare
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.
Tested changes, fixes the issue. 👍
@@ -806,6 +806,8 @@ def settings_get_form_vars | |||
field = "ntp_server_#{field_num}" | |||
next unless params.key?(field) | |||
@edit[:new][:ntp][field] = params[field] | |||
# remove unnecessary key from @edit[:new][:ntp] if there is no change | |||
@edit[:new][:ntp].except!(*field) if params[field] == @edit[:new][:ntp][:server][field_num - 1] |
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 asterisk does not seem necessary to me
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 change is done.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1749841 Make the button respond properly while editing an existing Zone.
94d5617
to
bb7d490
Compare
Checked commit hstastna@bb7d490 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1749841
Save button did not respond properly on changes in NTP Servers section while editing an existing Zone. Let me explain the fix. Here, the same as in other screens, values of
@edit[:new]
and@edit[:current]
are crucial for detecting changes in the fields and response of Add/Save buttons. In our case, we need to take care of@edit[:new][:ntp]
and@edit[:current][:ntp]
.Beginning of editing a Zone:
After we make some change and put it back, the result will look like this:
We are adding something extra to
@edit[:new][:ntp]
. We always just add something, not remove. And this is core of the problem why Save button remained always enabled if we touched anything in NTP Servers section, no matter we really made a change or not.So we need to remove unnecessary key
"ntp_server_2"
from@edit[:new][:ntp]
to achieve proper response of Save button. And as we can see that the field/server numbers in the loop are from 1 to 3, we have to look atfield_num - 1
th item in the array of@edit[:new][:ntp][:server]
to remove the right key from@edit[:new][:ntp]
as the second position (field_num == 2) in array is in position 1, obviously.After: (Save button becomes disabled after we put back the original values in fields in NTP Servers)