Module: Hancock::Catalog::Admin::Item

Defined in:
lib/hancock/catalog/admin/item.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/hancock/catalog/admin/item.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.catalog"))

    list do
      scopes [:sorted, :enabled, nil]

      field :enabled, :toggle do
        searchable false
      end
      field :name do
        searchable true
      end
      field :categories do
        # searchable :name
      end
      if Hancock::Catalog.config.pages_support and Hancock::Catalog.configuration.can_connect_items_with_pages
        field :connected_pages, :hancock_connectable
      end

      group :content, &Hancock::Admin.content_block
      if Hancock::Catalog.config.cache_support
        group :caching, &Hancock::Cache::Admin.caching_block
      end
    end

    edit do
      field :enabled, :toggle
      field :name
      if Hancock::Catalog.config.pages_support and Hancock::Catalog.configuration.can_connect_items_with_pages
        group :connected_pages do
          active false
          field :connected_pages, :hancock_connectable do
            read_only do
              !bindings[:view].current_user.admin?
            end
          end
        end
      end
      group :categories, &Hancock::Admin.categories_block
      # group :categories do
      #   active false
      #   field :main_category do
      #     inline_add false
      #     inline_edit false
      #   end
      #   field :categories, :hancock_multiselect
      # end
      field :price, :string
      # field :price, :money_field

      group :URL, &Hancock::Admin.url_block
      # group :URL do
      #   active false
      #   field :slugs, :hancock_slugs
      #   field :text_slug
      # end

      if Hancock::Catalog.config.gallery_support
        group :image, &Hancock::Gallery::Admin.images_block(:item_images)
        # group :image do
        #   active false
        #   field :image, :hancock_image
        #   field :item_images
        # end
      end


      group :content, &Hancock::Admin.content_block
      # group :content do
      #   active false
      #   field :excerpt, :hancock_html
      #   field :content, :hancock_html
      # end

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

      if Hancock::Catalog.config.seo_support
        group :seo_n_sitemap, &Hancock::Seo::Admin.seo_n_sitemap_block
      end
      # if Hancock::Catalog.config.seo_support
      #   group :seo do
      #     active false
      #     field :seo
      #   end
      #   group :sitemap_data do
      #     active false
      #     field :sitemap_data
      #   end
      # end

      if Hancock::Catalog.config.cache_support
        group :caching, &Hancock::Cache::Admin.caching_block
      end

      if Hancock::Catalog.config.insertions_support
        group :insertions, &Hancock::Admin.insertions_block
      end
    end

    nested_set({max_depth: 1, scopes: []})

    sort_embedded(
        {
            fields: [:item_images]
        }
    )

    if defined?(RailsAdminMultipleFileUpload)
      multiple_file_upload(
          {
              fields: [:item_images]
          }
      )
    end

    if block_given?
      yield self
    end
  }
end