summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb64
-rw-r--r--app/helpers/avatars_helper.rb61
-rw-r--r--app/helpers/icons_helper.rb45
-rw-r--r--app/helpers/issues_helper.rb107
-rw-r--r--app/helpers/journals_helper.rb8
-rw-r--r--app/helpers/messages_helper.rb1
-rw-r--r--app/helpers/news_helper.rb1
-rw-r--r--app/helpers/principal_memberships_helper.rb18
-rw-r--r--app/helpers/projects_helper.rb4
-rw-r--r--app/helpers/queries_helper.rb8
-rw-r--r--app/helpers/reactions_helper.rb100
-rw-r--r--app/helpers/reports_helper.rb4
-rw-r--r--app/helpers/repositories_helper.rb4
-rw-r--r--app/helpers/routes_helper.rb62
-rw-r--r--app/helpers/settings_helper.rb9
-rw-r--r--app/helpers/watchers_helper.rb7
16 files changed, 342 insertions, 161 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index fe250f7f3..ab418fb38 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -128,7 +128,7 @@ module ApplicationHelper
# * :download - Force download (default: false)
def link_to_attachment(attachment, options={})
text = options.delete(:text) || attachment.filename
- icon = options.fetch(:icon, false)
+ icon = options.delete(:icon)
if options.delete(:download)
route_method = :download_named_attachment_url
@@ -346,18 +346,18 @@ module ApplicationHelper
def thumbnail_tag(attachment)
thumbnail_size = Setting.thumbnails_size.to_i
thumbnail_path = thumbnail_path(attachment, :size => thumbnail_size * 2)
- link_to(
- image_tag(
- thumbnail_path,
- :srcset => "#{thumbnail_path} 2x",
- :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;",
- :title => attachment.filename,
- :loading => "lazy"
- ),
- attachment_path(
- attachment
+ tag.div class: 'thumbnail', title: attachment.filename do
+ link_to(
+ image_tag(
+ thumbnail_path,
+ :srcset => "#{thumbnail_path} 2x",
+ :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;",
+ :alt => attachment.filename,
+ :loading => "lazy"
+ ),
+ attachment_path(attachment)
)
- )
+ end
end
def toggle_link(name, id, options={})
@@ -414,8 +414,16 @@ module ApplicationHelper
end
def format_activity_description(text)
- h(text.to_s.truncate(120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).
- gsub(/[\r\n]+/, "<br />").html_safe
+ h(
+ # Limit input to avoid regex performance issues
+ text.to_s.slice(0, 10240)
+ # Abbreviate consecutive quoted lines as '> ...', keeping the first line
+ .gsub(%r{(^>.*?(?:\r?\n))(?:>.*?(?:\r?\n)+)+}m, "\\1> ...\n")
+ # Remove all content following the first <pre> or <code> tag
+ .sub(%r{[\r\n]*<(pre|code)>.*$}m, '')
+ # Truncate the description to a specified length and append '...'
+ .truncate(240)
+ ).gsub(/[\r\n]+/, "<br>").html_safe
end
def format_version_name(version)
@@ -428,7 +436,7 @@ module ApplicationHelper
def format_changeset_comments(changeset, options={})
method = options[:short] ? :short_comments : :comments
- textilizable changeset, method, :formatting => Setting.commit_logs_formatting?
+ textilizable changeset, method, project: changeset.project, formatting: Setting.commit_logs_formatting?
end
def due_date_distance_in_words(date)
@@ -510,7 +518,9 @@ module ApplicationHelper
def render_flash_messages
s = +''
flash.each do |k, v|
- s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
+ next unless v.is_a?(String)
+
+ s << content_tag('div', notice_icon(k) + v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
end
s.html_safe
end
@@ -781,7 +791,7 @@ module ApplicationHelper
end
def other_formats_links(&)
- concat('<p class="other-formats">'.html_safe + l(:label_export_to))
+ concat('<p class="other-formats hide-when-print">'.html_safe + l(:label_export_to))
yield Redmine::Views::OtherFormatsBuilder.new(self)
concat('</p>'.html_safe)
end
@@ -1378,7 +1388,7 @@ module ApplicationHelper
<|
$)
}x
- HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/i unless const_defined?(:HEADING_RE)
+ HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/im unless const_defined?(:HEADING_RE)
def parse_sections(text, project, obj, attr, only_path, options)
return unless options[:edit_section_links]
@@ -1568,7 +1578,9 @@ module ApplicationHelper
def render_error_messages(errors)
html = +""
if errors.present?
- html << "<div id='errorExplanation'><ul>\n"
+ html << "<div id='errorExplanation'>\n"
+ html << notice_icon('error')
+ html << "<ul>\n"
errors.each do |error|
html << "<li>#{h error}</li>\n"
end
@@ -1597,7 +1609,7 @@ module ApplicationHelper
# Helper to render JSON in views
def raw_json(arg)
- arg.to_json.to_s.gsub('/', '\/').html_safe
+ arg.to_json.gsub('/', '\/').html_safe
end
def back_url_hidden_field_tag
@@ -1795,7 +1807,7 @@ module ApplicationHelper
if Setting.wiki_tablesort_enabled?
tags << javascript_include_tag('tablesort-5.2.1.min.js', 'tablesort-5.2.1.number.min.js')
end
- tags << javascript_include_tag('application', 'responsive')
+ tags << javascript_include_tag('application-legacy', 'responsive')
unless User.current.pref.warn_on_leaving_unsaved == '0'
warn_text = escape_javascript(l(:text_warn_on_leaving_unsaved))
tags <<
@@ -1907,6 +1919,14 @@ module ApplicationHelper
end
end
+ def heads_for_i18n
+ javascript_tag(
+ "rm = window.rm || {};" \
+ "rm.I18n = rm.I18n || {};" \
+ "rm.I18n = Object.freeze({buttonCopy: '#{l(:button_copy)}'});"
+ )
+ end
+
def heads_for_auto_complete(project)
data_sources = autocomplete_data_sources(project)
javascript_tag(
@@ -1924,7 +1944,7 @@ module ApplicationHelper
def copy_object_url_link(url)
link_to_function(
- sprite_icon('copy-link', l(:button_copy_link)), 'copyTextToClipboard(this);',
+ sprite_icon('copy-link', l(:button_copy_link)), 'copyDataClipboardTextToClipboard(this);',
class: 'icon icon-copy-link',
data: {'clipboard-text' => url}
)
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
index b39427bda..67567fd8d 100644
--- a/app/helpers/avatars_helper.rb
+++ b/app/helpers/avatars_helper.rb
@@ -38,24 +38,9 @@ module AvatarsHelper
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
def avatar(user, options = {})
if Setting.gravatar_enabled?
- options[:default] = Setting.gravatar_default
- options[:class] = GravatarHelper::DEFAULT_OPTIONS[:class] + " " + options[:class] if options[:class]
- email = nil
- if user.respond_to?(:mail)
- email = user.mail
- options[:title] = user.name unless options[:title]
- elsif user.to_s =~ %r{<(.+?)>}
- email = $1
- end
- if email.present?
- gravatar(email.to_s.downcase, options) rescue nil
- elsif user.is_a?(AnonymousUser)
- anonymous_avatar(options)
- elsif user.is_a?(Group)
- group_avatar(options)
- else
- nil
- end
+ gravatar_avatar_tag(user, options)
+ elsif user.respond_to?(:initials)
+ initials_avatar_tag(user, options)
else
''
end
@@ -69,8 +54,6 @@ module AvatarsHelper
end
end
- private
-
def anonymous_avatar(options={})
image_tag 'anonymous.png', GravatarHelper::DEFAULT_OPTIONS.except(:default, :rating, :ssl).merge(options)
end
@@ -78,4 +61,42 @@ module AvatarsHelper
def group_avatar(options={})
image_tag 'group.png', GravatarHelper::DEFAULT_OPTIONS.except(:default, :rating, :ssl).merge(options)
end
+
+ private
+
+ def gravatar_avatar_tag(user, options)
+ options[:default] = Setting.gravatar_default
+ options[:class] = [GravatarHelper::DEFAULT_OPTIONS[:class], options[:class]].compact.join(' ')
+
+ email = extract_email_from_user(user)
+
+ if user.respond_to?(:mail)
+ options[:title] ||= user.name
+ options[:initials] = user.initials if options[:default] == "initials" && user.initials.present?
+ end
+
+ if email.present?
+ gravatar(email.to_s.downcase, options) rescue nil
+ elsif user.is_a?(AnonymousUser)
+ anonymous_avatar(options)
+ elsif user.is_a?(Group)
+ group_avatar(options)
+ end
+ end
+
+ def initials_avatar_tag(user, options)
+ size = (options.delete(:size) || GravatarHelper::DEFAULT_OPTIONS[:size]).to_i
+
+ css_class = ["avatar-color-#{user.id % 8}", 'avatar', "s#{size}", options[:class]].compact.join(' ')
+
+ content_tag('span', user.initials, role: 'img', class: css_class, title: options[:title])
+ end
+
+ def extract_email_from_user(user)
+ if user.respond_to?(:mail)
+ user.mail
+ elsif user.to_s =~ %r{<(.+?)>}
+ $1
+ end
+ end
end
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb
index 99006308e..6afb84537 100644
--- a/app/helpers/icons_helper.rb
+++ b/app/helpers/icons_helper.rb
@@ -21,10 +21,10 @@ 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, sprite: DEFAULT_SPRITE, plugin: nil)
+ def sprite_icon(icon_name, label = nil, icon_only: false, size: DEFAULT_ICON_SIZE, style: :outline, css_class: nil, sprite: DEFAULT_SPRITE, plugin: nil, rtl: false)
sprite = plugin ? "plugin_assets/#{plugin}/#{sprite}.svg" : "#{sprite}.svg"
- svg_icon = svg_sprite_icon(icon_name, size: size, css_class: css_class, sprite: sprite)
+ svg_icon = svg_sprite_icon(icon_name, size: size, style: style, css_class: css_class, sprite: sprite, rtl: rtl)
if label
label_classes = ["icon-label"]
@@ -36,23 +36,23 @@ module IconsHelper
end
end
- def file_icon(entry, name, **options)
+ def file_icon(entry, name, **)
if entry.is_dir?
- sprite_icon("folder", name, **options)
+ sprite_icon("folder", name, **)
else
icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(name))
- sprite_icon(icon_name, name, **options)
+ sprite_icon(icon_name, name, **)
end
end
- def principal_icon(principal, **options)
+ def principal_icon(principal, **)
raise ArgumentError, "First argument has to be a Principal, was #{principal.inspect}" unless principal.is_a?(Principal)
principal_class = principal.class.name.downcase
- sprite_icon('group', **options) if ['groupanonymous', 'groupnonmember', 'group'].include?(principal_class)
+ sprite_icon('group', **) if ['groupanonymous', 'groupnonmember', 'group'].include?(principal_class)
end
- def activity_event_type_icon(event_type, **options)
+ def activity_event_type_icon(event_type, **)
icon_name = case event_type
when 'reply'
'comments'
@@ -64,14 +64,39 @@ module IconsHelper
event_type
end
- sprite_icon(icon_name, **options)
+ sprite_icon(icon_name, **)
+ end
+
+ def scm_change_icon(action, name, **options)
+ icon_name = case action
+ when 'A'
+ "add"
+ when 'D'
+ "circle-minus"
+ else
+ "circle-dot-filled"
+ end
+ sprite_icon(icon_name, name, size: 14)
+ end
+
+ def notice_icon(type, **)
+ icon_name = case type
+ when 'notice'
+ 'checked'
+ when 'warning', 'error'
+ 'warning'
+ end
+
+ sprite_icon(icon_name, **)
end
private
- def svg_sprite_icon(icon_name, size: DEFAULT_ICON_SIZE, sprite: DEFAULT_SPRITE, css_class: nil)
+ def svg_sprite_icon(icon_name, size: DEFAULT_ICON_SIZE, style: :outline, sprite: DEFAULT_SPRITE, css_class: nil, rtl: false)
css_classes = "s#{size} icon-svg"
+ css_classes += " icon-svg-filled" if style == :filled
css_classes += " #{css_class}" unless css_class.nil?
+ css_classes += " icon-rtl" if rtl
content_tag(
:svg,
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index b4c87f758..ce3607a5d 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -21,6 +21,8 @@ module IssuesHelper
include ApplicationHelper
include Redmine::Export::PDF::IssuesPdfHelper
include IssueStatusesHelper
+ include QueriesHelper
+ include ReactionsHelper
def issue_list(issues, &)
ancestors = []
@@ -89,9 +91,28 @@ module IssuesHelper
s.html_safe
end
+ def get_related_issues_columns_for_project(issue)
+ query = IssueQuery.new project: issue.project
+ available_columns = query.available_inline_columns
+ column_names = Setting.related_issues_default_columns
+
+ (column_names - %w[tracker subject]).filter_map do |name|
+ available_columns.find { |f| f.name.to_s == name }
+ end
+ end
+
def render_descendants_tree(issue)
+ columns_list = get_related_issues_columns_for_project(issue)
+
manage_relations = User.current.allowed_to?(:manage_subtasks, issue.project)
s = +'<table class="list issues odd-even">'
+
+ if Setting.display_related_issues_table_headers?
+ headers = [l(:field_subject)]
+ headers += columns_list.map(&:caption)
+ s << content_tag(:thead, content_tag(:tr, safe_join(headers.map{|h| content_tag :th, h})), class: "related-issues")
+ end
+
issue_list(
issue.descendants.visible.
preload(:status, :priority, :tracker,
@@ -115,29 +136,17 @@ module IssuesHelper
"".html_safe
end
buttons << link_to_context_menu
- s <<
- content_tag(
- 'tr',
- content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil),
- :class => 'checkbox') +
- content_tag('td',
- link_to_issue(
- child,
- :project => (issue.project_id != child.project_id)),
- :class => 'subject') +
- content_tag('td', h(child.status), :class => 'status') +
- content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') +
- content_tag('td', format_date(child.start_date), :class => 'start_date') +
- content_tag('td', format_date(child.due_date), :class => 'due_date') +
- content_tag('td',
- (if child.disabled_core_fields.include?('done_ratio')
- ''
- else
- progress_bar(child.done_ratio)
- end),
- :class=> 'done_ratio') +
- content_tag('td', buttons, :class => 'buttons'),
- :class => css)
+
+ row_content =
+ content_tag('td', check_box_tag('ids[]', child.id, false, id: nil), class: 'checkbox') +
+ content_tag('td', link_to_issue(child, project: (issue.project_id != child.project_id)), class: 'subject')
+
+ columns_list.each do |column|
+ row_content << content_tag('td', column_content(column, child), class: column.css_classes.to_s)
+ end
+
+ row_content << content_tag('td', buttons, class: 'buttons')
+ s << content_tag('tr', row_content, class: css, id: "issue-#{child.id}").html_safe
end
s << '</table>'
s.html_safe
@@ -199,8 +208,17 @@ module IssuesHelper
# Renders the list of related issues on the issue details view
def render_issue_relations(issue, relations)
+ columns_list = get_related_issues_columns_for_project(issue)
+
manage_relations = User.current.allowed_to?(:manage_issue_relations, issue.project)
s = ''.html_safe
+
+ if Setting.display_related_issues_table_headers?
+ headers = [l(:field_subject)]
+ headers += columns_list.map(&:caption)
+ s = content_tag :thead, content_tag(:tr, safe_join(headers.map{|h| content_tag :th, h})), class: "related-issues"
+ end
+
relations.each do |relation|
other_issue = relation.other_issue(issue)
css = "issue hascontextmenu #{other_issue.css_classes} #{relation.css_classes_for(other_issue)}"
@@ -219,36 +237,19 @@ module IssuesHelper
"".html_safe
end
buttons << link_to_context_menu
- s <<
- content_tag(
- 'tr',
- content_tag('td',
- check_box_tag(
- "ids[]", other_issue.id,
- false, :id => nil),
- :class => 'checkbox') +
- content_tag('td',
- relation.to_s(@issue) do |other|
- link_to_issue(
- other,
- :project => Setting.cross_project_issue_relations?
- )
- end.html_safe,
- :class => 'subject') +
- content_tag('td', other_issue.status, :class => 'status') +
- content_tag('td', link_to_user(other_issue.assigned_to), :class => 'assigned_to') +
- content_tag('td', format_date(other_issue.start_date), :class => 'start_date') +
- content_tag('td', format_date(other_issue.due_date), :class => 'due_date') +
- content_tag('td',
- (if other_issue.disabled_core_fields.include?('done_ratio')
- ''
- else
- progress_bar(other_issue.done_ratio)
- end),
- :class=> 'done_ratio') +
- content_tag('td', buttons, :class => 'buttons'),
- :id => "relation-#{relation.id}",
- :class => css)
+
+ subject_content = relation.to_s(@issue) { |other| link_to_issue other, project: Setting.cross_project_issue_relations? }.html_safe
+
+ row_content =
+ content_tag('td', check_box_tag('ids[]', other_issue.id, false, id: nil), class: 'checkbox') +
+ content_tag('td', subject_content, class: 'subject')
+
+ columns_list.each do |column|
+ row_content << content_tag('td', column_content(column, other_issue), class: column.css_classes.to_s)
+ end
+
+ row_content << content_tag('td', buttons, class: 'buttons')
+ s << content_tag('tr', row_content, id: "relation-#{relation.id}", class: css)
end
content_tag('table', s, :class => 'list issues odd-even')
end
diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb
index 6c22fc4ca..0ddbc34b8 100644
--- a/app/helpers/journals_helper.rb
+++ b/app/helpers/journals_helper.rb
@@ -19,6 +19,7 @@
module JournalsHelper
include Redmine::QuoteReply::Helper
+ include ReactionsHelper
# Returns the attachments of a journal that are displayed as thumbnails
def journal_thumbnail_attachments(journal)
@@ -40,10 +41,12 @@ module JournalsHelper
)
end
+ links << reaction_button(journal)
+
if journal.notes.present?
if options[:reply_links]
url = quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice)
- links << quote_reply(url, "#journal-#{journal.id}-notes", icon_only: true)
+ links << quote_reply_button(url: url, icon_only: true)
end
if journal.editable_by?(User.current)
links << link_to(sprite_icon('edit', l(:button_edit)),
@@ -66,7 +69,8 @@ module JournalsHelper
end
def render_notes(issue, journal, options={})
- content_tag('div', textilizable(journal, :notes), :id => "journal-#{journal.id}-notes", :class => "wiki")
+ content_tag('div', textilizable(journal, :notes),
+ id: "journal-#{journal.id}-notes", class: "wiki journal-note", data: { quote_reply_target: 'content' })
end
def render_private_notes_indicator(journal)
diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb
index fd9ba3bcb..92f788d0c 100644
--- a/app/helpers/messages_helper.rb
+++ b/app/helpers/messages_helper.rb
@@ -19,4 +19,5 @@
module MessagesHelper
include Redmine::QuoteReply::Helper
+ include ReactionsHelper
end
diff --git a/app/helpers/news_helper.rb b/app/helpers/news_helper.rb
index a5c50fdfd..cd7b6734a 100644
--- a/app/helpers/news_helper.rb
+++ b/app/helpers/news_helper.rb
@@ -18,4 +18,5 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module NewsHelper
+ include ReactionsHelper
end
diff --git a/app/helpers/principal_memberships_helper.rb b/app/helpers/principal_memberships_helper.rb
index d9caf4f50..e69324247 100644
--- a/app/helpers/principal_memberships_helper.rb
+++ b/app/helpers/principal_memberships_helper.rb
@@ -38,27 +38,27 @@ module PrincipalMembershipsHelper
end
end
- def new_principal_membership_path(principal, *args)
+ def new_principal_membership_path(principal, *)
if principal.is_a?(Group)
- new_group_membership_path(principal, *args)
+ new_group_membership_path(principal, *)
else
- new_user_membership_path(principal, *args)
+ new_user_membership_path(principal, *)
end
end
- def edit_principal_membership_path(principal, *args)
+ def edit_principal_membership_path(principal, *)
if principal.is_a?(Group)
- edit_group_membership_path(principal, *args)
+ edit_group_membership_path(principal, *)
else
- edit_user_membership_path(principal, *args)
+ edit_user_membership_path(principal, *)
end
end
- def principal_membership_path(principal, membership, *args)
+ def principal_membership_path(principal, membership, *)
if principal.is_a?(Group)
- group_membership_path(principal, membership, *args)
+ group_membership_path(principal, membership, *)
else
- user_membership_path(principal, membership, *args)
+ user_membership_path(principal, membership, *)
end
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 01a5452f7..bae1c4e3a 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -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 << 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)
+ s << tag.span(sprite_icon('user', l(:label_my_projects), icon_only: true), class: 'icon-only icon-user my-project') if User.current.member_of?(project)
+ s << tag.span(sprite_icon('bookmarked', l(:label_my_bookmarks), icon_only: true), class: 'icon-only icon-bookmarked-project') 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
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 708a8acfb..3aef7083a 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -169,7 +169,7 @@ module QueriesHelper
group_name = format_object(group)
end
group_name ||= ""
- group_count = result_count_by_group ? result_count_by_group[group] : nil
+ group_count = result_count_by_group&.[](group)
group_totals = totals_by_group.map {|column, t| total_tag(column, t[group] || 0)}.join(" ").html_safe
end
end
@@ -192,6 +192,8 @@ module QueriesHelper
value =
if [:hours, :spent_hours, :total_spent_hours, :estimated_hours, :total_estimated_hours, :estimated_remaining_hours].include? column.name
format_hours(value)
+ elsif column.is_a?(QueryCustomFieldColumn)
+ format_object(value, thousands_delimiter: column.custom_field.thousands_delimiter?)
else
format_object(value)
end
@@ -480,8 +482,6 @@ module QueriesHelper
url_params =
if controller_name == 'issues'
{:controller => 'issues', :action => 'index', :project_id => @project}
- elsif controller_name == 'admin' && action_name == 'projects'
- {:admin_projects => '1'}
else
{}
end
@@ -510,7 +510,7 @@ module QueriesHelper
url_params.merge(:query_id => query),
:class => css,
:title => query.description,
- :data => { :disable_with => query.name }) +
+ :data => { :disable_with => CGI.escapeHTML(query.name) }) +
clear_link.html_safe)
end.join("\n").html_safe,
:class => 'queries'
diff --git a/app/helpers/reactions_helper.rb b/app/helpers/reactions_helper.rb
new file mode 100644
index 000000000..e02e1c9f9
--- /dev/null
+++ b/app/helpers/reactions_helper.rb
@@ -0,0 +1,100 @@
+# 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 ReactionsHelper
+ # Maximum number of users to display in the reaction button tooltip
+ DISPLAY_REACTION_USERS_LIMIT = 10
+
+ def reaction_button(object)
+ return unless Redmine::Reaction.visible?(object, User.current)
+
+ detail = object.reaction_detail
+
+ user_reaction = detail.user_reaction
+ count = detail.reaction_count
+ visible_user_names = detail.visible_users.take(DISPLAY_REACTION_USERS_LIMIT).map(&:name)
+
+ tooltip = build_reaction_tooltip(visible_user_names, count)
+
+ if Redmine::Reaction.editable?(object, User.current)
+ if user_reaction.present?
+ reaction_button_reacted(object, user_reaction, count, tooltip)
+ else
+ reaction_button_not_reacted(object, count, tooltip)
+ end
+ else
+ reaction_button_readonly(object, count, tooltip)
+ end
+ end
+
+ def reaction_id_for(object)
+ dom_id(object, :reaction)
+ end
+
+ private
+
+ def reaction_button_reacted(object, reaction, count, tooltip)
+ reaction_button_wrapper object do
+ link_to(
+ sprite_icon('thumb-up-filled', count.nonzero?, style: :filled),
+ reaction_path(reaction, object_type: object.class.name, object_id: object),
+ remote: true, method: :delete,
+ class: ['icon', 'reaction-button', 'reacted'],
+ title: tooltip
+ )
+ end
+ end
+
+ def reaction_button_not_reacted(object, count, tooltip)
+ reaction_button_wrapper object do
+ link_to(
+ sprite_icon('thumb-up', count.nonzero?),
+ reactions_path(object_type: object.class.name, object_id: object),
+ remote: true, method: :post,
+ class: 'icon reaction-button',
+ title: tooltip
+ )
+ end
+ end
+
+ def reaction_button_readonly(object, count, tooltip)
+ reaction_button_wrapper object do
+ tag.span(class: 'icon reaction-button readonly', title: tooltip) do
+ sprite_icon('thumb-up', count.nonzero?)
+ end
+ end
+ end
+
+ def reaction_button_wrapper(object, &)
+ tag.span(class: 'reaction-button-wrapper', data: { 'reaction-button-id': reaction_id_for(object) }, &)
+ end
+
+ def build_reaction_tooltip(visible_user_names, count)
+ return if count.zero?
+
+ display_user_names = visible_user_names.dup
+ others = count - visible_user_names.size
+
+ if others.positive?
+ display_user_names << I18n.t(:reaction_text_x_other_users, count: others)
+ end
+
+ display_user_names.to_sentence(locale: I18n.locale)
+ end
+end
diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb
index 6390ecbdb..f8df59b00 100644
--- a/app/helpers/reports_helper.rb
+++ b/app/helpers/reports_helper.rb
@@ -34,9 +34,9 @@ module ReportsHelper
a
end
- def aggregate_link(data, criteria, *args)
+ def aggregate_link(data, criteria, *)
a = aggregate data, criteria
- a > 0 ? link_to(h(a), *args) : '-'
+ a > 0 ? link_to(h(a), *) : '-'
end
def aggregate_path(project, field, row, options={})
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index 7a6978979..c72816367 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -96,7 +96,7 @@ module RepositoriesHelper
if s = tree[file][:s]
style << ' folder'
path_param = to_path_param(@repository.relative_path(file))
- text = link_to(h(text), :controller => 'repositories',
+ text = link_to(sprite_icon("folder-open", h(text)), :controller => 'repositories',
:action => 'show',
:id => @project,
:repository_id => @repository.identifier_param,
@@ -108,7 +108,7 @@ module RepositoriesHelper
elsif c = tree[file][:c]
style << " change-#{c.action}"
path_param = to_path_param(@repository.relative_path(c.path))
- text = link_to(h(text), :controller => 'repositories',
+ text = link_to(scm_change_icon(c.action, h(text)), :controller => 'repositories',
:action => 'entry',
:id => @project,
:repository_id => @repository.identifier_param,
diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb
index f5d6dbd38..a27ea783e 100644
--- a/app/helpers/routes_helper.rb
+++ b/app/helpers/routes_helper.rb
@@ -20,83 +20,83 @@
module RoutesHelper
# Returns the path to project issues or to the cross-project
# issue list if project is nil
- def _project_issues_path(project, *args)
+ def _project_issues_path(project, *)
if project
- project_issues_path(project, *args)
+ project_issues_path(project, *)
else
- issues_path(*args)
+ issues_path(*)
end
end
- def _project_issues_url(project, *args)
+ def _project_issues_url(project, *)
if project
- project_issues_url(project, *args)
+ project_issues_url(project, *)
else
- issues_url(*args)
+ issues_url(*)
end
end
- def _project_news_path(project, *args)
+ def _project_news_path(project, *)
if project
- project_news_index_path(project, *args)
+ project_news_index_path(project, *)
else
- news_index_path(*args)
+ news_index_path(*)
end
end
- def _new_project_issue_path(project, *args)
+ def _new_project_issue_path(project, *)
if project
- new_project_issue_path(project, *args)
+ new_project_issue_path(project, *)
else
- new_issue_path(*args)
+ new_issue_path(*)
end
end
- def _project_calendar_path(project, *args)
- project ? project_calendar_path(project, *args) : issues_calendar_path(*args)
+ def _project_calendar_path(project, *)
+ project ? project_calendar_path(project, *) : issues_calendar_path(*)
end
- def _project_gantt_path(project, *args)
- project ? project_gantt_path(project, *args) : issues_gantt_path(*args)
+ def _project_gantt_path(project, *)
+ project ? project_gantt_path(project, *) : issues_gantt_path(*)
end
- def _time_entries_path(project, issue, *args)
+ def _time_entries_path(project, issue, *)
if project
- project_time_entries_path(project, *args)
+ project_time_entries_path(project, *)
else
- time_entries_path(*args)
+ time_entries_path(*)
end
end
- def _report_time_entries_path(project, issue, *args)
+ def _report_time_entries_path(project, issue, *)
if project
- report_project_time_entries_path(project, *args)
+ report_project_time_entries_path(project, *)
else
- report_time_entries_path(*args)
+ report_time_entries_path(*)
end
end
- def _new_time_entry_path(project, issue, *args)
+ def _new_time_entry_path(project, issue, *)
if issue
- new_issue_time_entry_path(issue, *args)
+ new_issue_time_entry_path(issue, *)
elsif project
- new_project_time_entry_path(project, *args)
+ new_project_time_entry_path(project, *)
else
- new_time_entry_path(*args)
+ new_time_entry_path(*)
end
end
# Returns the path to bulk update issues or to issue path
# if only one issue is selected for bulk update
- def _bulk_update_issues_path(issue, *args)
+ def _bulk_update_issues_path(issue, *)
if issue
- issue_path(issue, *args)
+ issue_path(issue, *)
else
- bulk_update_issues_path(*args)
+ bulk_update_issues_path(*)
end
end
- def board_path(board, *args)
- project_board_path(board.project, board, *args)
+ def board_path(board, *)
+ project_board_path(board.project, board, *)
end
end
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 1fb57b2d7..c1f989805 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -48,7 +48,11 @@ module SettingsHelper
errors.each do |name, message|
s << content_tag('li', content_tag('b', l("setting_#{name}")) + " " + message)
end
- content_tag('div', content_tag('ul', s), :id => 'errorExplanation')
+
+ h = ''.html_safe
+ h << notice_icon('error')
+ h << content_tag('ul', s)
+ content_tag('div', h, :id => 'errorExplanation')
end
def setting_value(setting)
@@ -240,6 +244,7 @@ module SettingsHelper
['Mystery man', 'mm'],
['Retro', 'retro'],
['Robohash', 'robohash'],
- ['Wavatars', 'wavatar']]
+ ['Wavatars', 'wavatar'],
+ ['Initials', 'initials']]
end
end
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 882325c18..bfed8adf2 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -26,6 +26,7 @@ module WatchersHelper
watched = Watcher.any_watched?(objects, user)
css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
+ icon = watched ? 'unwatch' : 'watch'
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 sprite_icon('fav', text), url, :remote => true, :method => method, :class => css
+ link_to sprite_icon(icon, text), url, :remote => true, :method => method, :class => css
end
# Returns the css class used to identify watch links for a given +object+
@@ -47,7 +48,9 @@ module WatchersHelper
def watchers_list(object)
remove_allowed = User.current.allowed_to?(:"delete_#{object.class.name.underscore}_watchers", object.project)
content = ''.html_safe
- lis = object.watcher_users.sorted.collect do |user|
+ scope = object.watcher_users
+ scope = scope.includes(:email_address) if Setting.gravatar_enabled?
+ lis = scope.sorted.collect do |user|
s = ''.html_safe
s << avatar(user, :size => "16").to_s if user.is_a?(User)
s << link_to_principal(user, class: user.class.to_s.downcase)