Module: Hancock::Pages::Admin::Blockset

Defined in:
lib/hancock/pages/admin/blockset.rb

Class Method Summary collapse

Class Method Details

.config(nav_label = nil, 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
65
66
67
68
69
# File 'lib/hancock/pages/admin/blockset.rb', line 4

def self.config(nav_label = nil, fields = {})
  if nav_label.is_a?(Hash)
    nav_label, fields = nav_label[:nav_label], nav_label
  elsif nav_label.is_a?(Array)
    nav_label, fields = nil, nav_label
  end
  Proc.new {
    navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.pages'))

    field :enabled, :toggle do
      searchable false
    end
    field :text_slug do
      searchable true
    end
    field :name do
      searchable true
    end

    group :wrapper, &Hancock::Pages::Admin.wrapper_block
    # group :wrapper do
    #   active false
    #   field :use_wrapper, :toggle
    #   field :wrapper_tag, :string
    #   field :wrapper_class, :string
    #   field :wrapper_id, :string
    #   field :wrapper_attributes, :text do
    #     formatted_value do
    #       bindings[:object] and bindings[:object].wrapper_attributes ? bindings[:object].wrapper_attributes.to_json : "{}"
    #     end
    #   end
    # end

    group :blocks do
      active false
      field :blocks do
        searchable :name
      end
    end

    Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)

    # field :blocks do
    #   read_only true
    #   help 'Список блоков'
    #
    #   pretty_value do
    #     bindings[:object].blocks.to_a.map { |b|
    #       route = (bindings[:view] || bindings[:controller])
    #       model_name = b.rails_admin_model
    #       route.link_to(b.name, route.rails_admin.show_path(model_name: model_name, id: b.id), title: b.name)
    #     }.join("<br>").html_safe
    #   end
    # end

    sort_embedded(
        {
            fields: [:blocks]
        }
    )

    if block_given?
      yield self
    end
  }
end