From e8879d891f39539fe1d0d6cb14c26a02944234a5 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Mon, 9 Sep 2024 15:50:37 +0000 Subject: [PATCH] Refactors toggle checkboxes link and switch to SVG icon (#23980). Patch by Mizuki ISHIKAWA (user:ishikawa999) git-svn-id: https://svn.redmine.org/redmine/trunk@23047 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 8 +++++--- app/views/roles/permissions.html.erb | 10 ++-------- app/views/trackers/fields.html.erb | 12 +++--------- app/views/workflows/_form.html.erb | 12 +++--------- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index eedf4f891..8960f5ab9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1597,11 +1597,13 @@ module ApplicationHelper link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") end - def toggle_checkboxes_link(selector) - link_to_function '', + def toggle_checkboxes_link(selector, options={}) + css_classes = 'icon icon-checked' + css_classes += ' ' + options[:class] if options[:class] + link_to_function icon_with_label('checked', ''), "toggleCheckboxesBySelector('#{selector}')", :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'icon icon-checked' + :class => css_classes end def progress_bar(pcts, options={}) diff --git a/app/views/roles/permissions.html.erb b/app/views/roles/permissions.html.erb index 07fb6f615..63a1267fc 100644 --- a/app/views/roles/permissions.html.erb +++ b/app/views/roles/permissions.html.erb @@ -37,10 +37,7 @@ <%=l(:label_permissions)%> <% @roles.each do |role| %> - <%= link_to_function('', - "toggleCheckboxesBySelector('input.role-#{role.id}')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'icon-only icon-checked') %> + <%= toggle_checkboxes_link("input.role-#{role.id}") %> <%= content_tag(role.builtin? ? 'em' : 'span', role.name) %> <% end %> @@ -64,10 +61,7 @@ <% humanized_perm_name = l_or_humanize(permission.name, :prefix => 'permission_') %> - <%= link_to_function('', - "toggleCheckboxesBySelector('.permission-#{permission.name} input')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'icon-only icon-checked') %> + <%= toggle_checkboxes_link(".permission-#{permission.name} input") %> <%= humanized_perm_name %> <% @roles.each do |role| %> diff --git a/app/views/trackers/fields.html.erb b/app/views/trackers/fields.html.erb index 0b0fee373..5f44bf43b 100644 --- a/app/views/trackers/fields.html.erb +++ b/app/views/trackers/fields.html.erb @@ -9,9 +9,7 @@ <% @trackers.each do |tracker| %> - <%= link_to_function('', "toggleCheckboxesBySelector('input.tracker-#{tracker.id}')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'icon-only icon-checked') %> + <%= toggle_checkboxes_link("input.tracker-#{tracker.id}") %> <%= tracker.name %> <% end %> @@ -28,9 +26,7 @@ <% field_name = l("field_#{field}".delete_suffix('_id')) %> - <%= link_to_function('', "toggleCheckboxesBySelector('input.core-field-#{field}')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'icon-only icon-checked') %> + <%= toggle_checkboxes_link("input.core-field-#{field}") %> <%= field_name %> <% @trackers.each do |tracker| %> @@ -51,9 +47,7 @@ <% @custom_fields.each do |field| %> - <%= link_to_function('', "toggleCheckboxesBySelector('input.custom-field-#{field.id}')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'icon-only icon-checked') %> + <%= toggle_checkboxes_link("input.custom-field-#{field.id}") %> <%= field.name %> <% @trackers.each do |tracker| %> diff --git a/app/views/workflows/_form.html.erb b/app/views/workflows/_form.html.erb index f0863850f..5b7c16bc9 100644 --- a/app/views/workflows/_form.html.erb +++ b/app/views/workflows/_form.html.erb @@ -2,9 +2,7 @@ - <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled)')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'no-tooltip icon-only icon-checked') %> + <%= toggle_checkboxes_link("table.transitions-#{name} input[type=checkbox]:not(:disabled)", { class: 'no-tooltip' }) %> <%=l(:label_current_status)%> <%=l(:label_new_statuses_allowed)%> @@ -13,9 +11,7 @@ <% for new_status in @statuses %> - <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).new-status-#{new_status.id}')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'no-tooltip icon-only icon-checked') %> + <%= toggle_checkboxes_link("table.transitions-#{name} input[type=checkbox]:not(:disabled).new-status-#{new_status.id}", { class: 'no-tooltip' }) %> <%= new_status.name %> <% end %> @@ -27,9 +23,7 @@ <% next if old_status.nil? && name != 'always' %> - <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).old-status-#{old_status.try(:id) || 0}')", - :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", - :class => 'no-tooltip icon-only icon-checked') %> + <%= toggle_checkboxes_link("table.transitions-#{name} input[type=checkbox]:not(:disabled).old-status-#{old_status.try(:id) || 0}", { class: 'no-tooltip' }) %> <% if old_status %> <% old_status_name = old_status.name %> <%= old_status_name %> -- 2.39.5