aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/group_of_lines_controller.rb34
-rw-r--r--app/controllers/lines_controller.rb12
2 files changed, 26 insertions, 20 deletions
diff --git a/app/controllers/group_of_lines_controller.rb b/app/controllers/group_of_lines_controller.rb
index 78d3f64c0..f8b5301d3 100644
--- a/app/controllers/group_of_lines_controller.rb
+++ b/app/controllers/group_of_lines_controller.rb
@@ -1,4 +1,6 @@
-class GroupOfLinesController < ChouetteController
+class GroupOfLinesController < BreadcrumbController
+ include ApplicationHelper
+
defaults :resource_class => Chouette::GroupOfLine
respond_to :html
respond_to :xml
@@ -6,7 +8,7 @@ class GroupOfLinesController < ChouetteController
respond_to :kml, :only => :show
respond_to :js, :only => :index
- belongs_to :referential
+ belongs_to :line_referential
def show
@map = GroupOfLineMap.new(resource).with_helpers(self)
@@ -16,7 +18,7 @@ class GroupOfLinesController < ChouetteController
end
end
- def index
+ def index
index! do |format|
format.html {
if collection.out_of_bounds?
@@ -24,17 +26,16 @@ class GroupOfLinesController < ChouetteController
end
build_breadcrumb :index
}
- end
+ end
end
-
def name_filter
- respond_to do |format|
- format.json { render :json => filtered_group_of_lines_maps}
- end
+ respond_to do |format|
+ format.json { render :json => filtered_group_of_lines_maps}
+ end
end
-
+
protected
def filtered_group_of_lines_maps
@@ -42,29 +43,30 @@ class GroupOfLinesController < ChouetteController
{ :id => group_of_line.id, :name => group_of_line.name }
end
end
-
+
def filtered_group_of_lines
- referential.group_of_lines.select{ |t| t.name =~ /#{params[:q]}/i }
+ line_referential.group_of_lines.select{ |t| t.name =~ /#{params[:q]}/i }
end
- def collection
- @q = referential.group_of_lines.search(params[:q])
+ def collection
+ @q = line_referential.group_of_lines.search(params[:q])
@group_of_lines ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page])
end
def resource_url(group_of_line = nil)
- referential_group_of_line_path(referential, group_of_line || resource)
+ line_referential_group_of_line_path(line_referential, group_of_line || resource)
end
def collection_url
- referential_group_of_lines_path(referential)
+ line_referential_group_of_lines_path(line_referential)
end
+ alias_method :line_referential, :parent
private
def group_of_line_params
params.require(:group_of_line).permit( :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :lines, :registration_number, :line_tokens)
end
-
+
end
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index 50d8dcee3..8c14de06d 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -1,4 +1,6 @@
-class LinesController < ChouetteController
+class LinesController < BreadcrumbController
+ include ApplicationHelper
+
defaults :resource_class => Chouette::Line
respond_to :html
respond_to :xml
@@ -6,7 +8,7 @@ class LinesController < ChouetteController
respond_to :kml, :only => :show
respond_to :js, :only => :index
- belongs_to :referential
+ belongs_to :line_referential
def index
index! do |format|
@@ -57,7 +59,7 @@ class LinesController < ChouetteController
end
def filtered_lines
- referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e } }
+ line_referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e } }
end
def collection
@@ -76,10 +78,12 @@ class LinesController < ChouetteController
params[:q]["group_of_lines_id_blank"] = "1"
end
- @q = referential.lines.search(params[:q])
+ @q = line_referential.lines.search(params[:q])
@lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company])
end
+ alias_method :line_referential, :parent
+
private
def line_params