blob: 8c6172a7c83d968bd642a3ae32af5edcde58b6b7 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
class AccessLinksController < ChouetteController
defaults :resource_class => Chouette::AccessLink
belongs_to :referential do
belongs_to :access_point, :parent_class => Chouette::AccessPoint, :optional => true, :polymorphic => true
belongs_to :stop_area, :parent_class => Chouette::StopArea, :optional => true, :polymorphic => true
end
respond_to :html, :xml, :json
respond_to :kml, :only => :show
def index
request.format.kml? ? @per_page = nil : @per_page = 12
index!
end
def show
@map = AccessLinkMap.new(resource).with_helpers(self)
show!
end
def new
@access_point = Chouette::AccessPoint.find(params[:access_point_id])
data=params[:access_link]
@stop_area = Chouette::StopArea.find(data[:stop_area_id])
@orientation = data[:link_orientation_type]
name=data[:name]
if name.nil? || name.empty?
if @orientation == "access_point_to_stop_area"
name = "#{@access_point.name} -> #{@stop_area.name}"
else
name = "#{@stop_area.name} -> #{@access_point.name}"
end
data[:name] = name
end
@access_link = Chouette::AccessLink.new(data)
new!
end
def create
@access_point = Chouette::AccessPoint.find(params[:access_point_id])
data=params[:access_link]
@stop_area = Chouette::StopArea.find(data[:stop_area_id])
@orientation = data[:link_orientation_type]
create!
end
def edit
@access_point = Chouette::AccessPoint.find(params[:access_point_id])
@access_link = Chouette::AccessLink.find(params[:id])
@stop_area = @access_link.stop_area
@orientation = @access_link.link_orientation_type
edit!
end
protected
alias_method :access_link, :resource
# def map
# @map = AccessLinkMap.new(access_link).with_helpers(self)
# end
def collection
@q = parent.access_links.search(params[:q])
@access_links ||=
begin
access_links = @q.result(:distinct => true).order(:name)
access_links = access_links.paginate(:page => params[:page]) if @per_page.present?
access_links
end
end
end
|