app/controllers/report_controller/reports.rb
# Check for tab switch error conditions
Check for tab switch error conditions
Check for tab switch error conditions
def check_tabs
    @sb[:miq_tab] = params[:tab]
    active_tab = "edit_1"
    case @sb[:miq_tab].split("_")[1]
    when "8"
      if @edit[:new][:fields].length == 0
        add_flash(_("Consolidation tab is not available until at least 1 field has been selected"), :error)
      end
    when "2"
      if @edit[:new][:fields].length == 0
        add_flash(_("Formatting tab is not available until at least 1 field has been selected"), :error)
      end
    when "3"
      if @edit[:new][:model] == TREND_MODEL
        unless @edit[:new][:perf_trend_col]
          add_flash(_("Filter tab is not available until Trending for field has been selected"), :error)
        end
        unless @edit[:new][:perf_limit_col] || @edit[:new][:perf_limit_val]
          add_flash(_("Filter tab is not available until Trending Target Limit has been configured"), :error)
        end
        if @edit[:new][:perf_limit_val] && !is_numeric?(@edit[:new][:perf_limit_val])
          add_flash(_("%s must be numeric") % "Trend Target Limit", :error)
        end
      else
        if @edit[:new][:fields].length == 0
          add_flash(_("Filter tab is not available until at least 1 field has been selected"), :error)
        end
      end
    when "4"
      if @edit[:new][:fields].length == 0
        add_flash(_("Summary tab is not available until at least 1 field has been selected"), :error)
      end
    when "5"
      if @edit[:new][:fields].length == 0
        add_flash(_("Charts tab is not available until at least 1 field has been selected"), :error)
      elsif @edit[:new][:sortby1].blank? || @edit[:new][:sortby1] == NOTHING_STRING
        add_flash(_("Charts tab is not available unless a sort field has been selected"), :error)
        active_tab = "edit_4"
      end
    when "6"
      if @edit[:new][:fields].length == 0
        add_flash(_("Timeline tab is not available until at least 1 field has been selected"), :error)
      else
        found = false
        @edit[:new][:fields].each do |field|
          if MiqReport.get_col_type(field[1]) == :datetime
            found = true
            break
          end
        end
        unless found
          add_flash(_("Timeline tab is not available unless at least 1 time field has been selected"), :error)
        end
      end
    when "7"
      if @edit[:new][:model] == TREND_MODEL
        unless @edit[:new][:perf_trend_col]
          add_flash(_("Preview tab is not available until Trending for field has been selected"), :error)
        end
        unless @edit[:new][:perf_limit_col] || @edit[:new][:perf_limit_val]
          add_flash(_("Preview tab is not available until Trend Target Limit has been configured"), :error)
        end
        if @edit[:new][:perf_limit_val] && !is_numeric?(@edit[:new][:perf_limit_val])
          add_flash(_("Trend Target Limit: Value must be numeric"), :error)
        end
      else
        if @edit[:new][:fields].length == 0
          add_flash(_("Preview tab is not available until at least 1 field has been selected"), :error)
        elsif @edit[:new][:model] == "Chargeback" && !valid_chargeback_fields
          add_flash(_("Preview tab is not available until Chargeback Filters has been configured"), :error)
          active_tab = "edit_3"
        end
      end
    when "9"
      if @edit[:new][:fields].length == 0
        add_flash(_("Styling tab is not available until at least 1 field has been selected"), :error)
      end
    end
    @sb[:miq_tab] = active_tab if flash_errors?
  end
def check_tabs @sb [ :miq_tab ] = params [ :tab ] active_tab = "edit_1" case @sb [ :miq_tab ] . split ( "_" ) [ 1 ] when "8" if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Consolidation tab is not available until at least 1 field has been selected" ) , :error ) end when "2" if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Formatting tab is not available until at least 1 field has been selected" ) , :error ) end when "3" if @edit [ :new ] [ :model ] == TREND_MODEL unless @edit [ :new ] [ :perf_trend_col ] add_flash ( _ ( "Filter tab is not available until Trending for field has been selected" ) , :error ) end unless @edit [ :new ] [ :perf_limit_col ] || @edit [ :new ] [ :perf_limit_val ] add_flash ( _ ( "Filter tab is not available until Trending Target Limit has been configured" ) , :error ) end if @edit [ :new ] [ :perf_limit_val ] && ! is_numeric? ( @edit [ :new ] [ :perf_limit_val ] ) add_flash ( _ ( "%s must be numeric" ) % "Trend Target Limit" , :error ) end else if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Filter tab is not available until at least 1 field has been selected" ) , :error ) end end when "4" if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Summary tab is not available until at least 1 field has been selected" ) , :error ) end when "5" if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Charts tab is not available until at least 1 field has been selected" ) , :error ) elsif @edit [ :new ] [ :sortby1 ] . blank? || @edit [ :new ] [ :sortby1 ] == NOTHING_STRING add_flash ( _ ( "Charts tab is not available unless a sort field has been selected" ) , :error ) active_tab = "edit_4" end when "6" if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Timeline tab is not available until at least 1 field has been selected" ) , :error ) else found = false @edit [ :new ] [ :fields ] . each do | field | if MiqReport . get_col_type ( field [ 1 ] ) == :datetime found = true break end end unless found add_flash ( _ ( "Timeline tab is not available unless at least 1 time field has been selected" ) , :error ) end end when "7" if @edit [ :new ] [ :model ] == TREND_MODEL unless @edit [ :new ] [ :perf_trend_col ] add_flash ( _ ( "Preview tab is not available until Trending for field has been selected" ) , :error ) end unless @edit [ :new ] [ :perf_limit_col ] || @edit [ :new ] [ :perf_limit_val ] add_flash ( _ ( "Preview tab is not available until Trend Target Limit has been configured" ) , :error ) end if @edit [ :new ] [ :perf_limit_val ] && ! is_numeric? ( @edit [ :new ] [ :perf_limit_val ] ) add_flash ( _ ( "Trend Target Limit: Value must be numeric" ) , :error ) end else if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Preview tab is not available until at least 1 field has been selected" ) , :error ) elsif @edit [ :new ] [ :model ] == "Chargeback" && ! valid_chargeback_fields add_flash ( _ ( "Preview tab is not available until Chargeback Filters has been configured" ) , :error ) active_tab = "edit_3" end end when "9" if @edit [ :new ] [ :fields ] . length == 0 add_flash ( _ ( "Styling tab is not available until at least 1 field has been selected" ) , :error ) end end @sb [ :miq_tab ] = active_tab if flash_errors? end
Check for tab switch error conditions
Check for tab switch error conditions