diff options
| -rw-r--r-- | app/controllers/imports_controller.rb | 3 | ||||
| -rw-r--r-- | app/decorators/import_decorator.rb | 54 | ||||
| -rw-r--r-- | app/views/imports/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_page_header.html.slim | 6 | ||||
| -rw-r--r-- | lib/af83/decorator/link.rb | 4 |
5 files changed, 38 insertions, 31 deletions
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index 46d34efda..7a999d657 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -84,9 +84,8 @@ class ImportsController < ChouetteController end def decorate_imports(imports) - ModelDecorator.decorate( + ImportDecorator.decorate( imports, - with: ImportDecorator, context: { workbench: @workbench } diff --git a/app/decorators/import_decorator.rb b/app/decorators/import_decorator.rb index 8b00234d2..440501fc1 100644 --- a/app/decorators/import_decorator.rb +++ b/app/decorators/import_decorator.rb @@ -1,8 +1,6 @@ -class ImportDecorator < Draper::Decorator +class ImportDecorator < AF83::Decorator decorates Import - delegate_all - def import_status_css_class cls ='' cls = 'overheaded-success' if object.status == 'successful' @@ -11,28 +9,34 @@ class ImportDecorator < Draper::Decorator cls end - def action_links - policy = h.policy(object) - links = [] - - links << Link.new( - content: h.t('imports.actions.download'), - href: object.file.url - ) - - if policy.destroy? - links << Link.new( - content: h.destroy_link_content, - href: h.workbench_import_path( - context[:workbench], - object - ), - method: :delete, - data: { confirm: h.t('imports.actions.destroy_confirm') } - ) - end - - links + create_action_link do |l| + l.content t('imports.actions.new') + l.href { h.new_workbench_import_path(workbench_id: context[:workbench]) } + l.class 'btn btn-primary' end + # def action_links + # policy = h.policy(object) + # links = [] + # + # links << Link.new( + # content: h.t('imports.actions.download'), + # href: object.file.url + # ) + # + # if policy.destroy? + # links << Link.new( + # content: h.destroy_link_content, + # href: h.workbench_import_path( + # context[:workbench], + # object + # ), + # method: :delete, + # data: { confirm: h.t('imports.actions.destroy_confirm') } + # ) + # end + # + # links + # end + end diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim index 856b715e0..951910d18 100644 --- a/app/views/imports/index.html.slim +++ b/app/views/imports/index.html.slim @@ -1,6 +1,4 @@ - breadcrumb :imports, @workbench -- content_for :page_header_actions do - = link_to(t('imports.actions.new'), new_workbench_import_path(workbench_id: @workbench), class: 'btn btn-primary') .page_content .container-fluid diff --git a/app/views/layouts/navigation/_page_header.html.slim b/app/views/layouts/navigation/_page_header.html.slim index e407e53da..23bc64db0 100644 --- a/app/views/layouts/navigation/_page_header.html.slim +++ b/app/views/layouts/navigation/_page_header.html.slim @@ -24,13 +24,15 @@ - if action_links&.primary&.any? - action_links.primary.each do |link| = link.to_html do |l| - - l.class "btn btn-default #{l.disabled ? "disabled" : ""}" + - if !l.class? + - l.class "btn btn-default #{l.disabled ? "disabled" : ""}" - if action_links&.secondary&.any? .row.mb-sm .col-lg-12.text-right - action_links.secondary.each do |link| = link.to_html do |l| - - l.class "btn btn-primary #{l.disabled ? "disabled" : ""}" + - if !l.class? + - l.class "btn btn-primary #{l.disabled ? "disabled" : ""}" - if content_for? :page_header_content = yield :page_header_content diff --git a/lib/af83/decorator/link.rb b/lib/af83/decorator/link.rb index 55db3f5bb..10e6091aa 100644 --- a/lib/af83/decorator/link.rb +++ b/lib/af83/decorator/link.rb @@ -25,6 +25,10 @@ class AF83::Decorator::Link link_class args end + def class? + @options[:link_class] && !@options[:link_class].empty? + end + def method_missing name, *args, &block if block_given? @options[name] = block |
