Skip to content

Commit

Permalink
Merge pull request ManageIQ#13994 from eclarizio/cascading_auto_refre…
Browse files Browse the repository at this point in the history
…sh_critical_fix_euwe_backport

[EUWE] Make cascading auto-refresh behavior more consistent with how it was previously
  • Loading branch information
simaishi authored Feb 21, 2017
2 parents 99e55b2 + b89f5b5 commit 818f133
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/helpers/application_helper/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def build_auto_refreshable_field_indicies(workflow)
auto_refreshable_field_indicies
end

def auto_refresh_listening_options(options, trigger_override)
options.merge(:trigger => trigger_override)
end

private

def auto_refresh_options(field, auto_refresh_options_hash)
Expand Down
4 changes: 3 additions & 1 deletion app/views/shared/dialogs/_dialog_field_check_box.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
:javascript
dialogFieldRefresh.listenForAutoRefreshMessages(JSON.parse("#{j(auto_refresh_options.to_json)}"), function() {
dialogFieldRefresh.refreshCheckbox("#{field.name}", "#{field.id}", function() {
dialogFieldRefresh.triggerAutoRefresh(JSON.parse('#{j(auto_refresh_options.to_json)}'));
dialogFieldRefresh.triggerAutoRefresh(
JSON.parse('#{j(auto_refresh_listening_options(auto_refresh_options, true).to_json)}')
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
:javascript
dialogFieldRefresh.listenForAutoRefreshMessages(JSON.parse("#{j(auto_refresh_options.to_json)}"), function() {
dialogFieldRefresh.refreshDateTime("#{field.name}", "#{field.id}", function() {
dialogFieldRefresh.triggerAutoRefresh(JSON.parse('#{j(auto_refresh_options.to_json)}'));
dialogFieldRefresh.triggerAutoRefresh(
JSON.parse('#{j(auto_refresh_listening_options(auto_refresh_options, true).to_json)}')
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
dialogFieldRefresh.listenForAutoRefreshMessages(JSON.parse("#{j(auto_refresh_options.to_json)}"), function() {
var selectedValue = $('select[name="#{field.name}"]').val();
dialogFieldRefresh.refreshDropDownList("#{field.name}", "#{field.id}", selectedValue, function() {
dialogFieldRefresh.triggerAutoRefresh(JSON.parse('#{j(auto_refresh_options.to_json)}'));
dialogFieldRefresh.triggerAutoRefresh(
JSON.parse('#{j(auto_refresh_listening_options(auto_refresh_options, true).to_json)}')
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
checkedValue,
"#{url}",
JSON.parse('#{j(auto_refresh_options.to_json)}'), function() {
dialogFieldRefresh.triggerAutoRefresh(JSON.parse('#{j(auto_refresh_options.to_json)}'));
dialogFieldRefresh.triggerAutoRefresh(
JSON.parse('#{j(auto_refresh_listening_options(auto_refresh_options, true).to_json)}')
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
:javascript
dialogFieldRefresh.listenForAutoRefreshMessages(JSON.parse("#{j(auto_refresh_options.to_json)}"), function() {
dialogFieldRefresh.refreshTextAreaBox("#{field.name}", "#{field.id}", function() {
dialogFieldRefresh.triggerAutoRefresh(JSON.parse('#{j(auto_refresh_options.to_json)}'));
dialogFieldRefresh.triggerAutoRefresh(
JSON.parse('#{j(auto_refresh_listening_options(auto_refresh_options, true).to_json)}')
);
});
});

Expand Down
4 changes: 3 additions & 1 deletion app/views/shared/dialogs/_dialog_field_text_box.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
:javascript
dialogFieldRefresh.listenForAutoRefreshMessages(JSON.parse('#{j(auto_refresh_options.to_json)}'), function() {
dialogFieldRefresh.refreshTextBox("#{field.name}", "#{field.id}", function() {
dialogFieldRefresh.triggerAutoRefresh(JSON.parse('#{j(auto_refresh_options.to_json)}'));
dialogFieldRefresh.triggerAutoRefresh(
JSON.parse('#{j(auto_refresh_listening_options(auto_refresh_options, true).to_json)}')
);
});
});

Expand Down
8 changes: 8 additions & 0 deletions spec/helpers/application_helper/dialogs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,12 @@
])
end
end

describe "#auto_refresh_listening_options" do
let(:options) { {:trigger => false} }

it "overrides the trigger attribute" do
expect(helper.auto_refresh_listening_options(options, true)).to eq(:trigger => true)
end
end
end

0 comments on commit 818f133

Please sign in to comment.