Skip to content
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

Jquery enable disable checked calls conversion #1353

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vmdb/app/assets/javascripts/cfme_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ function toggleConvertButtonToLink(button, url, toggle) {
// parms: button_div=<id of div with buttons to update>, override=<forced state>
function miqUpdateAllCheckboxes(button_div,override) {
miqSparkle(true);
if ($('masterToggle')) {
var state = $('masterToggle').checked;
if ($j('#masterToggle').length > 0) {
var state = $j('#masterToggle').prop('checked');
if ( override != null ) state = override;
if (typeof gtl_list_grid == "undefined" && ($$('input[id=listcheckbox]').length>0)) { // No dhtmlx grid on the screen
cbs = $$('input[id=listcheckbox]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ def retire_date_changed
if session[:retire_date].blank?
session[:retire_warn] = ""
page << javascript_hide("remove_button")
page << "$('retirement_warn').disable();"
page << javascript_disable_field('retirement_warn')
page << "$('retirement_warn').value = '';"
else
page << javascript_show("remove_button")
page << "$('retirement_warn').enable();"
page << javascript_enable_field('retirement_warn')
end
page << "miqSparkle(false);"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def perf_chart_chooser
page << Charting.js_load_statement
page << 'miqSparkle(false);'
if request.parameters["controller"] == "storage" && @perf_options[:cat]
page << "$('perf_typ').disable();"
page << javascript_disable_field('perf_typ')
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions vmdb/app/helpers/js_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ def javascript_del_class(element, cls)
"$j('##{j_str(element)}').removeClass('#{j_str(cls)}');".html_safe
end

def javascript_disable_field(element)
"$j('##{j_str(element)}').prop('disabled', true);".html_safe
end

def javascript_enable_field(element)
"$j('##{j_str(element)}').prop('disabled', false);".html_safe
end

def javascript_show(element)
"$j('##{j_str(element)}').show();".html_safe
end
Expand Down
12 changes: 12 additions & 0 deletions vmdb/spec/helpers/js_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
end
end

context '#javascript_disable_field' do
it 'returns js to disable the provided element' do
javascript_disable_field('foo').should eq("$j('#foo').prop('disabled', true);")
end
end

context '#javascript_enable_field' do
it 'returns js to enable the provided element' do
javascript_enable_field('foo').should eq("$j('#foo').prop('disabled', false);")
end
end

context '#javascript_show' do
it 'returns js to show an element' do
javascript_show('foo').should eq("$j('#foo').show();")
Expand Down