diff options
| author | cedricnjanga | 2018-04-18 06:52:44 -0700 |
|---|---|---|
| committer | cedricnjanga | 2018-04-19 09:20:40 -0700 |
| commit | 4d8e941017d8149c542bd5fe9e6b0a604c6c9cfe (patch) | |
| tree | f0d4a8214db3ffcfb94744fae106610fae3a3c62 | |
| parent | 7a7924fb0a29c05a49c830cef7ce85e35e32f716 (diff) | |
| download | chouette-core-4d8e941017d8149c542bd5fe9e6b0a604c6c9cfe.tar.bz2 | |
Refs #6574 Create decorators to handle sync actions for stop area referential and line referential6574-sync-actions-in-decorators
| -rw-r--r-- | app/controllers/line_referentials_controller.rb | 6 | ||||
| -rw-r--r-- | app/controllers/stop_area_referentials_controller.rb | 7 | ||||
| -rw-r--r-- | app/decorators/line_referential_decorator.rb | 13 | ||||
| -rw-r--r-- | app/decorators/stop_area_referential_decorator.rb | 13 | ||||
| -rw-r--r-- | app/views/line_referentials/show.html.slim | 4 | ||||
| -rw-r--r-- | app/views/stop_area_referentials/show.html.slim | 3 |
6 files changed, 40 insertions, 6 deletions
diff --git a/app/controllers/line_referentials_controller.rb b/app/controllers/line_referentials_controller.rb index 03dab3f8f..e661fbb04 100644 --- a/app/controllers/line_referentials_controller.rb +++ b/app/controllers/line_referentials_controller.rb @@ -2,6 +2,12 @@ class LineReferentialsController < ChouetteController defaults :resource_class => LineReferential + def show + show! do + @line_referential = LineReferentialDecorator.decorate(@line_referential) + end + end + def sync authorize resource, :synchronize? @sync = resource.line_referential_syncs.build diff --git a/app/controllers/stop_area_referentials_controller.rb b/app/controllers/stop_area_referentials_controller.rb index f2d375e49..0e6a54b49 100644 --- a/app/controllers/stop_area_referentials_controller.rb +++ b/app/controllers/stop_area_referentials_controller.rb @@ -1,6 +1,13 @@ class StopAreaReferentialsController < ChouetteController defaults :resource_class => StopAreaReferential + + def show + show! do + @stop_area_referential = StopAreaReferentialDecorator.decorate(@stop_area_referential) + end + end + def sync authorize resource, :synchronize? @sync = resource.stop_area_referential_syncs.build diff --git a/app/decorators/line_referential_decorator.rb b/app/decorators/line_referential_decorator.rb new file mode 100644 index 000000000..1ca0312c3 --- /dev/null +++ b/app/decorators/line_referential_decorator.rb @@ -0,0 +1,13 @@ +class LineReferentialDecorator < AF83::Decorator + decorates LineReferential + + with_instance_decorator do |instance_decorator| + + instance_decorator.action_link policy: :synchronize, primary: :show do |l| + l.content t('actions.sync') + l.href { h. sync_line_referential_path(object.id) } + l.method :post + end + + end +end diff --git a/app/decorators/stop_area_referential_decorator.rb b/app/decorators/stop_area_referential_decorator.rb new file mode 100644 index 000000000..d30501ec9 --- /dev/null +++ b/app/decorators/stop_area_referential_decorator.rb @@ -0,0 +1,13 @@ +class StopAreaReferentialDecorator < AF83::Decorator + decorates StopAreaReferential + + with_instance_decorator do |instance_decorator| + + instance_decorator.action_link policy: :synchronize, primary: :show do |l| + l.content t('actions.sync') + l.href { h. sync_stop_area_referential_path(object.id) } + l.method :post + end + + end +end diff --git a/app/views/line_referentials/show.html.slim b/app/views/line_referentials/show.html.slim index 8db94609a..1f184b6f2 100644 --- a/app/views/line_referentials/show.html.slim +++ b/app/views/line_referentials/show.html.slim @@ -1,7 +1,5 @@ - breadcrumb :line_referential, @line_referential -- if policy(@line_referential).synchronize? - - content_for :page_header_actions do - = link_to(t('actions.sync'), sync_line_referential_path(@line_referential), method: :post, class: 'btn btn-default') +- page_header_content_for @line_referential .page_content .container-fluid diff --git a/app/views/stop_area_referentials/show.html.slim b/app/views/stop_area_referentials/show.html.slim index 9e6925e2c..bca89a0f4 100644 --- a/app/views/stop_area_referentials/show.html.slim +++ b/app/views/stop_area_referentials/show.html.slim @@ -1,8 +1,5 @@ - breadcrumb :stop_area_referential, @stop_area_referential - page_header_content_for @stop_area_referential -- if policy(@stop_area_referential).synchronize? - - content_for :page_header_actions do - = link_to(t('actions.sync'), sync_stop_area_referential_path(@stop_area_referential), method: :post, class: 'btn btn-default') .page_content .container-fluid |
