ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
Test Coverage
- url = url_for_only_path(:action => 'form_field_changed', :id => (@edit[:rpt_id] || 'new'))
#formatting_div
  %h3
    = _('PDF Output')
  .form-horizontal
    .form-group
      %label.control-label.col-md-2.report-col
        = _('Page Size')
      .col-md-8
        = select_tag('pdf_page_size',
          options_for_select(ViewHelper::PDF_PAGE_SIZES.map { |k, v| [_(v), v] }.sort, @edit[:new][:pdf_page_size]),
          :multiple             => false,
          :class                => "selectpicker")
        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent('pdf_page_size', '#{url}', {beforeSend: true});
  %hr
  %h3
    = _('Specify Column Headers and Formats')
  %table.table.table-striped.table-bordered
    %thead
      %tr
        %th
          = _('Column Name')
        %th
          = _('Header')
        %th
          = _('Format')
    %tbody
      - @edit[:new][:field_order].each do |f|
        %tr
          %td
            = h(f.first)
          %td
            %div{:id => "hdr_#{f.last}_div"}
              = text_field_tag("hdr_#{f.last}", @edit[:new][:headers][f.last],
                :maxlength         => 40,
                "data-miq_observe" => {:interval => '.5', :url => url}.to_json)
          %td
            - ci = MiqReport.get_col_info(f.last.split("__").first)
            - unless ci[:available_formats].blank?
              -# need to gsub the period out of the field name for pull down or observe doesn't work, replacing with "__"
              - opts = [["<#{_('None')}>", "_none_"], ["<#{_('Reset to Default')}>", nil]] + Array(ci[:available_formats].invert).sort_by(&:first).map{|format| [_(format[0]), format[1]]}
              = select_tag("fmt_#{f.last.gsub(".", "___")}",
                options_for_select(opts, @edit[:new][:col_formats][f.last] || ci[:default_format]),
                "data-miq_sparkle_on" => true,
                "data-miq_observe"    => {:url => url}.to_json)