Sha256: 72b352dcb57a5bd09355a4f169468cfa9d6031296f2a490974e7cb6b45fe3349

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

module ParamsParserHelper
  
  def parse_pagination_params
    @current_page = params[:page] || "1"
    @per_page = params[:per_page] || ConfigCenter::Defaults::ITEMS_PER_LIST.to_s

    if @per_page && @per_page.to_i > ConfigCenter::Defaults::MAX_ITEMS_PER_LIST
      @per_page = ConfigCenter::Defaults::ITEMS_PER_LIST.to_s
    end

    @offset = (@current_page.to_i - 1) * (@per_page.to_i)

  end

  def parse_filter_dates(instance_name, start_date_name="start_date", end_date_name="end_date")
    ## Parsing the date info if any
    unless params[instance_name][start_date_name].blank?
     d = params[instance_name][start_date_name] ? (Time.parse(params[instance_name][start_date_name])) : (Date.today - 1.day)
     @start_date = params[instance_name][:start_date] || (Date.today - 1.day)
     @start_time = Time.utc(d.year,d.month,d.day,00,00,00)
    end
    unless params[instance_name][end_date_name].blank?
     d = params[instance_name][end_date_name] ? Time.parse(params[instance_name][end_date_name]) : Date.today
     @end_date = params[instance_name][end_date_name] || Date.today
     @end_time = Time.utc(d.year,d.month,d.day,23,59,59)
    end
  end
  
end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
humdrum-rails-0.1.1 lib/rails/generators/humdrum/layout/templates/helpers/params_parser_helper.rb
humdrum-rails-0.0.9 lib/rails/generators/humdrum/layout/templates/helpers/params_parser_helper.rb
humdrum-rails-0.0.8 lib/rails/generators/humdrum/layout/templates/helpers/params_parser_helper.rb