-
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
Fix issues related to adding, editing Chargeback Rates #3129
Fix issues related to adding, editing Chargeback Rates #3129
Conversation
@miq-bot add_label bug, gaprindashvili/yes |
b727941
to
c0e8ed8
Compare
c0e8ed8
to
a2adf5c
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.
Fixes both issues described in ManageIQ/manageiq#16699. 👍
Tests are passing locally. |
fixing ManageIQ/manageiq#16699 Fix issues with adding new or editing existing chargeback rates in Cloud Intel -> Chargeback -> Rates tab, caused by improper detail_index in the chargeback rate edit table.
a2adf5c
to
97303e5
Compare
@himdel @martinpovolny It looks like this could be merged. If any issues occur, please just let me know. Thanks! |
Checked commit hstastna@97303e5 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 app/views/chargeback/_cb_rate_edit_table.html.haml
|
@hstastna please reopen PR to restart travis. @ZitaNemeckova is this PR fixing your BZ? |
@lpichler Yeah it is :) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1532368 @hstastna Can you please close and open this PR? Travis failures are not related to your changes and it should go green :) |
This fixes blocker bz https://bugzilla.redhat.com/show_bug.cgi?id=1532368 so adding label :) |
@ZitaNemeckova @hstastna please review changes that were made in 36163ea to make variable rate field non-editable. |
- @cur_group = detail[:group] if @cur_group.nil? | ||
- if @cur_group != detail[:group] | ||
- @cur_group = detail[:group] | ||
%tr | ||
%td{:colspan => "10", :style => "background-color: #f5f5f5;"} | ||
- detail_index = @edit[:new][:tiers].index { |x| x.detect { |tier_hash| tier_hash['chargeback_rate_detail_id'] == detail[:id] }.present? } | ||
- if params[:pressed] == "chargeback_rates_edit" |
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 doesn't sound like the best place for this kind of condition.
Also, this means detail_index
will be nil
for all the other cases...
So.. all the code like {:id => "rate_detail_row_#{detail_index}_0"}
has a bug now. (Well, unless nil
is really expected there.)
Please make sure detail_index
always has a reasonable value.
(And ideally, move the params[:pressed]
condition to controller code.)
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.
detail_index
will not be nil
because of https://github.com/ManageIQ/manageiq-ui-classic/pull/3129/files#diff-9e228e37bdb4a0dfb3c30cffd92d3981R21
....each_with_index do |detail, detail_index|
I have tested that, it always will be set, and properly. detail_index
is just changed if params[:pressed] == "chargeback_rates_edit"
Or am I missing something?
This change is made because in this haml... this haml is common for editing and displaying the rates. For just displaying, using detail_index
just as it is, works perfectly. When editing, we need it just like this: https://github.com/ManageIQ/manageiq-ui-classic/pull/3129/files#diff-9e228e37bdb4a0dfb3c30cffd92d3981L27
To move the condition to controller? I am not sure, how I would change detail_index
from controller if the rate is edited. Any idea how to make it properly? Thanks! :)
@h-kataria Yeah but only for |
@lpichler can you please review and let us know if this is good to go? Thx, Dan |
@h-kataria I think that 36163ea is ok. I don't see how this could affect this PR. The commit change is already in the code and I was fixing the issue against the actual code. |
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.
@dclarizio tested and it is working as expected 👍
@himdel
detail_index
is going from as an index from
.each_with_index do |detail, detail_index|
as @hstastna is saying but for editing we need to recalculated index when the rate is edited.
This doesn't sound like the best place for this kind of condition
yes, it doesn't but there is more similar array operations in the haml a maybe all these should live somewhere else, maybe in the helper, maybe it would be solved by some cleanup's in the controller.
I am considering this solution as most safe what we can do now and I am suggesting to solve these technical debts in follow up PR. There is also probabilty that this section would be replaced by something 'new' in future.
…per_ids Fix issues related to adding, editing Chargeback Rates (cherry picked from commit 5cd68c7) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1533924
Gaprindashvili backport details:
|
fixing ManageIQ/manageiq#16699
Fix issues related to adding new or editing existing chargeback rates in Cloud Intel -> Chargeback
-> Rates tab, caused by improper
detail_index
in the chargeback rate edit table.Issues:
https://user-images.githubusercontent.com/14937244/34208255-0446729a-e58e-11e7-8e4a-ecaadf5b419b.gif
https://user-images.githubusercontent.com/14937244/34208319-56445364-e58e-11e7-803b-d0c4673727ab.gif
After:
Details:
Simple condition was added to haml, because it is accessed not only if editing chargeback rate, but also if adding a new one. We don't need editing
detail_index
if we just add a new rate.Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1532368