Skip to content

Commit

Permalink
remove title, set default params values
Browse files Browse the repository at this point in the history
  • Loading branch information
mszczytowski committed Jan 17, 2009
1 parent f3bffdb commit dcdf12b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions app/controllers/charts_controller.rb
Expand Up @@ -4,6 +4,8 @@ class ChartsController < ApplicationController

menu_item :charts

before_filter :set_params_default_values

before_filter :find_project, :authorize, :only => [:index]

Y_STEPS = 5
Expand All @@ -27,6 +29,7 @@ def index
@show_conditions = false
end
@help = get_help
@title = get_title

render :template => "charts/index"
end
Expand All @@ -47,12 +50,7 @@ def data
chart.add_element(converter.convert(index,name,values,x_labels))
index += 1
end

unless get_title.nil?
title = Title.new(get_title)
chart.set_title(title)
end


if show_y_axis
y = YAxis.new
y.set_range(0,y_max*1.2,y_max/Y_STEPS) if y_max
Expand Down Expand Up @@ -203,7 +201,6 @@ def prepare_range(range, column = "created_on")
end

diff = from.strftime(strftime_i).to_i + from.strftime('%Y').to_i
#sql = RedmineCharts::DateFormat.format_date(range[:in], column, diff)
sql = ActiveRecord::Base.format_date(range[:in], column, diff)

[from, to, x_labels, range[:steps], sql, dates]
Expand Down Expand Up @@ -259,13 +256,18 @@ def find_project
rescue ActiveRecord::RecordNotFound
render_404
end


def set_params_default_values
params[:range_steps] = 10 if params[:range_steps].blank?
params[:range_offset] = 1 if params[:range_offset].blank?
params[:range_in] = :days if params[:range_in].blank?
end

def prepare_params
range = {:steps => 10, :offset => 1, :in => :days}
range[:steps] = Integer(params[:range_steps]) unless params[:range_steps].blank?
range[:steps] = 0 if params[:range_steps] and params[:range_steps].blank?
range[:offset] = Integer(params[:range_offset]) unless
range[:in] = params[:range_in].to_sym unless params[:range_in].blank?
range = {}
range[:steps] = Integer(params[:range_steps])
range[:offset] = Integer(params[:range_offset])
range[:in] = params[:range_in].to_sym

conditions = {:project_id => Project.find(params[:project_id]).id}
get_conditions_options.each do |k|
Expand Down

0 comments on commit dcdf12b

Please sign in to comment.