diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cdeb31f96436..03350903df16 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -39,6 +39,7 @@ class ApplicationController < ActionController::Base helper JsHelper helper QuadiconHelper helper ImageEncodeHelper + helper ViewFormattingHelper helper CloudResourceQuotaHelper diff --git a/app/controllers/miq_ae_class_controller.rb b/app/controllers/miq_ae_class_controller.rb index 81394c138e0b..737f4723b68a 100644 --- a/app/controllers/miq_ae_class_controller.rb +++ b/app/controllers/miq_ae_class_controller.rb @@ -1733,16 +1733,14 @@ def playbook_inputs(method) end def set_playbook_data - data = { - :repository_id => params['repository_id'], - :playbook_id => params['playbook_id'], - :credential_id => params['credential_id'], - :become_enabled => params['become_enabled'], - :verbosity => params['verbosity'], - } - data[:network_credential_id] = params['network_credential_id'] if params['network_credential_id'] - data[:cloud_credential_id] = params['cloud_credential_id'] if params['cloud_credential_id'] - data + params_list = %i(repository_id + playbook_id + credential_id + become_enabled + verbosity + network_credential_id + cloud_credential_id) + copy_params_if_set({}, params, params_list) end def angular_form_specific_data diff --git a/app/helpers/view_formatting_helper.rb b/app/helpers/view_formatting_helper.rb new file mode 100644 index 000000000000..185a66b911cb --- /dev/null +++ b/app/helpers/view_formatting_helper.rb @@ -0,0 +1,13 @@ +module ViewFormattingHelper + def format_form_group(label, value = nil) + output = content_tag(:label, :class => "col-md-2 control-label") do + _(label) + end + output << content_tag(:div, :class => "col-md-8") do + content_tag(:p, :class => "form-control-static") do + value + end + end + output + end +end diff --git a/app/views/miq_ae_class/_method_inputs.html.haml b/app/views/miq_ae_class/_method_inputs.html.haml index 8fd3bfd62a86..b1d797c46504 100644 --- a/app/views/miq_ae_class/_method_inputs.html.haml +++ b/app/views/miq_ae_class/_method_inputs.html.haml @@ -10,35 +10,15 @@ = _('Main Info') .form-horizontal.static .form-group - %label.col-md-2.control-label - = _('Type') - .col-md-8 - %p.form-control-static - = @ae_method.location + = format_form_group(_('Type'), @ae_method.location) .form-group - %label.col-md-2.control-label - = Dictionary.gettext('fqname', :type => :column, :notfound => :titleize) - .col-md-8 - %p.form-control-static - = h(@sb[:namespace_path]) + = format_form_group(Dictionary.gettext('fqname', :type => :column, :notfound => :titleize), @sb[:namespace_path]) .form-group - %label.col-md-2.control-label - = _('Name') - .col-md-8 - %p.form-control-static - = @ae_method.name + = format_form_group(_('Name'), @ae_method.name) .form-group - %label.col-md-2.control-label - = _('Display Name') - .col-md-8 - %p.form-control-static - = @ae_method.display_name + = format_form_group(_('Display Name'), @ae_method.display_name) .form-group - %label.col-md-2.control-label - = _('Created On') - .col-md-8 - %p.form-control-static - = h(format_timezone(@ae_method.created_on, Time.zone, "gtl")) + = format_form_group(_('Created On'), format_timezone(@ae_method.created_on, Time.zone, "gtl")) = render :partial => "domain_overrides", :locals => {:node_prefix => "aem", :model => "Method"} %h3= (@ae_method.location == 'builtin') ? _('Builtin name') : _('Data') - if @ae_method.location == "inline" @@ -59,35 +39,17 @@ - elsif @ae_method.location == 'playbook' .form-horizontal.static .form-group - %label.col-md-2.control-label - = _('Repository') - .col-md-8 - = h(@playbook_details[:repository]) + = format_form_group(_('Repository'), @playbook_details[:repository]) .form-group - %label.col-md-2.control-label - = _('Playbook') - .col-md-8 - = h(@playbook_details[:playbook]) + = format_form_group(_('Playbook'), @playbook_details[:playbook]) .form-group - %label.col-md-2.control-label - = _('Machine Credential') - .col-md-8 - = h(@playbook_details[:machine_credential]) + = format_form_group(_('Machine Credential'), @playbook_details[:machine_credential]) .form-group - %label.col-md-2.control-label - = _('Cloud Credential') - .col-md-8 - = h(@playbook_details[:cloud_credential]) + = format_form_group(_('Cloud Credential'), @playbook_details[:cloud_credential]) .form-group - %label.col-md-2.control-label - = _('Escalate Privilege') - .col-md-8 - = h(@playbook_details[:become_enabled]) + = format_form_group(_('Escalate Privilege'), @playbook_details[:become_enabled]) .form-group - %label.col-md-2.control-label - = _('Verbosity') - .col-md-8 - = h(verbosity_display(@playbook_details[:verbosity])) + = format_form_group(_('Verbosity'), verbosity_display(@playbook_details[:verbosity])) - else = @ae_method.data -# show inputs parameters grid if there are any inputs diff --git a/spec/views/miq_ae_class/_method_inputs.html.haml_spec.rb b/spec/views/miq_ae_class/_method_inputs.html.haml_spec.rb index b3c3edf25a31..486a2506f36e 100644 --- a/spec/views/miq_ae_class/_method_inputs.html.haml_spec.rb +++ b/spec/views/miq_ae_class/_method_inputs.html.haml_spec.rb @@ -1,5 +1,6 @@ describe "miq_ae_class/_method_inputs.html.haml" do include Spec::Support::AutomationHelper + helper(ViewFormattingHelper) context 'display method inputs' do before do