Module: Enjoy::Goto::Admin::Transfer

Defined in:
lib/enjoy/goto/admin/transfer.rb

Class Method Summary collapse

Class Method Details

.config(fields = {}) ⇒ Object



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
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/enjoy/goto/admin/transfer.rb', line 4

def self.config(fields = {})
  Proc.new {
    if defined?(Enjoy::Feedback)
      navigation_label I18n.t('enjoy.feedback')
    else
      navigation_label I18n.t('enjoy.goto')
    end

    field :creator do
      filterable true
      pretty_value do
        unless bindings[:object].creator.blank?
          route = (bindings[:view] || bindings[:controller])
          creator = bindings[:object].creator
          model_name = creator.class.to_param.gsub("::", "~").underscore
          _url = route.rails_admin.show_path(model_name: model_name, id: creator._id)
          route.link_to(creator.name_for_enjoy_cms, _url, class: "creator_link")
        end
      end
    end
    field :created_at
    field :url do
      searchable true
      pretty_value do
        unless bindings[:object].url.blank?
          route = (bindings[:view] || bindings[:controller])
          _target = Addressable::URI.parse(bindings[:object].url).to_s
          route.link_to(_target, _target, title: _target, target: :_blank)
        end
      end
    end
    field :recieved_url
    field :host do
      searchable true
      pretty_value do
        unless bindings[:object].host.blank?
          route = (bindings[:view] || bindings[:controller])
          _target = Addressable::URI.parse(bindings[:object].host).to_s
          route.link_to(_target, _target, title: _target, target: :_blank)
        end
      end
    end
    field :referer do
      searchable true
      pretty_value do
        unless bindings[:object].referer.blank?
          route = (bindings[:view] || bindings[:controller])
          _target = Addressable::URI.parse(bindings[:object].referer).to_s
          route.link_to(_target, _target, title: _target, target: :_blank)
        end
      end
    end
    field :source_ip do
      searchable true
    end

    if block_given?
      yield self
    end
  }
end