aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/referential_lines_controller.rb9
-rw-r--r--app/controllers/routes_controller.rb3
-rw-r--r--app/decorators/route_decorator.rb5
-rw-r--r--app/views/referential_lines/show.html.slim52
4 files changed, 52 insertions, 17 deletions
diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb
index 5d36e7da7..4b4a822b4 100644
--- a/app/controllers/referential_lines_controller.rb
+++ b/app/controllers/referential_lines_controller.rb
@@ -39,6 +39,15 @@ class ReferentialLinesController < ChouetteController
@routes = @routes.paginate(page: params[:page], per_page: 10)
+ @routes = ModelDecorator.decorate(
+ @routes,
+ with: RouteDecorator,
+ context: {
+ referential: referential,
+ line: @line
+ }
+ )
+
show! do
build_breadcrumb :show
end
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 786bd57cc..4781d0d16 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -44,8 +44,7 @@ class RoutesController < ChouetteController
show! do
@route = @route.decorate(context: {
referential: @referential,
- line: @line,
- route_sp: @route_sp
+ line: @line
})
build_breadcrumb :show
diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb
index 99b174dff..484c3db04 100644
--- a/app/decorators/route_decorator.rb
+++ b/app/decorators/route_decorator.rb
@@ -6,13 +6,12 @@ class RouteDecorator < Draper::Decorator
# Requires:
# context: {
# referential: ,
- # line: ,
- # route_sp
+ # line:
# }
def action_links
links = []
- if context[:route_sp].any?
+ if object.stop_points.any?
links << Link.new(
content: h.t('journey_patterns.index.title'),
href: [
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 0bb6d9032..327906c9c 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -51,18 +51,46 @@
- if @routes.any?
.row
.col-lg-12
- = table_builder @routes,
- { 'ID' => Proc.new { |n| n.objectid.local_id },
- :name => 'name',
- :published_name => 'published_name',
- :wayback => 'wayback_text',
- 'Arrêt de départ' => Proc.new{|r| r.try(:stop_points).first.try(:stop_area).try(:name)},
- "Arrêt d'arrivée" => Proc.new{|r| r.try(:stop_points).last.try(:stop_area).try(:name)},
- :stop_points => Proc.new{|r| r.try(:stop_points).count},
- :journey_patterns => Proc.new{|r| r.try(:journey_patterns).count} },
- [:show, :edit, :delete],
- [],
- 'table has-search'
+ = table_builder_2 @routes,
+ [ \
+ TableBuilderHelper::Column.new( \
+ name: 'ID', \
+ attribute: Proc.new { |n| n.objectid.local_id }, \
+ sortable: false \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :published_name, \
+ attribute: 'published_name' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :wayback, \
+ attribute: 'wayback_text' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ name: 'Arrêt de départ', \
+ attribute: Proc.new { |r| r.try(:stop_points).first.try(:stop_area).try(:name) }, \
+ sortable: false \
+ ), \
+ TableBuilderHelper::Column.new( \
+ name: 'Arrêt d'arrivée', \
+ attribute: Proc.new{ |r| r.try(:stop_points).last.try(:stop_area).try(:name) }, \
+ sortable: false \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :stop_points, \
+ attribute: Proc.new{ |r| r.try(:stop_points).count } \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :journey_patterns, \
+ attribute: Proc.new{ |r| r.try(:journey_patterns).count } \
+ ) \
+ ],
+ links: [:show, :edit],
+ cls: 'table has-search'
= new_pagination @routes, 'pull-right'