diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2024-10-19 10:06:26 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2024-10-19 10:06:26 +0000 |
commit | d1008280d8bead4757646d53f18d0b76fa20b429 (patch) | |
tree | 6424d06cc95da85711dc27460e39a976760527fd /app/helpers | |
parent | ffb78c12c35192aff8e13389577ef9564ab278ee (diff) | |
download | redmine-d1008280d8bead4757646d53f18d0b76fa20b429.tar.gz redmine-d1008280d8bead4757646d53f18d0b76fa20b429.zip |
Renames and improves methods provided by @IconsHelper@ (#23980).
git-svn-id: https://svn.redmine.org/redmine/trunk@23145 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 18 | ||||
-rw-r--r-- | app/helpers/email_addresses_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/gantt_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/icons_helper.rb | 40 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/journals_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/my_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 12 | ||||
-rw-r--r-- | app/helpers/projects_queries_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/queries_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/sort_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/users_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/versions_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/watchers_helper.rb | 4 |
14 files changed, 64 insertions, 56 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8d390d6f7..dd639c0c4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -143,7 +143,7 @@ module ApplicationHelper options[:only_path] = true unless options.key?(:only_path) url = send(route_method, attachment, options) - label = icon ? icon_with_label(icon, text) : text + label = icon ? sprite_icon(icon, text) : text link_to label, url, html_options end @@ -657,7 +657,7 @@ module ApplicationHelper check_box_tag(name, principal.id, false, :id => nil) + (avatar(principal, :size => 16).presence || content_tag( - 'span', icon_for_principal(principal.class.name.downcase), + 'span', principal_icon(principal.class.name.downcase), :class => "name icon icon-#{principal.class.name.downcase}" ) ) + principal.to_s @@ -769,7 +769,7 @@ module ApplicationHelper :reorder_url => options[:url] || url_for(object), :reorder_param => options[:param] || object.class.name.underscore } - content_tag('span', icon_with_label('reorder', ''), + content_tag('span', sprite_icon('reorder', ''), :class => "icon-only icon-sort-handle sort-handle", :data => data, :title => l(:button_sort)) @@ -849,7 +849,7 @@ module ApplicationHelper content = capture(&) if content.present? trigger = - content_tag('span', icon_with_label('3-bullets', l(:button_actions)), :class => 'icon-only icon-actions', + content_tag('span', sprite_icon('3-bullets', l(:button_actions)), :class => 'icon-only icon-actions', :title => l(:button_actions)) trigger = content_tag('span', trigger, :class => 'drdn-trigger') content = content_tag('div', content, :class => 'drdn-items') @@ -1390,7 +1390,7 @@ module ApplicationHelper content_tag( 'div', link_to( - icon_with_label('edit', l(:button_edit_section)), + sprite_icon('edit', l(:button_edit_section)), options[:edit_section_links].merge( :section => @current_section), :class => 'icon-only icon-edit'), @@ -1584,7 +1584,7 @@ module ApplicationHelper :class => 'icon icon-del' }.merge(options) - link_to icon_with_label('del', button_name), url, options + link_to sprite_icon('del', button_name), url, options end def link_to_function(name, function, html_options={}) @@ -1592,7 +1592,7 @@ module ApplicationHelper end def link_to_context_menu - link_to icon_with_label('3-bullets', l(:button_actions)), '#', title: l(:button_actions), class: 'icon-only icon-actions js-contextmenu ' + link_to sprite_icon('3-bullets', l(:button_actions)), '#', title: l(:button_actions), class: 'icon-only icon-actions js-contextmenu ' end # Helper to render JSON in views @@ -1619,7 +1619,7 @@ module ApplicationHelper 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', ''), + link_to_function sprite_icon('checked', ''), "toggleCheckboxesBySelector('#{selector}')", :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}", :class => css_classes @@ -1924,7 +1924,7 @@ module ApplicationHelper def copy_object_url_link(url) link_to_function( - icon_with_label('copy-link', l(:button_copy_link)), 'copyTextToClipboard(this);', + sprite_icon('copy-link', l(:button_copy_link)), 'copyTextToClipboard(this);', class: 'icon icon-copy-link', data: {'clipboard-text' => url} ) diff --git a/app/helpers/email_addresses_helper.rb b/app/helpers/email_addresses_helper.rb index 093f1b1c3..2f42de374 100644 --- a/app/helpers/email_addresses_helper.rb +++ b/app/helpers/email_addresses_helper.rb @@ -22,14 +22,14 @@ module EmailAddressesHelper def toggle_email_address_notify_link(address) if address.notify? link_to( - icon_with_label('email', l(:label_disable_notifications)), + sprite_icon('email', l(:label_disable_notifications)), user_email_address_path(address.user, address, :notify => '0'), :method => :put, :remote => true, :title => l(:label_disable_notifications), :class => 'icon-only icon-email') else link_to( - icon_with_label('email-disabled', l(:label_enable_notifications)), + sprite_icon('email-disabled', l(:label_enable_notifications)), user_email_address_path(address.user, address, :notify => '1'), :method => :put, :remote => true, :title => l(:label_enable_notifications), diff --git a/app/helpers/gantt_helper.rb b/app/helpers/gantt_helper.rb index d037dfeaa..054aad366 100644 --- a/app/helpers/gantt_helper.rb +++ b/app/helpers/gantt_helper.rb @@ -23,21 +23,21 @@ module GanttHelper when :in if gantt.zoom < 4 link_to( - icon_with_label('zoom-in', l(:text_zoom_in)), + sprite_icon('zoom-in', l(:text_zoom_in)), {:params => request.query_parameters.merge(gantt.params.merge(:zoom => (gantt.zoom + 1)))}, :class => 'icon icon-zoom-in') else - content_tag(:span, icon_with_label('zoom-in', l(:text_zoom_in)), :class => 'icon icon-zoom-in').html_safe + content_tag(:span, sprite_icon('zoom-in', l(:text_zoom_in)), :class => 'icon icon-zoom-in').html_safe end when :out if gantt.zoom > 1 link_to( - icon_with_label('zoom-out', l(:text_zoom_out)), + sprite_icon('zoom-out', l(:text_zoom_out)), {:params => request.query_parameters.merge(gantt.params.merge(:zoom => (gantt.zoom - 1)))}, :class => 'icon icon-zoom-out') else - content_tag(:span, icon_with_label('zoom-out', l(:text_zoom_out)), :class => 'icon icon-zoom-out').html_safe + content_tag(:span, sprite_icon('zoom-out', l(:text_zoom_out)), :class => 'icon icon-zoom-out').html_safe end end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index e297d950b..ee1c66f3e 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -20,28 +20,36 @@ module IconsHelper DEFAULT_ICON_SIZE = "18" DEFAULT_SPRITE = "icons" + + def sprite_icon(icon_name, label = nil, icon_only: false, size: DEFAULT_ICON_SIZE, css_class: nil) + svg_icon = svg_sprite_icon(icon_name, size: size, css_class: css_class) - def icon_with_label(icon_name, label_text, icon_only: false, size: DEFAULT_ICON_SIZE, css_class: nil) - label_classes = ["icon-label"] - label_classes << "hidden" if icon_only - sprite_icon(icon_name, size: size, css_class: css_class) + content_tag(:span, label_text, class: label_classes.join(' ')) + if label + label_classes = ["icon-label"] + label_classes << "hidden" if icon_only + + svg_icon + content_tag(:span, label, class: label_classes.join(' ')) + else + svg_icon + end end - def icon_for_file(entry, name, size: DEFAULT_ICON_SIZE, css_class: nil) + # + def file_icon(entry, name, size: DEFAULT_ICON_SIZE, css_class: nil) if entry.is_dir? - icon_with_label("folder", name, size: size, css_class: css_class) + sprite_icon("folder", name, size: size, css_class: css_class) else - icon = icon_for_mime_type(Redmine::MimeType.css_class_of(name)) - icon_with_label(icon, name, size: size, css_class: css_class) + icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(name)) + sprite_icon(icon_name, name, size: size, css_class: css_class) end end - def icon_for_principal(principal_class, size: DEFAULT_ICON_SIZE, css_class: nil) - sprite_icon('group', size: size, css_class: css_class) if ['groupanonymous', 'groupnonmember', 'group'].include?(principal_class) + def principal_icon(principal_class, size: DEFAULT_ICON_SIZE, css_class: nil) + svg_sprite_icon('group', size: size, css_class: css_class) if ['groupanonymous', 'groupnonmember', 'group'].include?(principal_class) end - def icon_for_event_type(event_type, size: DEFAULT_ICON_SIZE, css_class: nil) - icon = case event_type + def activity_event_type_icon(event_type, size: DEFAULT_ICON_SIZE, css_class: nil) + icon_name = case event_type when 'reply' 'comments' when 'time-entry' @@ -52,10 +60,12 @@ module IconsHelper event_type end - sprite_icon(icon, size: size, css_class: css_class) + svg_sprite_icon(icon_name, size: size, css_class: css_class) end - def sprite_icon(icon_name, size: DEFAULT_ICON_SIZE, sprite: DEFAULT_SPRITE, css_class: nil) + private + + def svg_sprite_icon(icon_name, size: DEFAULT_ICON_SIZE, sprite: DEFAULT_SPRITE, css_class: nil) sprite_path = "#{sprite}.svg" css_classes = "s#{size} icon-svg" css_classes += " #{css_class}" unless css_class.nil? @@ -70,8 +80,6 @@ module IconsHelper ) end - private - def icon_for_mime_type(mime) if %w(text-plain text-x-c text-x-csharp text-x-java text-x-php text-x-ruby text-xml text-css text-html text-css text-html diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 88c98f90d..dc5b894e5 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -101,7 +101,7 @@ module IssuesHelper buttons = if manage_relations link_to( - icon_with_label('link-break', l(:label_delete_link_to_subtask)), + sprite_icon('link-break', l(:label_delete_link_to_subtask)), issue_path( {:id => child.id, :issue => {:parent_issue_id => ''}, :back_url => issue_path(issue.id), :no_flash => '1'} @@ -207,7 +207,7 @@ module IssuesHelper buttons = if manage_relations link_to( - icon_with_label('link-break', l(:label_relation_delete)), + sprite_icon('link-break', l(:label_relation_delete)), relation_path(relation, issue_id: issue.id), :remote => true, :method => :delete, diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index e4c23995e..6c22fc4ca 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -33,7 +33,7 @@ module JournalsHelper dropbown_links << copy_object_url_link(issue_url(issue, anchor: "note-#{indice}", only_path: false)) if journal.attachments.size > 1 - dropbown_links << link_to(icon_with_label('download', l(:label_download_all_attachments)), + dropbown_links << link_to(sprite_icon('download', l(:label_download_all_attachments)), container_attachments_download_path(journal), :title => l(:label_download_all_attachments), :class => 'icon icon-download' @@ -46,14 +46,14 @@ module JournalsHelper links << quote_reply(url, "#journal-#{journal.id}-notes", icon_only: true) end if journal.editable_by?(User.current) - links << link_to(icon_with_label('edit', l(:button_edit)), + links << link_to(sprite_icon('edit', l(:button_edit)), edit_journal_path(journal), :remote => true, :method => 'get', :title => l(:button_edit), :class => 'icon-only icon-edit' ) - dropbown_links << link_to(icon_with_label('del', l(:button_delete)), + dropbown_links << link_to(sprite_icon('del', l(:button_delete)), journal_path(journal, :journal => {:notes => ""}), :remote => true, :method => 'put', diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb index 2957f4e90..16b4ca290 100644 --- a/app/helpers/my_helper.rb +++ b/app/helpers/my_helper.rb @@ -34,8 +34,8 @@ module MyHelper def render_block(block, user) content = render_block_content(block, user) if content.present? - handle = content_tag('span', icon_with_label('reorder', ''), :class => 'icon-only icon-sort-handle sort-handle', :title => l(:button_move)) - close = link_to(icon_with_label('close', l(:button_delete)), + handle = content_tag('span', sprite_icon('reorder', ''), :class => 'icon-only icon-sort-handle sort-handle', :title => l(:button_move)) + close = link_to(sprite_icon('close', l(:button_delete)), {:action => "remove_block", :block => block}, :remote => true, :method => 'post', :class => "icon-only icon-close", :title => l(:button_delete)) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 2cd5aff61..01a5452f7 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -63,10 +63,10 @@ module ProjectsHelper def render_project_action_links links = (+"").html_safe if User.current.allowed_to?(:add_project, nil, :global => true) - links << link_to(icon_with_label('add', l(:label_project_new)), new_project_path, :class => 'icon icon-add') + links << link_to(sprite_icon('add', l(:label_project_new)), new_project_path, :class => 'icon icon-add') end if User.current.admin? - links << link_to(icon_with_label('settings', l(:label_administration)), admin_projects_path, :class => 'icon icon-settings') + links << link_to(sprite_icon('settings', l(:label_administration)), admin_projects_path, :class => 'icon icon-settings') end links end @@ -80,8 +80,8 @@ module ProjectsHelper classes += %w(icon icon-bookmarked-project) if bookmarked_project_ids.include?(project.id) s = link_to_project(project, {}, :class => classes.uniq.join(' ')) - s << icon_with_label('user', l(:label_my_projects), icon_only: true) if User.current.member_of?(project) - s << icon_with_label('bookmarked', l(:label_my_bookmarks), icon_only: true) if bookmarked_project_ids.include?(project.id) + s << sprite_icon('user', l(:label_my_projects), icon_only: true) if User.current.member_of?(project) + s << sprite_icon('bookmarked', l(:label_my_bookmarks), icon_only: true) if bookmarked_project_ids.include?(project.id) if project.description.present? s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') end @@ -187,12 +187,12 @@ module ProjectsHelper css << "icon-bookmark" icon = "bookmark-delete" method = "delete" - text = icon_with_label(icon, l(:button_project_bookmark_delete)) + text = sprite_icon(icon, l(:button_project_bookmark_delete)) else css << "icon-bookmark-off" icon = "bookmark-add" method = "post" - text = icon_with_label(icon, l(:button_project_bookmark)) + text = sprite_icon(icon, l(:button_project_bookmark)) end url = bookmark_project_path(project) diff --git a/app/helpers/projects_queries_helper.rb b/app/helpers/projects_queries_helper.rb index 7c978f350..302ec5055 100644 --- a/app/helpers/projects_queries_helper.rb +++ b/app/helpers/projects_queries_helper.rb @@ -24,8 +24,8 @@ module ProjectsQueriesHelper case column.name when :name link_to_project(item) + - (tag.span(icon_with_label('user', l(:label_my_projects), icon_only: true), class: 'icon-only icon-user my-project') if User.current.member_of?(item)) + - (tag.span(icon_with_label('bookmarked', l(:label_my_bookmarks), icon_only: true), class: 'icon-only icon-bookmarked-project') if User.current.bookmarked_project_ids.include?(item.id)) + (tag.span(sprite_icon('user', l(:label_my_projects), icon_only: true), class: 'icon-only icon-user my-project') if User.current.member_of?(item)) + + (tag.span(sprite_icon('bookmarked', l(:label_my_bookmarks), icon_only: true), class: 'icon-only icon-bookmarked-project') if User.current.bookmarked_project_ids.include?(item.id)) when :short_description if item.description? # Sets :inline_attachments to false to avoid performance issues diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 2712b6151..d2991fd25 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -225,7 +225,7 @@ module QueriesHelper end content = link_to( - icon_with_label(icon, column.caption), + sprite_icon(icon, column.caption), {:params => request.query_parameters.deep_merge(sort_param)}, link_options ) @@ -519,7 +519,7 @@ module QueriesHelper def link_to_clear_query(params = {:set_filter => 1, :sort => '', :project_id => @project}) link_to( - icon_with_label('clear-query', l(:button_clear)), + sprite_icon('clear-query', l(:button_clear)), params, :class => 'icon-only icon-clear-query', :title => l(:button_clear) diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb index b827c61c4..77b01e16a 100644 --- a/app/helpers/sort_helper.rb +++ b/app/helpers/sort_helper.rb @@ -127,7 +127,7 @@ module SortHelper caption = column.to_s.humanize unless caption sort_options = {:sort => @sort_criteria.add(column.to_s, order).to_param} - link_to(icon_with_label(icon, caption), {:params => request.query_parameters.merge(sort_options)}, :class => css) + link_to(sprite_icon(icon, caption), { :params => request.query_parameters.merge(sort_options)}, :class => css) end # Returns a table header <th> tag with a sort link for the named column diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 71527b87b..0da236e38 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -69,17 +69,17 @@ module UsersHelper url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil} if user.locked? - link_to icon_with_label('unlock', l(:button_unlock)), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' + link_to sprite_icon('unlock', l(:button_unlock)), url.merge(:user => { :status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' elsif user.registered? - link_to icon_with_label('unlock', l(:button_activate)), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' + link_to sprite_icon('unlock', l(:button_activate)), url.merge(:user => { :status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' elsif user != User.current - link_to icon_with_label('lock', l(:button_lock)), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock' + link_to sprite_icon('lock', l(:button_lock)), url.merge(:user => { :status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock' end end def additional_emails_link(user) if user.email_addresses.count > 1 || Setting.max_additional_emails.to_i > 0 - link_to icon_with_label('email', l(:label_email_address_plural)), user_email_addresses_path(@user), :class => 'icon icon-email-add', :remote => true + link_to sprite_icon('email', l(:label_email_address_plural)), user_email_addresses_path(@user), :class => 'icon icon-email-add', :remote => true end end diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 4f88ba5ee..98b16415b 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -101,7 +101,7 @@ module VersionsHelper :tracker_id => new_issue_tracker, :fixed_version_id => version.id } - link_to icon_with_label('add', l(:label_issue_new)), new_project_issue_path(project, :issue => attrs, :back_url => version_path(version)), :class => 'icon icon-add' + link_to sprite_icon('add', l(:label_issue_new)), new_project_issue_path(project, :issue => attrs, :back_url => version_path(version)), :class => 'icon icon-add' end end end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 286eaa8e6..f7763e41b 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -33,7 +33,7 @@ module WatchersHelper ) method = watched ? 'delete' : 'post' - link_to icon_with_label('fav', text), url, :remote => true, :method => method, :class => css + link_to sprite_icon('fav', text), url, :remote => true, :method => method, :class => css end # Returns the css class used to identify watch links for a given +object+ @@ -61,7 +61,7 @@ module WatchersHelper :object_id => object.id, :user_id => user} s << ' ' - s << link_to(icon_with_label('del', l(:button_delete)), url, + s << link_to(sprite_icon('del', l(:button_delete)), url, :remote => true, :method => 'delete', :class => "delete icon-only icon-del", :title => l(:button_delete)) |