blob: 20f84e763fcecd8f3a2cdbd079467f2c07c1488f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  | 
class CompaniesController < ChouetteController
  defaults :resource_class => Chouette::Company
  respond_to :html
  respond_to :xml
  respond_to :json
  respond_to :js, :only => :index
  belongs_to :referential, :parent_class => Referential
  def index    
    index! do |format|
      format.html {
        if collection.out_of_bounds?
          redirect_to params.merge(:page => 1)
        end
      add_breadcrumb Referential.model_name.human(:count => 2), referentials_path()
      add_breadcrumb @referential.name, referential_path(@referential)
      }
    end       
  end
  
  def show
    show! do
      add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential)
    end
  end
  def new
    new! do
      add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential)
    end
  end
  
  def edit
    edit! do
      add_breadcrumb Referential.human_attribute_name("companies"), referential_companies_path(@referential)
      add_breadcrumb @company.name, referential_line_path(@referential, @company)
    end
  end
  protected
  def collection    
    @q = referential.companies.search(params[:q])
    @companies ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page])
  end
  def resource_url(company = nil)
    referential_company_path(referential, company || resource)
  end
  def collection_url
    referential_companies_path(referential)
  end
end
  |