aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2018-04-19 18:24:22 +0200
committerGitHub2018-04-19 18:24:22 +0200
commitba4cfd78bb9a750aa9f077392934cee39058a616 (patch)
treef0d4a8214db3ffcfb94744fae106610fae3a3c62
parent7a7924fb0a29c05a49c830cef7ce85e35e32f716 (diff)
parent4d8e941017d8149c542bd5fe9e6b0a604c6c9cfe (diff)
downloadchouette-core-ba4cfd78bb9a750aa9f077392934cee39058a616.tar.bz2
Merge pull request #497 from af83/6574-sync-actions-in-decorators
Refs #6574 Create decorators to handle sync actions for stop area ref…
-rw-r--r--app/controllers/line_referentials_controller.rb6
-rw-r--r--app/controllers/stop_area_referentials_controller.rb7
-rw-r--r--app/decorators/line_referential_decorator.rb13
-rw-r--r--app/decorators/stop_area_referential_decorator.rb13
-rw-r--r--app/views/line_referentials/show.html.slim4
-rw-r--r--app/views/stop_area_referentials/show.html.slim3
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