| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 | module HistoryHelper
  def creation_tag(object)
    field_set_tag t("layouts.history_tag.title"), :class => "history_tag" do
      content_tag :ul do
        [(content_tag :li do
          if object.has_attribute?(:created_at)
            object.class.human_attribute_name('created_at') + ' : ' + l(object.created_at, :format => :short)
          end
        end),
        (content_tag :li do
           if object.has_attribute?(:creator_id)
             object.human_attribute_name('creator_id') + ' : ' + object.creator_id if object.creator_id
           end
        end),
        (content_tag :li do
           if object.has_attribute?(:objectid)
             object.human_attribute_name('objectid') + ' : ' + object.objectid if object.objectid
           end
        end),
        (content_tag :li do
           if object.has_attribute?(:object_version)
             object.human_attribute_name('object_version') + ' : ' + object.object_version.to_s if object.object_version
           end
        end)].join.html_safe
      end
    end
  end
  def history_tag(object)
    field_set_tag t("layouts.history_tag.title"), class: "history_tag" do
      content_tag :ul do
        [:created_at, :updated_at, :user_name, :no_save].each do |field|
          concat history_tag_li(object, field)
        end
      end
    end
  end
  protected
  def history_tag_li(object, field)
    if object.respond_to?(field)
      key = t("layouts.history_tag.#{field}")
      value = object.public_send(field)
      value = l(value, format: :short) if value.is_a?(Time)
      value = t(value.to_s) if value.in?([true, false])
      content_tag(:li, "#{key} : #{value}")
    end
  end
end
 |