diff options
| author | Robert | 2017-12-12 19:23:50 +0100 |
|---|---|---|
| committer | Robert | 2017-12-12 19:23:50 +0100 |
| commit | 2a46643e10e669b34cc6af807adb8dbe3926a248 (patch) | |
| tree | 157819332ae14868f21943105ab346166896582a | |
| parent | f584e9bba564355ca4e3650e4a167991249defb8 (diff) | |
| download | chouette-core-2a46643e10e669b34cc6af807adb8dbe3926a248.tar.bz2 | |
Fixes: #5206@1h; Refactored5206-multiple-selection-refactoring
| -rw-r--r-- | app/helpers/multiple_selection_toolbox_helper.rb | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/app/helpers/multiple_selection_toolbox_helper.rb b/app/helpers/multiple_selection_toolbox_helper.rb index c5a30ddb0..e66dafe22 100644 --- a/app/helpers/multiple_selection_toolbox_helper.rb +++ b/app/helpers/multiple_selection_toolbox_helper.rb @@ -1,30 +1,11 @@ module MultipleSelectionToolboxHelper # Box of links that floats at the bottom right of the page - # c.f. https://projects.af83.io/issues/5206 - # #5206 method too long def multiple_selection_toolbox(workbench_id, *actions, collection_name:) links = content_tag :ul do - - delete_path = referentials_workbench_path workbench_id - actions.flatten.map do |action| - if action == :delete - action_link = link_to( - '#', - method: :delete, - data: { - path: delete_path, - # #5206 Missing Translations an - confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' - }, - title: t("actions.#{action}") - ) do - content_tag :span, '', class: 'fa fa-trash' - end - end - - content_tag :li, action_link, class: 'st_action' - end.join.html_safe + actions.flatten.map{ |action| make_action action, workbench_id } + .join + .html_safe end label = content_tag( @@ -36,7 +17,28 @@ module MultipleSelectionToolboxHelper content_tag :div, '', class: 'select_toolbox noselect', id: "selected-#{collection_name}-action-box" do - links + label + links + label + end + end + + + private + + def make_action action, workbench_id + if action == :delete + action_link = link_to( + '#', + method: :delete, + data: { + path: referentials_workbench_path(workbench_id), + confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' + }, + title: t("actions.#{action}") + ) do + content_tag :span, '', class: 'fa fa-trash' + end end + + content_tag :li, action_link, class: 'st_action' end end |
