ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
Test Coverage
- url = url_for_only_path(:action => action, :id => rec_id)
#form_role_visibility
  %hr
  %h3
    = _("Role Access")
  .form-horizontal
    .form-group
      %label.control-label.col-md-2
        = _("Show")
      .col-md-10
        = select_tag("visibility_typ",
                     options_for_select(@edit[:visibility_types], @edit[:new][:visibility_typ]),
                     :class => "selectpicker")
        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent("visibility_typ", "#{url}");
    - if @edit[:new][:visibility_typ] == "role"
      .form-group
        %label.control-label.col-md-2
          = _("User Roles")
        .col-md-10
          %table
            - @edit[:sorted_user_roles].each_with_index do |user_role, index|
              - checkbox = capture do
                - checked = (!@edit[:new][:roles].nil? && @edit[:new][:roles].include?(user_role.values.first))
                %td{:align => "left", :valign => "top", :nowrap => true}
                  = check_box_tag("roles_#{user_role.values.first}", "1", checked, "data-miq_observe_checkbox" => {:url => url}.to_json)
                  = h(user_role.keys.first)
              - if (index % 3) == 0
                - if index != 0
                  = "</tr>".html_safe
                = "<tr>".html_safe
                = checkbox
              - else
                = checkbox
    - elsif @edit[:new][:visibility_typ] == "group"
      .form-group
        %label.control-label.col-md-2
          = _("Groups")
        .col-md-10
          %table
            - @edit[:sorted_groups].each_with_index do |group, index|
              - checkbox = capture do
                - checked = (!@edit[:new][:groups].nil? && @edit[:new][:groups].include?(group.values.first))
                %td{:align => "left", :valign => "top", :nowrap => true}
                  = check_box_tag("groups_#{group.values.first}", "1", checked, "data-miq_observe_checkbox" => {:url => url}.to_json)
                  = h(group.keys.first)
              - if (index % 3) == 0
                - if index != 0
                  = "</tr>".html_safe
                = "<tr>".html_safe
                = checkbox
              - else
                = checkbox