diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c7cd7d9d2..21b5e2b4c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,11 +1,38 @@
require 'dtext'
module ApplicationHelper
+ def listing_type(*fields, member_check: true, types: [:revert, :standard])
+ (fields.reduce(false) { |acc, field| acc || params.dig(:search, field).present? } && (!member_check || CurrentUser.is_member?) ? types[0] : types[1])
+ end
+
def diff_list_html(new, old, latest, ul_class: ["diff-list"], li_class: [])
diff = SetDiff.new(new, old, latest)
render "diff_list", diff: diff, ul_class: ul_class, li_class: li_class
end
+ def diff_body_html(record, previous, field)
+ return h(record[field]).gsub(/\r?\n/, 'ΒΆ
').html_safe if previous.blank?
+
+ pattern = Regexp.new('(?:<.+?>)|(?:\w+)|(?:[ \t]+)|(?:\r?\n)|(?:.+?)')
+ DiffBuilder.new(record[field], previous[field], pattern).build
+ end
+
+ def status_diff_html(record)
+ previous = record.previous
+
+ return "New" if previous.blank?
+
+ statuses = []
+ record.class.status_fields.each do |field, status|
+ if record.has_attribute?(field)
+ statuses += [status] if record[field] != previous[field]
+ else
+ statuses += [status] if record.send(field)
+ end
+ end
+ statuses.join("
").html_safe
+ end
+
def wordbreakify(string)
lines = string.scan(/.{1,10}/)
wordbreaked_string = lines.map {|str| h(str)}.join("")