Sha256: 56788767357110b9602e2362b1e131ff4ff16fcecb8ff833f8d4544415e4d4a1

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

require_dependency "customer_vault/application_controller"
require 'handles_sortable_columns'

module CustomerVault
  class PeopleController < ::CustomerVault::ApplicationController
    handles_sortable_columns

    def index
      redirect_to people_activity_path
    end

    def list
      authorize! :list, Person

      @filters      ||= ::CustomerVault::SmallData::FilterForPeople.new(cookies)
      @tags         ||= customer_vault_tag_list
      @individuals  ||= Individual.search(params[:q])
      @corporations ||= Corporation.search(params[:q])

      @individuals  = @filters.apply(@individuals)
      @corporations = @filters.apply(@corporations)

      @people ||= @individuals + @corporations

      @people = sortable_column_order do |column, direction|
        case column
        when 'name'
          (direction == :asc) ? @people.sort_by(&:name)
                              : @people.sort_by(&:name).reverse
        when 'zip'
          (direction == :asc) ? @people.sort_by{ |p| p.address.zip.to_s }
                              : @people.sort_by{ |p| p.address.zip.to_s }.reverse
        else
          @people.sort_by(&:name)
        end
      end

      @people = Kaminari.paginate_array(@people).page(params[:page]).per(25)
    end

    def activity
      authorize! :list, Person

      @comments ||= Dorsale::Comment
        .where("commentable_type LIKE ?", "CustomerVault%")
        .order("created_at DESC, id DESC")

      @comments = @comments.page(params[:page]).per(50)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
customer_vault-1.3.0 app/controllers/customer_vault/people_controller.rb
customer_vault-1.2.10 app/controllers/customer_vault/people_controller.rb
customer_vault-1.2.9 app/controllers/customer_vault/people_controller.rb
customer_vault-1.2.8 app/controllers/customer_vault/people_controller.rb