Actions
Maintenance #1951
closedxmera Omnia - Collection #1826: Maintenance tasks of several components
Maintenance #1739: Support Redmine 5.1.1
Check if application helper changes will have impact on plugins
Start date:
Due date:
% Done:
100%
Estimated time:
Compatible Redmine Version:
Pull Request Link:
Description
Affected plugins:
- Redmine Project Types
- project:redmine-local-avatars
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 209796cf7..2457422fc 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -252,34 +252,34 @@ module ApplicationHelper
# Helper that formats object for html or text rendering
def format_object(object, html=true, &block)
- if block_given?
+ if block
object = yield object
end
- case object.class.name
- when 'Array'
+ case object
+ when Array
formatted_objects = object.map {|o| format_object(o, html)}
html ? safe_join(formatted_objects, ', ') : formatted_objects.join(', ')
- when 'Time'
+ when Time
format_time(object)
- when 'Date'
+ when Date
format_date(object)
- when 'Fixnum'
+ when Integer
object.to_s
- when 'Float'
+ when Float
sprintf "%.2f", object
- when 'User', 'Group'
+ when User, Group
html ? link_to_principal(object) : object.to_s
- when 'Project'
+ when Project
html ? link_to_project(object) : object.to_s
- when 'Version'
+ when Version
html ? link_to_version(object) : object.to_s
- when 'TrueClass'
+ when TrueClass
l(:general_text_Yes)
- when 'FalseClass'
+ when FalseClass
l(:general_text_No)
- when 'Issue'
+ when Issue
object.visible? && html ? link_to_issue(object) : "##{object.id}"
- when 'Attachment'
+ when Attachment
if html
content_tag(
:span,
@@ -294,8 +294,9 @@ module ApplicationHelper
else
object.filename
end
- when 'CustomValue', 'CustomFieldValue'
+ when CustomValue, CustomFieldValue
return "" unless object.customized&.visible?
+
if object.custom_field
f = object.custom_field.format.formatted_custom_value(self, object, html)
if f.nil? || f.is_a?(String)
@@ -318,10 +319,11 @@ 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(attachment),
- :srcset => "#{thumbnail_path(attachment, :size => thumbnail_size * 2)} 2x",
+ thumbnail_path,
+ :srcset => "#{thumbnail_path} 2x",
:style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;",
:loading => "lazy"
),
@@ -438,7 +440,7 @@ module ApplicationHelper
classes = (ancestors.empty? ? 'root' : 'child')
classes += ' archived' if project.archived?
s << "<li class='#{classes}'><div class='#{classes}'>"
- s << h(block_given? ? capture(project, &block) : project.name)
+ s << h(block ? capture(project, &block) : project.name)
s << "</div>\n"
ancestors << project
end
@@ -692,6 +694,8 @@ module ApplicationHelper
end
def time_tag(time)
+ return if time.nil?
+
text = distance_of_time_in_words(Time.now, time)
if @project
link_to(text,
@@ -874,9 +878,9 @@ module ApplicationHelper
@current_section = 0 if options[:edit_section_links]
parse_sections(text, project, obj, attr, only_path, options)
- text = parse_non_pre_blocks(text, obj, macros, options) do |text|
+ text = parse_non_pre_blocks(text, obj, macros, options) do |txt|
[:parse_inline_attachments, :parse_hires_images, :parse_wiki_links, :parse_redmine_links].each do |method_name|
- send method_name, text, project, obj, attr, only_path, options
+ send method_name, txt, project, obj, attr, only_path, options
end
end
parse_headings(text, project, obj, attr, only_path, options)
@@ -940,7 +944,7 @@ module ApplicationHelper
attachments += obj.attachments if obj.respond_to?(:attachments)
end
if attachments.present?
- text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
+ text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|webp))"(\s+alt="([^"]*)")?/i) do |m|
filename, ext, alt, alttext = $1, $2, $3, $4
# search for the picture in attachments
if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
@@ -1499,7 +1503,7 @@ module ApplicationHelper
# Render the error messages for the given objects
def error_messages_for(*objects)
- objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
+ objects = objects.filter_map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}
errors = objects.map {|o| o.errors.full_messages}.flatten
render_error_messages(errors)
end
@@ -1801,6 +1805,23 @@ module ApplicationHelper
end
end
+ def export_csv_separator_select_tag
+ options = [[l(:label_comma_char), ','], [l(:label_semi_colon_char), ';']]
+ # Add the separator from translations if it is missing
+ general_csv_separator = l(:general_csv_separator)
+ unless options.index { |option| option.last == general_csv_separator }
+ options << Array.new(2, general_csv_separator)
+ end
+ content_tag(:p) do
+ concat(
+ content_tag(:label) do
+ concat l(:label_fields_separator) + ' '
+ concat select_tag('field_separator', options_for_select(options, general_csv_separator))
+ end
+ )
+ end
+ end
+
# Returns an array of error messages for bulk edited items (issues, time entries)
def bulk_edit_error_messages(items)
messages = {}
@@ -1851,10 +1872,10 @@ module ApplicationHelper
# Returns the markdown formatter: markdown or common_mark
# ToDo: Remove this when markdown will be removed
def markdown_formatter
- if Setting.text_formatting == "common_mark"
- "common_mark"
- else
+ if Setting.text_formatting == "markdown"
"markdown"
+ else
+ "common_mark"
end
end
Updated by liaham about 1 year ago
- Status changed from New to Closed
- Assignee set to liaham
- % Done changed from 0 to 100
No impact on Redmine Project Types.
No impact on project:redmine-local-avatars.
Actions