diff options
| author | Zog | 2017-12-20 12:58:20 +0100 |
|---|---|---|
| committer | Alban Peignier | 2017-12-21 21:19:27 +0100 |
| commit | 9a34cb48f49df574ae1e7c599713ed246e2938cf (patch) | |
| tree | 49c91cfdaa645f39363c3e8c492b86a0dde08c89 /app/helpers | |
| parent | 8cd9b9ee5fc127b2f39a9c89c71327ab8d5e9cec (diff) | |
| download | chouette-core-9a34cb48f49df574ae1e7c599713ed246e2938cf.tar.bz2 | |
Refs #5430 @2h; Deactivate lines instead of destroying them
- Add `activate` and `deactivate` actions in `LinesController`, as well
as corresponding routes
- Add `activate!` and `deactivate!` methods in `Chouette::Line`, as well
as `activated?`
- Add `activate?` and `deactivate?` permissions in `LinePolicy`
- Add corresponding `action_links`in the Decorator
- Create helper for these actions
- Add an optional `'extra_class` to the Links
- Update styles for ".delete-action" to handle the case where there are
several
- Add I18n keys accordingly
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/links_helper.rb | 15 | ||||
| -rw-r--r-- | app/helpers/table_builder_helper.rb | 6 |
2 files changed, 19 insertions, 2 deletions
diff --git a/app/helpers/links_helper.rb b/app/helpers/links_helper.rb index 4fb7a797d..088415dc3 100644 --- a/app/helpers/links_helper.rb +++ b/app/helpers/links_helper.rb @@ -1,5 +1,18 @@ module LinksHelper + def custom_link_content(translation_key, klass, extra_class: nil) + klass = ["fa", "fa-#{klass}", "mr-xs", extra_class].compact.join(" ") + content_tag(:span, nil, class: klass) + t(translation_key) + end + def destroy_link_content(translation_key = 'actions.destroy') - content_tag(:span, nil, class: 'fa fa-trash mr-xs') + t(translation_key) + custom_link_content translation_key, 'trash' + end + + def deactivate_link_content(translation_key = 'actions.deactivate') + custom_link_content translation_key, 'power-off', extra_class: "text-danger" + end + + def activate_link_content(translation_key = 'actions.activate') + custom_link_content translation_key, 'power-off', extra_class: "text-success" end end diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index de78e903d..96b2889da 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -368,6 +368,10 @@ module TableBuilderHelper end def gear_menu_link(link) + klass = [link.extra_class] + klass << 'delete-action' if link.method == :delete + klass = klass.compact.join(' ') + klass = nil unless klass.present? content_tag( :li, link_to( @@ -377,7 +381,7 @@ module TableBuilderHelper ) do link.content end, - class: ('delete-action' if link.method == :delete) + class: klass ) end |
