app/controllers/report_controller/reports.rb
# Check for valid report configuration in @edit[:new]
Check for valid report configuration in @edit[:new]
Check for valid report configuration in @edit [ : new ]
def valid_report?(rpt)
    active_tab = "edit_1"
    if @edit[:new][:model] == TREND_MODEL
      unless @edit[:new][:perf_trend_col]
        add_flash(_("Trending for is required"), :error)
      end
      unless @edit[:new][:perf_limit_col] || @edit[:new][:perf_limit_val]
        add_flash(_("Trend Target Limit must be configured"), :error)
      end
      if @edit[:new][:perf_limit_val] && !is_numeric?(@edit[:new][:perf_limit_val])
        add_flash(_("Trend Target Limit must be numeric"), :error)
      end
    else
      if @edit[:new][:fields].length == 0
        add_flash(_("At least one Field must be selected"), :error)
      end
    end
    if @edit[:new][:model] == "Chargeback"
      unless @edit[:new][:cb_show_typ]
        add_flash(_("Show Costs by must be selected"), :error)
        active_tab = "edit_3"
      else
        if @edit[:new][:cb_show_typ] == "owner"
          unless @edit[:new][:cb_owner_id]
            add_flash(_("An Owner must be selected"), :error)
            active_tab = "edit_3"
          end
        elsif @edit[:new][:cb_show_typ] == "tenant" && !@edit[:new][:cb_tenant_id]
          add_flash(_("A Tenant Category must be selected"), :error)
          active_tab = "edit_3"
        elsif @edit[:new][:cb_show_typ] == "tag"
          unless @edit[:new][:cb_tag_cat]
            add_flash(_("A Tag Category must be selected"), :error)
            active_tab = "edit_3"
          else
            unless @edit[:new][:cb_tag_value]
              add_flash(_("A Tag must be selected"), :error)
              active_tab = "edit_3"
            end
          end
        end
      end
    end
    unless rpt.col_options.blank? || @edit[:new][:field_order].nil?
      @edit[:new][:field_order].each do |f| 
        col = f.last.split(".").last.split("-").last
        if val = rpt.col_options[col] 
          next unless val.key?(:style)  
          val[:style].each_with_index do |s, s_idx| 
            if s[:value]
              if e = MiqExpression.atom_error(rpt.col_to_expression_col(col.split("__").first), 
                                              s[:operator],
                                              s[:value])
                msg = case s_idx + 1
                      when 1
                        add_flash(_("Styling for '%{item}', first value is in error: %{message}") %
                                    {:item => f.first, :message => e.message}, :error)
                      when 2
                        add_flash(_("Styling for '%{item}', second value is in error: %{message}") %
                                    {:item => f.first, :message => e.message}, :error)
                      when 3
                        add_flash(_("Styling for '%{item}', third value is in error: %{message}") %
                                    {:item => f.first, :message => e.message}, :error)
                      end
                active_tab = "edit_9"
              end
            end
          end
        end
      end
    end
    unless rpt.valid? 
      rpt.errors.each do |field, msg|
        add_flash("#{field.to_s.capitalize} #{msg}", :error)
      end
    end
    @sb[:miq_tab] = active_tab if flash_errors?
    @flash_array.nil?
  end
def valid_report? ( rpt ) active_tab = "edit_1" if @edit [ :new ] [ :model ] == TREND_MODEL unless @edit [ :new ] [ :perf_trend_col ] add_flash ( _ ( "Trending for is required" ) , :error ) end unless @edit [ :new ] [ :perf_limit_col ] || @edit [ :new ] [ :perf_limit_val ] add_flash ( _ ( "Trend Target Limit must be configured" ) , :error ) end if @edit [ :new ] [ :perf_limit_val ] && ! is_numeric? ( @edit [ :new ] [ :perf_limit_val ] ) add_flash ( _ ( "Trend Target Limit must be numeric" ) , :error ) end else if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "At least one Field must be selected" ) , :error ) end end if @edit [ :new ] [ :model ] == "Chargeback" unless @edit [ :new ] [ :cb_show_typ ] add_flash ( _ ( "Show Costs by must be selected" ) , :error ) active_tab = "edit_3" else if @edit [ :new ] [ :cb_show_typ ] == "owner" unless @edit [ :new ] [ :cb_owner_id ] add_flash ( _ ( "An Owner must be selected" ) , :error ) active_tab = "edit_3" end elsif @edit [ :new ] [ :cb_show_typ ] == "tenant" && ! @edit [ :new ] [ :cb_tenant_id ] add_flash ( _ ( "A Tenant Category must be selected" ) , :error ) active_tab = "edit_3" elsif @edit [ :new ] [ :cb_show_typ ] == "tag" unless @edit [ :new ] [ :cb_tag_cat ] add_flash ( _ ( "A Tag Category must be selected" ) , :error ) active_tab = "edit_3" else unless @edit [ :new ] [ :cb_tag_value ] add_flash ( _ ( "A Tag must be selected" ) , :error ) active_tab = "edit_3" end end end end end unless rpt . col_options . blank? || @edit [ :new ] [ :field_order ] . nil? @edit [ :new ] [ :field_order ] . each do | f | col = f . last . split ( "." ) . last . split ( "-" ) . last if val = rpt . col_options [ col ] next unless val . key? ( :style ) val [ :style ] . each_with_index do | s , s_idx | if s [ :value ] if e = MiqExpression . atom_error ( rpt . col_to_expression_col ( col . split ( "__" ) . first ) , s [ :operator ] , s [ :value ] ) msg = case s_idx + 1 when 1 add_flash ( _ ( "Styling for '%{item}', first value is in error: %{message}" ) % { :item => f . first , :message => e . message } , :error ) when 2 add_flash ( _ ( "Styling for '%{item}', second value is in error: %{message}" ) % { :item => f . first , :message => e . message } , :error ) when 3 add_flash ( _ ( "Styling for '%{item}', third value is in error: %{message}" ) % { :item => f . first , :message => e . message } , :error ) end active_tab = "edit_9" end end end end end end unless rpt . valid? rpt . errors . each do | field , msg | add_flash ( "#{field.to_s.capitalize} #{msg}" , :error ) end end @sb [ :miq_tab ] = active_tab if flash_errors? @flash_array . nil? end
Check for valid report configuration in @edit[:new]
Check for valid report configuration in @edit [ : new ]
# Validate column styles # Go thru all of the cols in order # Skip if no options for this col # Skip if no style options # Go through all of the configured ifs # See if the value is in error # Check the model for errors
rpt
<not_specific>