Sha256: e1eebf7ef071a085e0f92581f30890a662f913f4799a8a93e99dea6a914ca74a

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

class Bhf::PagesController < Bhf::ApplicationController
  before_filter :set_page

  def show
    @edit_params = {}
    unless platform_options = @settings.content_for_page(@page)
      raise Exception.new("Page '#{@page}' could not be found")
    end

    if request.xhr?
      params.each do |key, value|
        return render_platform(key) if value.is_a?(Hash)
      end
    end

    @platforms = platform_options.each_with_object([]) do |opts, obj|
      platform = find_platform(opts.keys[0])
      
      next if platform.table_hide?
      paginate_platform_objects(platform)
      obj << platform
    end
  end

  private

    def set_page
      @page = params[:page]
    end

    def render_platform(platform_name)
      platform = find_platform(platform_name)

      paginate_platform_objects(platform)

      render layout: false, partial: 'platform', locals: {platform: platform}
    end

    def paginate_platform_objects(platform)
      p = (params[platform.name] || {})
      page = 1
      unless p[:page].blank?
        page = p[:page].to_i
      end
      
      per_page = platform.pagination.offset_per_page
      unless p[:per_page].blank?
        per_page = p[:per_page].to_i
      end

      page_params = { page: page, per_page: per_page }

      @edit_params[platform.name] = page_params

      platform.get_objects(p, page_params)
    end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bhf-0.10.12 app/controllers/bhf/pages_controller.rb
bhf-0.10.11 app/controllers/bhf/pages_controller.rb
bhf-0.10.10 app/controllers/bhf/pages_controller.rb
bhf-0.10.9 app/controllers/bhf/pages_controller.rb
bhf-0.9.9 app/controllers/bhf/pages_controller.rb
bhf-0.9.8 app/controllers/bhf/pages_controller.rb
bhf-0.9.7 app/controllers/bhf/pages_controller.rb
bhf-0.9.6 app/controllers/bhf/pages_controller.rb
bhf-0.9.5 app/controllers/bhf/pages_controller.rb
bhf-0.9.4 app/controllers/bhf/pages_controller.rb
bhf-0.9.3 app/controllers/bhf/pages_controller.rb
bhf-0.9.2 app/controllers/bhf/pages_controller.rb
bhf-0.9.1 app/controllers/bhf/pages_controller.rb
bhf-0.9.0 app/controllers/bhf/pages_controller.rb
bhf-0.8.7 app/controllers/bhf/pages_controller.rb
bhf-0.8.6 app/controllers/bhf/pages_controller.rb
bhf-0.8.5 app/controllers/bhf/pages_controller.rb
bhf-0.8.4 app/controllers/bhf/pages_controller.rb
bhf-0.8.3 app/controllers/bhf/pages_controller.rb
bhf-0.8.2 app/controllers/bhf/pages_controller.rb