ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/_policy_sim.html.haml

Summary

Maintainability
Test Coverage
- url = url_for_only_path(:action => 'policy_sim_add')
#main_div
  - unless @explorer
    %h1#explorer_title
      %span#explorer_title_text
        = safe_right_cell_text
  #flash_msg_div
    = render :partial => "layouts/flash_msg"

  %h3= _("Choose Policies")
  #tab_div
    %table.table.table-bordered.table-striped
      %thead
        %tr
          %th{:colspan => "2"}
            %strong= _("Select a Policy Profile to add:")
            = select_tag("profile_id",
                         options_for_select(@all_profs.invert.sort_by { |desc, _id| desc.downcase }, "select"),
                         "data-miq_observe" => {:url => url}.to_json,
                         "class"            => "selectpicker",
                         "data-width"       => "auto")
            :javascript
              miqInitSelectPicker();
              miqSelectPickerEvent("profile_id", "#{url}", {beforeSend: true, complete: true});
        %tr
          %th.table-view-pf-select
          %th= _("Policy Profiles in Effect")
      %tbody
        - if session[:policies].length == 0
          %tr
            %td
            %td
              = _("No policies have been chosen yet")
        - else
          - session[:policies].invert.sort.each do |desc, id|
            %tr{:id => "#{desc}_tr"}
              %td
                %button.btn.btn-default{:onclick  => "#{remote_function(:loading  => "miqSparkle(true);",
                                        :complete => "miqSparkle(false);",
                                        :url      => {:action  => 'policy_sim_remove', :del_pol => id})}",
                                        :title    => _("Click to remove this policy")}
                  %i.pficon.pficon-delete
              %td
                = h(desc)
  %hr
  %h3= n_("Policy Simulation for %{amount} Item", "Policy Simulation for %{amount} Items", @tagitems.length) % {:amount => @tagitems.length}
  - if @tagitems
    - @embedded = true
    - @policy_sim = true
    - session[:edit] ||= {} 
    - session[:edit][:policy_sim] = @policy_sim
    = render :partial => "layouts/gtl",
             :locals  => {:view => @pol_view}

- if params[:action] == 'policy_sim' && !@explorer
  %table{:width => "100%"}
    %tr
      %td{:align => 'right'}
        #buttons_on
          = link_to(_('Cancel'),
                    {:action => 'policy_sim_cancel'},
                     :class  => 'btn btn-default',
                     :alt    => t = _('Cancel Changes'),
                     :title  => t,
                     :method => :post)