Skip to content

Commit

Permalink
Added helper method to use while display data in view.
Browse files Browse the repository at this point in the history
- Addressed more PR review comments
- Fixed broken spec test

https://www.pivotaltracker.com/story/show/149747321
  • Loading branch information
h-kataria committed Oct 2, 2017
1 parent cfd4788 commit f9c8bda
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 59 deletions.
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ApplicationController < ActionController::Base
helper JsHelper
helper QuadiconHelper
helper ImageEncodeHelper
helper ViewFormattingHelper

helper CloudResourceQuotaHelper

Expand Down
18 changes: 8 additions & 10 deletions app/controllers/miq_ae_class_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions app/helpers/view_formatting_helper.rb
Original file line number Diff line number Diff line change
@@ -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
60 changes: 11 additions & 49 deletions app/views/miq_ae_class/_method_inputs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/views/miq_ae_class/_method_inputs.html.haml_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f9c8bda

Please sign in to comment.