summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb19
-rw-r--r--app/helpers/icons_helper.rb40
-rw-r--r--app/helpers/issues_helper.rb4
-rw-r--r--app/helpers/journals_helper.rb16
-rw-r--r--app/helpers/my_helper.rb4
-rw-r--r--app/helpers/projects_helper.rb10
-rw-r--r--app/helpers/queries_helper.rb2
-rw-r--r--app/helpers/versions_helper.rb2
-rw-r--r--app/helpers/watchers_helper.rb7
9 files changed, 75 insertions, 29 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ca8e1c266..315868de9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -127,7 +127,9 @@ module ApplicationHelper
# * :download - Force download (default: false)
def link_to_attachment(attachment, options={})
text = options.delete(:text) || attachment.filename
+ icon = 'attachment'
if options.delete(:download)
+ icon = 'download'
route_method = :download_named_attachment_url
options[:filename] = attachment.filename
else
@@ -136,9 +138,10 @@ module ApplicationHelper
options.delete(:filename)
end
html_options = options.slice!(:only_path, :filename)
+
options[:only_path] = true unless options.key?(:only_path)
url = send(route_method, attachment, options)
- link_to text, url, html_options
+ link_to icon_with_label(icon, text), url, html_options
end
# Generates a link to a SCM revision
@@ -744,7 +747,7 @@ module ApplicationHelper
:reorder_url => options[:url] || url_for(object),
:reorder_param => options[:param] || object.class.name.underscore
}
- content_tag('span', '',
+ content_tag('span', icon_with_label('reorder', ''),
:class => "icon-only icon-sort-handle sort-handle",
:data => data,
:title => l(:button_sort))
@@ -824,7 +827,7 @@ module ApplicationHelper
content = capture(&)
if content.present?
trigger =
- content_tag('span', l(:button_actions), :class => 'icon-only icon-actions',
+ content_tag('span', icon_with_label('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')
@@ -1365,7 +1368,7 @@ module ApplicationHelper
content_tag(
'div',
link_to(
- l(:button_edit_section),
+ icon_with_label('edit', l(:button_edit_section)),
options[:edit_section_links].merge(
:section => @current_section),
:class => 'icon-only icon-edit'),
@@ -1559,7 +1562,7 @@ module ApplicationHelper
:class => 'icon icon-del'
}.merge(options)
- link_to button_name, url, options
+ link_to icon_with_label('del', button_name), url, options
end
def link_to_function(name, function, html_options={})
@@ -1567,7 +1570,7 @@ module ApplicationHelper
end
def link_to_context_menu
- link_to l(:button_actions), '#', title: l(:button_actions), class: 'icon-only icon-actions js-contextmenu'
+ link_to icon_with_label('3-bullets', l(:button_actions)), '#', title: l(:button_actions), class: 'icon-only icon-actions js-contextmenu '
end
# Helper to render JSON in views
@@ -1897,8 +1900,8 @@ module ApplicationHelper
def copy_object_url_link(url)
link_to_function(
- l(:button_copy_link), 'copyTextToClipboard(this);',
- class: 'icon icon-copy-link',
+ icon_with_label('copy-link', l(:button_copy_link)), 'copyTextToClipboard(this);',
+ class: 'icon icon-copy-link ',
data: {'clipboard-text' => url}
)
end
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb
new file mode 100644
index 000000000..d82a74611
--- /dev/null
+++ b/app/helpers/icons_helper.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+# Redmine - project management software
+# Copyright (C) 2006- Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module IconsHelper
+ DEFAULT_ICON_SIZE = "14"
+ DEFAULT_SPRITE = "icons"
+
+ def icon_with_label(icon_name, label_text, icon_only: false)
+ sprite_icon(icon_name) + content_tag(:span, label_text, class: "icon-label")
+ end
+
+ def sprite_icon(icon_name, size: DEFAULT_ICON_SIZE, sprite: DEFAULT_SPRITE)
+ sprite_path = "#{sprite}.svg"
+
+ content_tag(
+ :svg,
+ content_tag(:use, '', { 'href' => "#{asset_path(sprite_path)}#icon--#{icon_name}" }),
+ class: "s#{size}",
+ aria: {
+ hidden: true
+ }
+ )
+ end
+end
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 1455fa1c5..c92dd75e7 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(
- l(:label_delete_link_to_subtask),
+ icon_with_label('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(
- l(:label_relation_delete),
+ icon_with_label('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 d5c996d87..c3ba50180 100644
--- a/app/helpers/journals_helper.rb
+++ b/app/helpers/journals_helper.rb
@@ -31,37 +31,37 @@ 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(l(:label_download_all_attachments),
+ dropbown_links << link_to(icon_with_label('download', l(:label_download_all_attachments)),
container_attachments_download_path(journal),
:title => l(:label_download_all_attachments),
- :class => 'icon icon-download'
+ :class => 'icon icon-download '
)
end
if journal.notes.present?
if options[:reply_links]
- links << link_to(l(:button_quote),
+ links << link_to(icon_with_label('comment', l(:button_quote)),
quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice),
:remote => true,
:method => 'post',
:title => l(:button_quote),
- :class => 'icon-only icon-comment'
+ :class => 'icon-only icon-comment '
)
end
if journal.editable_by?(User.current)
- links << link_to(l(:button_edit),
+ links << link_to(icon_with_label('edit', l(:button_edit)),
edit_journal_path(journal),
:remote => true,
:method => 'get',
:title => l(:button_edit),
- :class => 'icon-only icon-edit'
+ :class => 'icon-only icon-edit '
)
- dropbown_links << link_to(l(:button_delete),
+ dropbown_links << link_to(icon_with_label('del', l(:button_delete)),
journal_path(journal, :journal => {:notes => ""}),
:remote => true,
:method => 'put',
:data => {:confirm => l(:text_are_you_sure)},
- :class => 'icon icon-del'
+ :class => 'icon icon-del '
)
end
end
diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb
index f65288de1..2957f4e90 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', '', :class => 'icon-only icon-sort-handle sort-handle', :title => l(:button_move))
- close = link_to(l(:button_delete),
+ 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)),
{: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 5a8649dc3..bb05a3ef1 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(l(:label_project_new), new_project_path, :class => 'icon icon-add')
+ links << link_to(icon_with_label('add', l(:label_project_new)), new_project_path, :class => 'icon icon-add')
end
if User.current.admin?
- links << link_to(l(:label_administration), admin_projects_path, :class => 'icon icon-settings')
+ links << link_to(icon_with_label('settings', l(:label_administration)), admin_projects_path, :class => 'icon icon-settings')
end
links
end
@@ -182,12 +182,14 @@ module ProjectsHelper
if bookmarked
css << "icon-bookmark"
+ icon = "bookmark"
method = "delete"
- text = l(:button_project_bookmark_delete)
+ text = icon_with_label(icon, l(:button_project_bookmark_delete))
else
css << "icon-bookmark-off"
+ icon = "bookmark-off"
method = "post"
- text = l(:button_project_bookmark)
+ text = icon_with_label(icon, l(:button_project_bookmark))
end
url = bookmark_project_path(project)
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 516088f8d..26d1ee48b 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -517,7 +517,7 @@ module QueriesHelper
def link_to_clear_query(params = {:set_filter => 1, :sort => '', :project_id => @project})
link_to(
- l(:button_clear),
+ icon_with_label('clear-query', l(:button_clear)),
params,
:class => 'icon-only icon-clear-query',
:title => l(:button_clear)
diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb
index 5ad319c7f..4f88ba5ee 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 l(:label_issue_new), new_project_issue_path(project, :issue => attrs, :back_url => version_path(version)), :class => 'icon icon-add'
+ 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'
end
end
end
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 8afd5af31..2071879e3 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -25,7 +25,8 @@ module WatchersHelper
return '' unless objects.any?
watched = Watcher.any_watched?(objects, user)
- css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
+ icon = watched ? 'fav' : 'fav-off'
+ css = [watcher_css(objects), '', 'icon', icon].join(' ')
text = watched ? l(:button_unwatch) : l(:button_watch)
url = watch_path(
:object_type => objects.first.class.to_s.underscore,
@@ -33,7 +34,7 @@ module WatchersHelper
)
method = watched ? 'delete' : 'post'
- link_to text, url, :remote => true, :method => method, :class => css
+ link_to icon_with_label(icon, text), url, :remote => true, :method => method, :class => css
end
# Returns the css class used to identify watch links for a given +object+
@@ -61,7 +62,7 @@ module WatchersHelper
:object_id => object.id,
:user_id => user}
s << ' '
- s << link_to(l(:button_delete), url,
+ s << link_to(icon_with_label('del', l(:button_delete)), url,
:remote => true, :method => 'delete',
:class => "delete icon-only icon-del",
:title => l(:button_delete))