enjoy_cms_catalog 0.2.0.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 114464bfa249ce351c0a6e890748ac8d247a59b2
4
- data.tar.gz: 1f18915d49ee5b3d2672f97f55855e978692e1b7
3
+ metadata.gz: 38d3f0bc0de2667ad75dfc5647106c3a83e6843c
4
+ data.tar.gz: 55f3ecc1ede6616068a73837e5289fbda08ab315
5
5
  SHA512:
6
- metadata.gz: 759949488d235e315a7457807aaf99ce6c651753db138d9eff8a24263b1108ad8c10ed0a7f5a0b8a1aa24a0c67e025d22e8ad00fa4861f54906fca3c3e12b0f3
7
- data.tar.gz: 15d6238782d5ca34b5c68d1616ac1010384160bfc053f27ef8926548c6ae55ceea029f1f27d5f21c469d7920f9d359c0d60b3d98af3182ce48e4525d62fd673b
6
+ metadata.gz: 889ecc3bcb16e643ebc714c0234a919bfd974c576d1b580fbc7c8495dd93c8ae39ff84dad51818531627f902036f4cfd656aa83a4b161fda140017f884e69b8d
7
+ data.tar.gz: 22592e5f748586af88081a69d6b511f645f6b4fb77105d77a2427cd13fa158f9504c99783682143c8ecffeaa62f68e88a3b1ceed9434b3d14146b2b894741687
@@ -0,0 +1,5 @@
1
+ module Enjoy::Catalog::Decorators
2
+ module ItemCategories
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy::Catalog::Decorators
2
+ module Items
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -1,5 +1,7 @@
1
1
  module Enjoy::Catalog
2
2
  class ItemCategoriesController < ApplicationController
3
3
  include Enjoy::Catalog::Controllers::ItemCategories
4
+
5
+ include Enjoy::Catalog::Decorators::ItemCategories
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
1
  module Enjoy::Catalog
2
2
  class ItemsController < ApplicationController
3
3
  include Enjoy::Catalog::Controllers::Items
4
+
5
+ include Enjoy::Catalog::Decorators::Items
4
6
  end
5
7
  end
@@ -31,12 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "bundler", "~> 1.10"
32
32
  spec.add_development_dependency "rake", "~> 10.0"
33
33
 
34
- spec.add_dependency 'rails', '>= 4.1.0', '< 5.0'
35
-
36
34
  spec.add_dependency 'money-rails'
37
35
  spec.add_dependency 'mongoid_money_field'
38
36
 
39
- spec.add_dependency 'enjoy_cms'
40
- spec.add_dependency 'rails_admin_sort_embedded'
41
- spec.add_dependency 'ack_rails_admin_jcrop'
37
+ spec.add_dependency 'enjoy_cms', "~> 0.3.0"
42
38
  end
@@ -34,8 +34,8 @@ module Enjoy::Catalog
34
34
  end
35
35
  end
36
36
  field :item_categories
37
- field :excerpt, :ck_editor
38
- field :content, :ck_editor
37
+ field :excerpt, :enjoy_html
38
+ field :content, :enjoy_html
39
39
 
40
40
  field :item_images
41
41
 
@@ -15,8 +15,10 @@ module Enjoy::Catalog
15
15
  read_only true
16
16
 
17
17
  pretty_value do
18
- bindings[:object].items.to_a.map { |h|
19
- (bindings[:view] || bindings[:controller]).link_to(h.name, (bindings[:view] || bindings[:controller]).rails_admin.show_path(model_name: "item", id: h.id), title: h.name)
18
+ bindings[:object].items.to_a.map { |i|
19
+ route = (bindings[:view] || bindings[:controller])
20
+ model_name = i.rails_admin_model
21
+ route.link_to(i.name, route.rails_admin.show_path(model_name: model_name, id: i.id), title: i.name)
20
22
  }.join("<br>").html_safe
21
23
  end
22
24
  end
@@ -42,8 +44,8 @@ module Enjoy::Catalog
42
44
  :image_jcrop_options
43
45
  end
44
46
  end
45
- field :excerpt, :ck_editor
46
- field :content, :ck_editor
47
+ field :excerpt, :enjoy_html
48
+ field :content, :enjoy_html
47
49
 
48
50
  field :item_category_images
49
51
 
@@ -77,8 +79,10 @@ module Enjoy::Catalog
77
79
  help 'Список товаров'
78
80
 
79
81
  pretty_value do
80
- bindings[:object].items.to_a.map { |h|
81
- (bindings[:view] || bindings[:controller]).link_to(h.name, (bindings[:view] || bindings[:controller]).rails_admin.edit_path(model_name: "item", id: h.id), title: h.name)
82
+ bindings[:object].items.to_a.map { |i|
83
+ route = (bindings[:view] || bindings[:controller])
84
+ model_name = i.rails_admin_model
85
+ route.link_to(i.name, route.rails_admin.show_path(model_name: model_name, id: i.id), title: i.name)
82
86
  }.join("<br>").html_safe
83
87
  end
84
88
  end
@@ -108,8 +112,10 @@ module Enjoy::Catalog
108
112
  read_only true
109
113
 
110
114
  pretty_value do
111
- bindings[:object].items.to_a.map { |h|
112
- (bindings[:view] || bindings[:controller]).link_to(h.name, (bindings[:view] || bindings[:controller]).rails_admin.show_path(model_name: "item", id: h.id), title: h.name)
115
+ bindings[:object].items.to_a.map { |i|
116
+ route = (bindings[:view] || bindings[:controller])
117
+ model_name = i.rails_admin_model
118
+ route.link_to(i.name, route.rails_admin.show_path(model_name: model_name, id: i.id), title: i.name)
113
119
  }.join("<br>").html_safe
114
120
  end
115
121
  end
@@ -4,7 +4,7 @@ module Enjoy::Catalog
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def index
7
- @items = item_class.enabled.sorted.to_a
7
+ @z = item_class.enabled.sorted.to_a
8
8
  # index_crumbs
9
9
  end
10
10
 
@@ -26,15 +26,6 @@ module Enjoy::Catalog
26
26
  def clean_content
27
27
  Rails::Html::FullSanitizer.new.sanitize(self.content.strip)
28
28
  end
29
-
30
- module ClassMethods
31
- def rails_admin_add_fields
32
- {}
33
- end
34
-
35
- def rails_admin_add_config(config)
36
- end
37
- end
38
29
  end
39
30
  end
40
31
  end
@@ -27,23 +27,6 @@ module Enjoy::Catalog
27
27
  Enjoy::Catalog::Item
28
28
  end
29
29
 
30
- def items
31
- item_class.in(item_category_ids: self.id)
32
- end
33
-
34
- def all_items
35
- item_class.any_in(item_category_ids: self.self_and_descendants.map(&:id))
36
- end
37
-
38
- module ClassMethods
39
- def rails_admin_add_fields
40
- {}
41
- end
42
-
43
- def rails_admin_add_config(config)
44
- end
45
- end
46
-
47
30
  end
48
31
  end
49
32
  end
@@ -9,15 +9,6 @@ module Enjoy::Catalog
9
9
 
10
10
  included do
11
11
  end
12
-
13
- module ClassMethods
14
- def rails_admin_add_fields
15
- {}
16
- end
17
-
18
- def rails_admin_add_config(config)
19
- end
20
- end
21
12
  end
22
13
  end
23
14
  end
@@ -9,15 +9,6 @@ module Enjoy::Catalog
9
9
 
10
10
  included do
11
11
  end
12
-
13
- module ClassMethods
14
- def rails_admin_add_fields
15
- {}
16
- end
17
-
18
- def rails_admin_add_config(config)
19
- end
20
- end
21
12
  end
22
13
  end
23
14
  end
@@ -5,9 +5,9 @@ module Enjoy::Catalog
5
5
  extend ActiveSupport::Concern
6
6
  include Enjoy::MongoidPaperclip
7
7
 
8
- included do
9
- # default_scope -> { unscoped.any_of( {_type: nil}, {type: ""}, {_type: "Enjoy::Catalog::Item"} ) }
8
+ include Enjoy::HtmlField
10
9
 
10
+ included do
11
11
  field :name, type: String, localize: Enjoy.configuration.localize, default: ""
12
12
 
13
13
  enjoy_cms_mongoid_attached_file(:image,
@@ -18,10 +18,11 @@ module Enjoy::Catalog
18
18
  acts_as_nested_set
19
19
  scope :sorted, -> { order_by([:lft, :asc]) }
20
20
 
21
- field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
22
- field :content, type: String, localize: Enjoy.configuration.localize, default: ""
21
+ enjoy_cms_html_field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
22
+ enjoy_cms_html_field :content, type: String, localize: Enjoy.configuration.localize, default: ""
23
23
 
24
24
  has_and_belongs_to_many :item_categories, class_name: "Enjoy::Catalog::ItemCategory", inverse_of: nil
25
+ alias :categories :item_categories
25
26
 
26
27
  embeds_many :item_images, cascade_callbacks: true, class_name: "Enjoy::Catalog::ItemImage"
27
28
  alias :images :item_images
@@ -5,6 +5,8 @@ module Enjoy::Catalog
5
5
  extend ActiveSupport::Concern
6
6
  include Enjoy::MongoidPaperclip
7
7
 
8
+ include Enjoy::HtmlField
9
+
8
10
  included do
9
11
  field :name, type: String, localize: Enjoy.configuration.localize, default: ""
10
12
 
@@ -16,14 +18,22 @@ module Enjoy::Catalog
16
18
  acts_as_nested_set
17
19
  scope :sorted, -> { order_by([:lft, :asc]) }
18
20
 
19
- field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
20
- field :content, type: String, localize: Enjoy.configuration.localize, default: ""
21
+ enjoy_cms_html_field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
22
+ enjoy_cms_html_field :content, type: String, localize: Enjoy.configuration.localize, default: ""
21
23
 
22
24
  embeds_many :item_category_images, cascade_callbacks: true, class_name: "Enjoy::Catalog::ItemCategoryImage"
23
25
  alias :images :item_category_images
24
26
  accepts_nested_attributes_for :item_category_images, allow_destroy: true
25
27
  end
26
28
 
29
+ def items
30
+ item_class.in(item_category_ids: self.id)
31
+ end
32
+
33
+ def all_items
34
+ item_class.any_in(item_category_ids: self.self_and_descendants.map(&:id))
35
+ end
36
+
27
37
  def image_styles
28
38
  Enjoy::Catalog.configuration.item_category_image_styles
29
39
  end
@@ -1,5 +1,5 @@
1
1
  module Enjoy
2
2
  module Catalog
3
- VERSION = "0.2.0.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms_catalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,26 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rails
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 4.1.0
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '5.0'
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 4.1.0
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: '5.0'
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: money-rails
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -90,44 +70,16 @@ dependencies:
90
70
  name: enjoy_cms
91
71
  requirement: !ruby/object:Gem::Requirement
92
72
  requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: rails_admin_sort_embedded
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :runtime
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: ack_rails_admin_jcrop
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
73
+ - - "~>"
122
74
  - !ruby/object:Gem::Version
123
- version: '0'
75
+ version: 0.3.0
124
76
  type: :runtime
125
77
  prerelease: false
126
78
  version_requirements: !ruby/object:Gem::Requirement
127
79
  requirements:
128
- - - ">="
80
+ - - "~>"
129
81
  - !ruby/object:Gem::Version
130
- version: '0'
82
+ version: 0.3.0
131
83
  description: Items catalog with EnjoyCMS support.
132
84
  email:
133
85
  - dev@enjoycreate.ru
@@ -144,6 +96,8 @@ files:
144
96
  - Rakefile
145
97
  - app/assets/javascripts/enjoy_cms_catalog/enjoy_cms_catalog.coffee
146
98
  - app/assets/stylesheets/enjoy_cms_catalog/enjoy_cms_catalog.sass
99
+ - app/controllers/concerns/enjoy/catalog/decorators/item_categories.rb
100
+ - app/controllers/concerns/enjoy/catalog/decorators/items.rb
147
101
  - app/controllers/enjoy/catalog/item_categories_controller.rb
148
102
  - app/controllers/enjoy/catalog/items_controller.rb
149
103
  - app/models/concerns/enjoy/catalog/decorators/item.rb