diff options
| author | Teddy Wing | 2018-01-23 11:42:15 +0100 | 
|---|---|---|
| committer | Zog | 2018-01-25 17:18:01 +0100 | 
| commit | 759699cec33a06b931c50f4473460fb79290e356 (patch) | |
| tree | 12492d1a95491c6f619a07e638451e78ca7f307a /app/decorators | |
| parent | 9f4584ef7427575fce4b8294b79f2368b130d8b6 (diff) | |
| download | chouette-core-759699cec33a06b931c50f4473460fb79290e356.tar.bz2 | |
Imports#index: Move 'New import' button to action links
Begin the process of converting the `ImportDecorator` to the new action
links interface.
For now, only the "New import" button on the top right of the index page
is converted. The rest of the links are commented out for now and will
be treated in a subsequent commit.
Add a new `#class?` method to `AF83::Decorator::Link` that tells callers
whether a CSS class has been defined on the link. This allows us to
determine whether we should force a class or use the one provided in
`_page_header.html.slim`.
We need a way to specify the class of the link in the header because the
"New import" button is supposed to be blue (`.btn-primary`), but the
default for primary action links is white.
Refs #5586
Diffstat (limited to 'app/decorators')
| -rw-r--r-- | app/decorators/import_decorator.rb | 54 | 
1 files changed, 29 insertions, 25 deletions
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  | 
