ManageIQ/manageiq-ui-classic

View on GitHub
app/views/report/_column_lists.html.haml

Summary

Maintainability
Test Coverage
#column_lists
  %table
    %tr
      %td{:align => "left"}
        = _('Available Fields:')
      %td
    %tr
      %td{:align => "left", :valign => "top"}
        - af = @edit[:new][:model] ? cashed_reporting_available_fields - @edit[:new][:fields] : []
        = select_tag('available_fields[]',
          options_for_select(af),
          :multiple          => true,
          "data-width"       => "850px",
          "data-live-search" => "true",
          "data-live-search-focus" => "false",
          :style             => "overflow-x: scroll;",
          :id                => "available_fields",
          :title             => "<#{_('Choose one or more Fields')}>")
        :javascript
          miqInitSelectPicker('#available_fields', {size: false});
      %td
    %tr
      %td.text-center{:style => "padding-top: 15px;"}
        - cond_down = @edit[:new][:model].nil? || cashed_reporting_available_fields.empty?
        - cond_up = @edit[:new][:fields].length == 0
        - [['fa-angle-down', 'right', _("down"), cond_down],
           ['fa-angle-up',   'left',  _("up"),   cond_up]].each do |icon, button, text, condition|
          - t = _("Move selected fields %{where}") % {:where => text}
          - if condition
            %button.btn.btn-default.disabled{:title => t, :disabled => true}
              %i.fa.fa-lg{:class => icon}
          - else
            %button.btn.btn-default{:title           => t,
                                    :alt             => t,
                                    :remote          => true,
                                    "data-submit"    => 'column_lists',
                                    "data-method"    => :post,
                                    "data-click_url" => {:url => url_for_only_path(:action => 'form_field_changed',
                                                                         :button => button,
                                                                         :id     => @edit[:rpt_id] || "new")}.to_json}

              %i.fa.fa-lg{:class => icon}
      %td
    %tr
      %td{:align => "left"}
        = _('Selected Fields:')
      %td
    %tr
      %td{:align => "left", :valign => "top"}
        = select_tag('selected_fields[]',
          options_for_select(@edit[:new][:fields], @selected),
          :multiple => true,
          :style    => "width:850px;",
          :size     => 10,
          :id       => "selected_fields")
      %td.text-center{:width => "30"}
        .btn-group-vertical
          - [['fa-angle-double-up',   'top',    _("to top")],
             ['fa-angle-up',          'up',     _("up")],
             ['fa-angle-down',        'down',   _("down")],
             ['fa-angle-double-down', 'bottom', _("to bottom")]].each do |icon, button, text|
            - t = _("Move selected fields %{where}") % {:where => text}
            - if @edit[:new][:fields].length < 2
              %button.btn.btn-default.disabled{:title => t, :disabled => true}
                %i.fa.fa-lg{:class => icon}
            - else
              %button.btn.btn-default{:title           => t,
                                      :alt             => t,
                                      :remote          => true,
                                      "data-submit"    => 'column_lists',
                                      "data-method"    => :post,
                                      "data-click_url" => {:url => url_for_only_path(:action => 'form_field_changed',
                                                                           :button => button,
                                                                           :id     => @edit[:rpt_id] || "new")}.to_json}
                %i.fa.fa-lg{:class => icon}