diff options
| author | Teddy Wing | 2018-01-25 12:39:52 +0100 | 
|---|---|---|
| committer | Zog | 2018-01-25 17:18:03 +0100 | 
| commit | c9e5f4e5ab03c0d8e4ff65e72b8c77260cba9c20 (patch) | |
| tree | 90564f7bfc98e8e3bfe9822cb38fadebcb3ab64a /app | |
| parent | 6a00c37a43648fdeee5d6eceb92b52986e06bb31 (diff) | |
| download | chouette-core-c9e5f4e5ab03c0d8e4ff65e72b8c77260cba9c20.tar.bz2 | |
StopPointDecorator: Convert to new action links interface
Subtleties were that the links need to reference `StopArea`s. In
particular, the `edit` link goes to the `StopAreaReferential` path
instead of the referential-StopArea path.
Refs #5586
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/routes_controller.rb | 5 | ||||
| -rw-r--r-- | app/decorators/stop_point_decorator.rb | 34 | ||||
| -rw-r--r-- | app/views/referential_stop_areas/show.html.slim | 9 | ||||
| -rw-r--r-- | app/views/routes/show.html.slim | 4 | 
4 files changed, 33 insertions, 19 deletions
| diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 79f49143a..af5a9a91b 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -47,10 +47,7 @@ class RoutesController < ChouetteController          line: @line        }) -      @route_sp = ModelDecorator.decorate( -        @route_sp, -        with: StopPointDecorator -      ) +      @route_sp = StopPointDecorator.decorate(@route_sp)      end    end diff --git a/app/decorators/stop_point_decorator.rb b/app/decorators/stop_point_decorator.rb index 27e1a7058..e777e2b56 100644 --- a/app/decorators/stop_point_decorator.rb +++ b/app/decorators/stop_point_decorator.rb @@ -1,9 +1,35 @@ -class StopPointDecorator < StopAreaDecorator +class StopPointDecorator < AF83::Decorator    decorates Chouette::StopPoint -  delegate_all +  with_instance_decorator do |instance_decorator| +    instance_decorator.show_action_link do |l| +      l.href do +        h.referential_stop_area_path( +          object.referential, +          object.stop_area +        ) +      end +    end -  def action_links -    common_action_links(object.stop_area).flatten +    instance_decorator.edit_action_link do |l| +      l.content h.t('stop_points.actions.edit') +      l.href do +        h.edit_stop_area_referential_stop_area_path( +          object.stop_area.stop_area_referential, +          object.stop_area +        ) +      end +    end + +    instance_decorator.destroy_action_link do |l| +      l.content h.destroy_link_content('stop_points.actions.destroy') +      l.href do +        h.referential_stop_area_path( +          object.referential, +          object.stop_area +        ) +      end +      l.data confirm: h.t('stop_points.actions.destroy_confirm') +    end    end  end diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index 0470b4654..cb04ab7a6 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -1,14 +1,5 @@  - breadcrumb :referential_stop_area, @referential, @stop_area  - page_header_content_for @stop_area -- content_for :page_header_content do -  .row -    .col-lg-12.text-right.mb-sm -      - @stop_area.action_links.each do |link| -        = link_to link.href, -            method: link.method, -            data: link.data, -            class: 'btn btn-primary' do -              = link.content  .page_content    .container-fluid diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index 4d5963cd1..375d7c57b 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -54,9 +54,9 @@                  attribute: Proc.new { |s| t("stop_points.stop_point.for_alighting.#{s.for_alighting}") } \                ) \              ], -            links: [:show],              sortable: false, -            cls: 'table has-stoppoints' +            cls: 'table has-stoppoints', +            action: :index          - else            = replacement_msg t('stop_areas.search_no_results') | 
