diff --git a/app/assets/javascripts/host_edit.js b/app/assets/javascripts/host_edit.js index fb1ba06151a..eedb77cf0dd 100644 --- a/app/assets/javascripts/host_edit.js +++ b/app/assets/javascripts/host_edit.js @@ -6,6 +6,20 @@ $(document).on('ContentLoad', function() { $(document).on('AddedClass', function(event, link) { load_puppet_class_parameters(link); }); +$(document) + .on('change', '.hostgroup-select', function(evt) { + hostgroup_changed(evt.target); + }).on('change', '.host-form-compute-resource-handle', function(evt) { + computeResourceSelected(evt.target); + }).on('change', '.host-taxonomy-select', function(evt) { + update_form(evt.target); + }).on('change', '.host-architecture-select', function(evt) { + architecture_selected(evt.target); + }).on('change', '.host-architecture-os-select', function(evt) { + os_selected(evt.target); + }).on('change', '.host-os-media-select', function(evt) { + medium_selected(evt.target); + }); function update_nics(success_callback) { var data = serializeForm().replace('method=patch', 'method=post'); @@ -323,14 +337,6 @@ function set_inherited_value(hostgroup_elem) { }); } -function organization_changed(element) { - update_form(element); -} - -function location_changed(element) { - update_form(element); -} - function update_form(element, options) { options = options || {}; var url = $(element).data('url'); diff --git a/app/helpers/hosts_helper.rb b/app/helpers/hosts_helper.rb index 1274423c68a..e3a76f3364c 100644 --- a/app/helpers/hosts_helper.rb +++ b/app/helpers/hosts_helper.rb @@ -56,7 +56,7 @@ def host_taxonomy_select(f, taxonomy) select_opts = { :include_blank => !@host.managed? || @host.send(taxonomy_id).nil?, :selected => selected_taxonomy } html_opts = { :disabled => !@host.new_record?, - :onchange => "#{taxonomy.to_s.downcase}_changed(this);", + :class => 'host-taxonomy-select', :label => label, :'data-host-id' => @host.id, :'data-url' => process_taxonomy_hosts_path, diff --git a/app/views/common/os_selection/_architecture.html.erb b/app/views/common/os_selection/_architecture.html.erb index d9a53f103b6..807dcdf699d 100644 --- a/app/views/common/os_selection/_architecture.html.erb +++ b/app/views/common/os_selection/_architecture.html.erb @@ -3,7 +3,8 @@ {:selected => item.operatingsystem_id, :include_blank => blank_or_inherit_f(f, :operatingsystem) }, { :label => _("Operating system"), :help_inline => :indicator, - :onchange => 'os_selected(this);', :'data-url' => method_path('os_selected'), :'data-type' => controller_name.singularize, + :class => 'host-architecture-os-select', + :data => { :url => method_path('os_selected'), :type => controller_name.singularize }, :required => !item.is_a?(Hostgroup), :placeholder => arch_oss.empty? ? _("No options available for selected Architecture") : nil } %> diff --git a/app/views/common/os_selection/_initial.html.erb b/app/views/common/os_selection/_initial.html.erb index 2cfa4a74af6..f7763be66af 100644 --- a/app/views/common/os_selection/_initial.html.erb +++ b/app/views/common/os_selection/_initial.html.erb @@ -1,6 +1,6 @@ <%= fields_for item do |f| %> <%= select_f f, :architecture_id, accessible_resource(f.object, :architecture), :id, :to_label, {:include_blank => blank_or_inherit_f(f, :architecture)}, - {:label => _("Architecture"), :onchange => 'architecture_selected(this);', :'data-url' => method_path('architecture_selected'), :'data-type' => controller_name.singularize} %> + {:label => _("Architecture"), :class => 'host-architecture-select', :data => { :url => method_path('architecture_selected'), :type => controller_name.singularize }} %> diff --git a/app/views/common/os_selection/_operatingsystem.html.erb b/app/views/common/os_selection/_operatingsystem.html.erb index 74a39da322a..22c4bd8845e 100644 --- a/app/views/common/os_selection/_operatingsystem.html.erb +++ b/app/views/common/os_selection/_operatingsystem.html.erb @@ -1,8 +1,8 @@ <%= fields_for item do |f| %> <%= select_f f, :medium_id, os_media, :id, :to_label, {:include_blank => blank_or_inherit_f(f, :medium), :selected => item.medium_id}, - {:label => _("Media"), :help_inline => :indicator, :onchange => 'medium_selected(this);', - :'data-url' => method_path('medium_selected'), :'data-type' => controller_name.singularize, + {:label => _("Media"), :help_inline => :indicator, :class => 'host-os-media-select', + :data => { :url => method_path('medium_selected'), :type => controller_name.singularize }, :required => !item.is_a?(Hostgroup), :placeholder => os_media.empty? ? _("No options available for selected Operating System") : nil } %> <%= select_f f, :ptable_id, os_ptable, :id, :to_label, diff --git a/app/views/hostgroups/_form.html.erb b/app/views/hostgroups/_form.html.erb index c37a8df2919..915067da3f4 100644 --- a/app/views/hostgroups/_form.html.erb +++ b/app/views/hostgroups/_form.html.erb @@ -23,7 +23,8 @@
<%= select_f(f, :parent_id, parent_hostgroups, :id, :to_label, {:include_blank => true}, {:label => _('Parent'), - :onchange => 'hostgroup_changed(this);', :'data-url'=> process_hostgroup_hostgroups_path, + :class => 'hostgroup-select', + :data => { :url => process_hostgroup_hostgroups_path }, :help_inline => :indicator }) if show_parent?(@hostgroup) %> <%= text_f f, :name %> <%= textarea_f f, :description, :rows => :auto %> diff --git a/app/views/hosts/_form.html.erb b/app/views/hosts/_form.html.erb index 4f2aa37de00..4f61b7180fd 100644 --- a/app/views/hosts/_form.html.erb +++ b/app/views/hosts/_form.html.erb @@ -43,7 +43,7 @@ <%= select_f f, :hostgroup_id, accessible_resource(@host, :hostgroup, :title), :id, :to_label, { :include_blank => true}, - { :onchange => 'hostgroup_changed(this);', + { :class => 'hostgroup-select', :data => { :'host-id' => @host.id, :'url' => (@host.new_record? || @host.type_changed?) ? process_hostgroup_hosts_path : hostgroup_or_environment_selected_hosts_path, @@ -56,8 +56,8 @@ :disable_button => _(HostsAndHostgroupsHelper::INHERIT_TEXT), :disable_button_enabled => inherited_by_default?(:compute_resource_id, @host), :user_set => user_set?(:compute_resource_id) }, - { :label => _('Deploy On'), :disabled => (!@host.new_record? || @host.uuid.present?), :'data-url' => compute_resource_selected_hosts_path, - :onchange => 'computeResourceSelected(this);', + { :class => 'host-form-compute-resource-handle', + :label => _('Deploy On'), :disabled => (!@host.new_record? || @host.uuid.present?), :'data-url' => compute_resource_selected_hosts_path, :help_inline => :indicator } if SETTINGS[:unattended] && @host.new_record? || @host.compute_resource_id %> <% if @host.new_record? && visible_compute_profiles(@host).any? %> @@ -70,8 +70,8 @@ :disable_button_enabled => inherited_by_default?(:compute_profile_id, @host), :user_set => user_set?(:compute_profile_id) }, - { :label => _("Compute profile"), :'data-url' => compute_resource_selected_hosts_path, - :onchange => 'computeResourceSelected(this);', + { :class => 'host-form-compute-resource-handle', + :label => _("Compute profile"), :'data-url' => compute_resource_selected_hosts_path, :help_inline => :indicator } if SETTINGS[:unattended] %>
<% end %>