ecm_products 0.0.7.pre → 2.0.6.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. data/app/models/ecm/products/product.rb +51 -42
  2. data/app/models/ecm/products/product_category.rb +6 -7
  3. data/app/models/ecm/products/product_link.rb +1 -0
  4. data/app/models/ecm/products/product_picture.rb +56 -0
  5. data/app/views/ecm/products/product_pictures/_product_picture.html.erb +10 -0
  6. data/app/views/ecm/products/products/_product_details.html.erb +18 -7
  7. data/config/locales/ecm.products.de.yml +1 -0
  8. data/config/locales/ecm.products.en.yml +1 -0
  9. data/config/locales/ecm.products.product.de.yml +31 -29
  10. data/config/locales/ecm.products.product.en.yml +31 -29
  11. data/config/locales/ecm.products.product_category.de.yml +27 -25
  12. data/config/locales/ecm.products.product_category.en.yml +27 -25
  13. data/config/locales/ecm.products.product_picture.de.yml +25 -0
  14. data/config/locales/ecm.products.product_picture.en.yml +25 -0
  15. data/config/locales/ecm.products.routes.de.yml +2 -0
  16. data/config/locales/ecm.products.routes.en.yml +2 -0
  17. data/db/migrate/002_create_ecm_products_products.rb +1 -0
  18. data/db/migrate/004_create_ecm_products_product_pictures.rb +32 -0
  19. data/lib/ecm/products/active_admin/ecm_products_product_categories.rb +61 -39
  20. data/lib/ecm/products/active_admin/ecm_products_product_links.rb +16 -12
  21. data/lib/ecm/products/active_admin/ecm_products_product_pictures.rb +76 -0
  22. data/lib/ecm/products/active_admin/ecm_products_products.rb +80 -35
  23. data/lib/ecm/products/configuration.rb +35 -2
  24. data/lib/ecm/products/version.rb +1 -1
  25. data/lib/ecm_products.rb +1 -0
  26. data/lib/generators/ecm/products/install/templates/ecm_products.rb +46 -0
  27. data/lib/generators/ecm/products/locales/locales_generator.rb +3 -0
  28. data/lib/tasks/ecm_products_tasks.rake +118 -67
  29. metadata +70 -50
@@ -9,6 +9,7 @@ class CreateEcmProductsProducts < ActiveRecord::Migration
9
9
 
10
10
  # associations
11
11
  t.integer :ecm_products_product_links_count, :default => 0, :null => false
12
+ t.integer :ecm_products_product_pictures_count, :default => 0, :null => false
12
13
  t.references :ecm_products_product_category
13
14
 
14
15
  # acts as list
@@ -0,0 +1,32 @@
1
+ class CreateEcmProductsProductPictures < ActiveRecord::Migration
2
+ def change
3
+ create_table :ecm_products_product_pictures do |t|
4
+ t.string :name
5
+ t.text :description
6
+
7
+ # acts as list
8
+ t.integer :position
9
+
10
+ # acts as markup
11
+ t.string :markup_language
12
+
13
+ # friendly id
14
+ t.string :slug
15
+
16
+ # paperclip
17
+ # t.attachment :image
18
+ t.string :image_file_name
19
+ t.integer :image_file_size
20
+ t.string :image_content_type
21
+ t.timestamp :image_updated_at
22
+ t.string :image_fingerprint
23
+
24
+ # associations
25
+ t.references :ecm_products_product
26
+
27
+ t.timestamps
28
+ end
29
+ add_index :ecm_products_product_pictures, :ecm_products_product_id
30
+ end
31
+ end
32
+
@@ -1,7 +1,13 @@
1
+ include ActiveAdmin::ActsAsList::Helper if defined?(ActiveAdmin)
2
+ include ActiveAdmin::AwesomeNestedSet::Helper if defined?(ActiveAdmin)
3
+
1
4
  ::ActiveAdmin.register Ecm::Products::ProductCategory do
2
5
  # menu entry settings
3
6
  menu :parent => Proc.new { I18n.t('ecm.products.active_admin.menu') }.call
4
-
7
+
8
+ # awesome nested set
9
+ sortable_tree_member_actions
10
+
5
11
  form :html => { :enctype => "multipart/form-data" } do |f|
6
12
  f.inputs do
7
13
  f.input :parent, :as => :select, :collection => nested_set_options(Ecm::Products::ProductCategory, f.object) { |pc| "#{'&#160;&#160;&#160;&#160;' * pc.level} |-- #{pc.tree_name}".html_safe }
@@ -12,20 +18,21 @@
12
18
  f.input :preview_image, :as => :file, :hint => f.template.image_tag(f.object.preview_image.url(:medium_thumb))
13
19
  f.input :main_image, :as => :file, :hint => f.template.image_tag(f.object.main_image.url(:medium_thumb))
14
20
  end
15
-
21
+
16
22
  f.inputs do
17
- f.input :markup_language, :as => :select, :collection => Ecm::Products::ProductCategory::MARKUP_LANGUAGES
23
+ f.input :markup_language, :as => :select, :collection => Ecm::Products::Configuration.markup_languages
18
24
  end
19
-
25
+
20
26
  f.actions
21
27
  end
22
-
28
+
23
29
  index :as => :nested_set do
24
30
  selectable_column
31
+ sortable_tree_columns
25
32
  column :preview_image do |pc|
26
- link_to(image_tag(pc.preview_image.url(:small_thumb)), [:admin, pc], :style => "margin-left: #{50 * pc.level}px")
33
+ link_to(image_tag(pc.preview_image.url(:small_thumb)), [:admin, pc], :style => "margin-left: #{50 * pc.level}px")
27
34
  end
28
- column :locale
35
+ column :locale
29
36
  column :name
30
37
  column :short_description
31
38
  column :ecm_products_products_count
@@ -33,48 +40,63 @@
33
40
  column :updated_at
34
41
  default_actions
35
42
  end
36
-
37
- show do
38
- panel Ecm::Products::ProductCategory.human_attribute_name(:preview_image) do
39
- div { image_tag(ecm_products_product_category.preview_image.url) }
40
- end
41
-
42
- attributes_table do
43
- row :parent
44
- row :name
45
- row :ecm_products_products_count
46
- row :markup_language
47
- row :created_at
48
- row :updated_at
43
+
44
+ show :title => :to_s do
45
+ panel Ecm::Products::ProductCategory.human_attribute_name(:main_image) do
46
+ div { image_tag(ecm_products_product_category.main_image.url) }
47
+ end
48
+
49
+ panel Ecm::Products::ProductCategory.human_attribute_name(:children) do
50
+ table_for ecm_products_product_category.descendants, :i18n => Ecm::Products::ProductCategory do
51
+ sortable_tree_columns
52
+ column(:name) { |child| link_to child, [:admin, child], :style => "margin-left: #{30 * (child.level - ecm_products_product_category.level - 1)}px" }
53
+ column :short_description
54
+ column :ecm_products_products_count
55
+ column :created_at
56
+ column :updated_at
57
+ column do |child|
58
+ link_to(I18n.t('active_admin.view'), [:admin, child], :class => "member_link view_link") +
59
+ link_to(I18n.t('active_admin.edit'), [:edit, :admin, child], :class => "member_link edit_link")
60
+ end
61
+ end
62
+ end
63
+
64
+ panel Ecm::Products::ProductCategory.human_attribute_name(:short_description) do
65
+ div { ecm_products_product_category.short_description }
66
+ end
67
+
68
+ panel Ecm::Products::ProductCategory.human_attribute_name(:long_description) do
69
+ div { ecm_products_product_category.long_description }
49
70
  end
50
-
71
+
51
72
  panel Ecm::Products::ProductCategory.human_attribute_name(:ecm_products_products) do
52
73
  table_for ecm_products_product_category.ecm_products_products, :i18n => Ecm::Products::Product do
74
+ sortable_columns
53
75
  column :preview_image do |p|
54
- link_to(image_tag(p.preview_image.url(:medium_thumb)), [:admin, p])
55
- end
56
- column :ecm_products_product_category
76
+ link_to(image_tag(p.preview_image.url(:medium_thumb)), [:admin, p])
77
+ end
57
78
  column :name
58
79
  column :short_description
59
80
  column :created_at
60
81
  column :updated_at
61
82
  column do |p|
62
83
  link_to(I18n.t('active_admin.view'), admin_ecm_products_product_path(p), :class => "member_link view_link") +
63
- link_to(I18n.t('active_admin.edit'), edit_admin_ecm_products_product_path(p), :class => "member_link edit_link")
84
+ link_to(I18n.t('active_admin.edit'), edit_admin_ecm_products_product_path(p), :class => "member_link edit_link")
64
85
  end
65
86
  end
66
- end
67
-
68
- panel Ecm::Products::ProductCategory.human_attribute_name(:main_image) do
69
- div { image_tag(ecm_products_product_category.main_image.url) }
70
- end
71
-
72
- panel Ecm::Products::ProductCategory.human_attribute_name(:short_description) do
73
- div { ecm_products_product_category.short_description }
74
- end
75
-
76
- panel Ecm::Products::ProductCategory.human_attribute_name(:long_description) do
77
- div { ecm_products_product_category.long_description }
78
- end
79
- end
87
+ end
88
+ end # show
89
+
90
+ sidebar Ecm::Products::ProductCategory.human_attribute_name(:details), :only => :show do
91
+ div { image_tag(ecm_products_product_category.preview_image.url(:medium_thumb)) }
92
+ attributes_table_for ecm_products_product_category do
93
+ row :parent
94
+ row :name
95
+ row :ecm_products_products_count
96
+ row :markup_language
97
+ row :created_at
98
+ row :updated_at
99
+ end
100
+ end # sidebar
80
101
  end if defined?(::ActiveAdmin)
102
+
@@ -1,22 +1,25 @@
1
1
  ::ActiveAdmin.register Ecm::Products::ProductLink do
2
2
  # menu entry settings
3
3
  menu :parent => Proc.new { I18n.t('ecm.products.active_admin.menu') }.call
4
-
4
+
5
+ # acts as list
6
+ sortable_member_actions
7
+
5
8
  form do |f|
6
9
  f.inputs do
7
10
  f.input :ecm_products_product
8
11
  f.input :name
9
12
  f.input :url
10
- f.input :description
13
+ f.input :description
11
14
  end
12
-
15
+
13
16
  f.inputs do
14
- f.input :markup_language, :as => :select, :collection => Ecm::Products::ProductLink::MARKUP_LANGUAGES
17
+ f.input :markup_language, :as => :select, :collection => Ecm::Products::Configuration.markup_languages
15
18
  end
16
-
19
+
17
20
  f.actions
18
- end
19
-
21
+ end
22
+
20
23
  index do
21
24
  selectable_column
22
25
  column :ecm_products_product
@@ -25,8 +28,8 @@
25
28
  column :url
26
29
  default_actions
27
30
  end
28
-
29
- show do
31
+
32
+ show do
30
33
  attributes_table do
31
34
  row :ecm_products_product
32
35
  row :name
@@ -35,11 +38,12 @@
35
38
  end
36
39
  row :markup_language
37
40
  row :created_at
38
- row :updated_at
41
+ row :updated_at
39
42
  end
40
-
43
+
41
44
  panel Ecm::Products::ProductLink.human_attribute_name(:description) do
42
45
  div { ecm_products_product_link.description }
43
- end
46
+ end
44
47
  end
45
48
  end if defined?(::ActiveAdmin)
49
+
@@ -0,0 +1,76 @@
1
+ include ActiveAdmin::ActsAsList::Helper if defined?(::ActiveAdmin)
2
+
3
+ ::ActiveAdmin.register Ecm::Products::ProductPicture do
4
+ # menu entry settings
5
+ menu :parent => Proc.new { I18n.t('ecm.products.active_admin.menu') }.call
6
+
7
+ # acts as list
8
+ sortable_member_actions
9
+
10
+ form :html => { :enctype => "multipart/form-data" } do |f|
11
+ f.inputs do
12
+ f.input :ecm_products_product
13
+ f.input :name
14
+ f.input :image, :as => :file,
15
+ :hint => f.template.image_tag(f.object.image.url(:medium_thumb))
16
+ f.input :description
17
+ end
18
+
19
+ f.inputs do
20
+ f.input :markup_language, :as => :select, :collection => Ecm::Products::Configuration.markup_languages
21
+ end
22
+ f.actions
23
+ end
24
+
25
+ index do
26
+ selectable_column
27
+ column :thumbnail do |pp|
28
+ link_to(image_tag(pp.image.url(:medium_thumb)), [:admin, pp])
29
+ end
30
+ column :ecm_products_product
31
+ column :name
32
+ column :description
33
+ column :created_at
34
+ column :updated_at
35
+ default_actions
36
+ end
37
+
38
+ show do
39
+ panel Ecm::Products::ProductPicture.human_attribute_name(:image) do
40
+ div { image_tag(ecm_products_product_picture.image.url) }
41
+ end
42
+
43
+ attributes_table do
44
+ row :name
45
+ row :markup_language
46
+ row :image_file_name
47
+ row :image_file_size do |pp|
48
+ number_to_human_size(pp.image_file_size)
49
+ end
50
+ row :image_content_type
51
+ row :image_updated_at
52
+ row :image_fingerprint
53
+ row :created_at
54
+ row :updated_at
55
+ end
56
+
57
+ panel Ecm::Products::ProductPicture.human_attribute_name(:description) do
58
+ div { ecm_products_product_picture.description }
59
+ end
60
+ end # show
61
+
62
+ sidebar Ecm::Products::ProductPicture.human_attribute_name(:ecm_products_product), :only => :show do
63
+ div { image_tag(ecm_products_product_picture.ecm_products_product.preview_image.url(:medium_thumb)) }
64
+ attributes_table_for ecm_products_product_picture.ecm_products_product do
65
+ row(:name) { |p| link_to(p.name, [:admin, p]) }
66
+ row :ecm_products_product_category
67
+ row(:price) { |p| humanized_money_with_symbol p.price }
68
+ row(:price_on_application) { |p| I18n.t(p.price_on_application) }
69
+ row :published_at
70
+ row :markup_language
71
+ row :created_at
72
+ row :updated_at
73
+ end
74
+ end # sidebar
75
+ end if defined?(::ActiveAdmin)
76
+
@@ -1,7 +1,12 @@
1
+ include ActiveAdmin::ActsAsList::Helper if defined?(ActiveAdmin)
2
+
1
3
  ::ActiveAdmin.register Ecm::Products::Product do
2
4
  # menu entry settings
3
5
  menu :parent => Proc.new { I18n.t('ecm.products.active_admin.menu') }.call
4
-
6
+
7
+ # acts as list
8
+ sortable_member_actions
9
+
5
10
  form :html => { :enctype => "multipart/form-data" } do |f|
6
11
  f.inputs do
7
12
  f.input :ecm_products_product_category
@@ -12,67 +17,107 @@
12
17
  f.input :price_on_application
13
18
  f.input :published_at
14
19
  f.input :preview_image, :as => :file
15
- f.input :main_image, :as => :file
20
+ f.input :main_image, :as => :file
16
21
  end
17
-
22
+
18
23
  f.inputs do
19
- f.input :markup_language, :as => :select, :collection => Ecm::Products::Product::MARKUP_LANGUAGES
24
+ f.input :markup_language, :as => :select, :collection => Ecm::Products::Configuration.markup_languages
20
25
  end
21
-
26
+
27
+ f.inputs do
28
+ f.has_many :ecm_products_product_pictures do |pp|
29
+ if pp.object.persisted?
30
+ pp.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
31
+ end
32
+
33
+ # pp.inputs do
34
+ pp.input :name
35
+ pp.input :image, :as => :file,
36
+ :hint => pp.template.image_tag(pp.object.image.url(:medium_thumb))
37
+ pp.input :description
38
+ # end
39
+
40
+ # pp.inputs do
41
+ pp.input :markup_language, :as => :select, :collection => Ecm::Products::ProductPicture::MARKUP_LANGUAGES
42
+ # end
43
+ end # f.has_many
44
+ end
45
+
22
46
  f.actions
23
47
  end
24
-
48
+
25
49
  index do
26
50
  selectable_column
27
51
  column :preview_image do |p|
28
- link_to(image_tag(p.preview_image.url(:medium_thumb)), [:admin, p])
29
- end
30
- column :ecm_products_product_category
52
+ link_to(image_tag(p.preview_image.url(:medium_thumb)), [:admin, p])
53
+ end
54
+ column :ecm_products_product_category
31
55
  column :name
32
56
  column :short_description
33
57
  column :created_at
34
58
  column :updated_at
35
59
  default_actions
36
60
  end
37
-
61
+
38
62
  show do
39
- panel Ecm::Products::Product.human_attribute_name(:preview_image) do
40
- div { image_tag(ecm_products_product.preview_image.url) }
63
+ panel Ecm::Products::Product.human_attribute_name(:main_image) do
64
+ div { image_tag(ecm_products_product.main_image.url) }
41
65
  end
42
-
43
- attributes_table do
44
- row :ecm_products_product_category
45
- row :name
46
- row :price
47
- row :price_on_application
48
- row :published_at
49
- row :markup_language
50
- row :created_at
51
- row :updated_at
52
- end
53
-
54
- panel Ecm::Products::ProductLink.human_attribute_name(:ecm_products_product_links) do
66
+
67
+ panel Ecm::Products::Product.human_attribute_name(:ecm_products_product_pictures) do
68
+ table_for ecm_products_product.ecm_products_product_pictures, :i18n => Ecm::Products::ProductPicture do
69
+ sortable_columns
70
+
71
+ column :thumbnail do |pp|
72
+ link_to(image_tag(pp.image.url(:medium_thumb)), [:admin, pp])
73
+ end
74
+ column :name
75
+ column :description
76
+ column :created_at
77
+ column :updated_at
78
+
79
+ column do |pp|
80
+ link_to(I18n.t('active_admin.view'), [:admin, pp], :class => "member_link view_link") +
81
+ link_to(I18n.t('active_admin.edit'), [:edit, :admin, pp], :class => "member_link edit_link")
82
+ end
83
+ end
84
+ end
85
+
86
+ panel Ecm::Products::Product.human_attribute_name(:ecm_products_product_links) do
55
87
  table_for ecm_products_product.ecm_products_product_links, :i18n => Ecm::Products::ProductLink do
88
+ sortable_columns
89
+
56
90
  column :name
57
91
  column :description
58
92
  column :url
59
93
  column do |pl|
60
94
  link_to(I18n.t('active_admin.view'), admin_ecm_products_product_link_path(pl), :class => "member_link view_link") +
61
- link_to(I18n.t('active_admin.edit'), edit_admin_ecm_products_product_link_path(pl), :class => "member_link edit_link")
95
+ link_to(I18n.t('active_admin.edit'), edit_admin_ecm_products_product_link_path(pl), :class => "member_link edit_link")
62
96
  end
63
97
  end
64
- end
65
-
66
- panel Ecm::Products::Product.human_attribute_name(:main_image) do
67
- div { image_tag(ecm_products_product.main_image.url) }
68
- end
69
-
98
+ end
99
+
70
100
  panel Ecm::Products::Product.human_attribute_name(:short_description) do
71
101
  div { ecm_products_product.short_description }
72
- end
73
-
102
+ end
103
+
74
104
  panel Ecm::Products::Product.human_attribute_name(:long_description) do
75
105
  div { ecm_products_product.long_description }
76
- end
106
+ end
77
107
  end
108
+
109
+ sidebar Ecm::Products::Product.human_attribute_name(:details), :only => :show do
110
+ div { image_tag(ecm_products_product.preview_image.url(:medium_thumb)) }
111
+ attributes_table_for ecm_products_product do
112
+ row :ecm_products_product_category
113
+ row :name
114
+ row(:price) { |p| humanized_money_with_symbol p.price }
115
+ row(:price_on_application) { |p| I18n.t(p.price_on_application) }
116
+ row :published_at
117
+ row :markup_language
118
+ row :created_at
119
+ row :updated_at
120
+ end
121
+ end # sidebar
78
122
  end if defined?(::ActiveAdmin)
123
+
@@ -9,8 +9,41 @@ module Ecm
9
9
  yield self
10
10
  end
11
11
 
12
- # mattr_accessor :foo
13
- # @@foo = nil
12
+ mattr_accessor :markup_languages
13
+ @@markup_languages = []
14
+
15
+ mattr_accessor :default_markup_language
16
+ @@default_markup_language = nil
17
+
18
+ mattr_accessor :product_category_preview_image_styles
19
+ @@product_category_preview_image_styles = {}
20
+ def product_category_preview_image_styles=(product_category_preview_image_styles)
21
+ @@product_category_preview_image_styles = HashWithIndifferentAccess.new(product_category_preview_image_styles)
22
+ end
23
+
24
+ mattr_accessor :product_category_main_image_styles
25
+ @@product_category_main_image_styles = {}
26
+ def product_category_main_image_styles=(product_category_main_image_styles)
27
+ @@product_category_main_image_styles = HashWithIndifferentAccess.new(product_category_main_image_styles)
28
+ end
29
+
30
+ mattr_accessor :product_preview_image_styles
31
+ @@product_preview_image_styles = {}
32
+ def product_preview_image_styles=(product_preview_image_styles)
33
+ @@product_preview_image_styles = HashWithIndifferentAccess.new(product_preview_image_styles)
34
+ end
35
+
36
+ mattr_accessor :product_main_image_styles
37
+ @@product_main_image_styles = {}
38
+ def product_main_image_styles=(product_main_image_styles)
39
+ @@product_main_image_styles = HashWithIndifferentAccess.new(product_main_image_styles)
40
+ end
41
+
42
+ mattr_accessor :product_picture_image_styles
43
+ @@product_picture_image_styles = {}
44
+ def product_picture_image_styles=(product_picture_image_styles)
45
+ @@product_picture_image_styles = HashWithIndifferentAccess.new(product_picture_image_styles)
46
+ end
14
47
  end
15
48
  end
16
49
  end
@@ -1,5 +1,5 @@
1
1
  module ECM
2
2
  module Products
3
- VERSION = "0.0.7.pre"
3
+ VERSION = "2.0.6.pre"
4
4
  end
5
5
  end
data/lib/ecm_products.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_admin-acts_as_list'
1
2
  require 'active_admin-awesome_nested_set'
2
3
  require 'acts_as_list'
3
4
  # require 'acts_as_published'
@@ -1,2 +1,48 @@
1
1
  Ecm::Products.configure do |config|
2
+ # markup options
3
+
4
+ # Accepted markup languages
5
+ config.markup_languages = %w[ markdown rdoc textile ]
6
+
7
+ # Default markup language
8
+ config.default_markup_language = 'textile'
9
+
10
+ # product category options
11
+
12
+ # image sizes for product category preview images
13
+ config.product_category_preview_image_styles = {
14
+ :small_thumb => "64x48",
15
+ :medium_thumb => "160x120",
16
+ :big_thumb => "360x268"
17
+ }
18
+
19
+ # image sizes for product category main images
20
+ config.product_category_main_image_styles = {
21
+ :medium_thumb => "160x120",
22
+ :big_thumb => "360x268"
23
+ }
24
+
25
+ # product options
26
+
27
+ # image sizes for product preview images
28
+ config.product_preview_image_styles = {
29
+ :medium_thumb => "160x120",
30
+ :big_thumb => "360x268"
31
+ }
32
+
33
+ # image sizes for product main images
34
+ config.product_main_image_styles = {
35
+ :medium_thumb => "160x120",
36
+ :big_thumb => "360x268"
37
+ }
38
+
39
+ # product picture options
40
+
41
+ # image sizes for slider items
42
+ config.product_picture_image_styles = {
43
+ :small_thumb => "80x60",
44
+ :medium_thumb => "160x120",
45
+ :default => "260x180"
46
+ }
2
47
  end
48
+
@@ -21,6 +21,9 @@ module Ecm
21
21
 
22
22
  copy_file "ecm.products.product_link.en.yml", "config/locales/ecm.products.product_link.en.yml"
23
23
  copy_file "ecm.products.product_link.de.yml", "config/locales/ecm.products.product_link.de.yml"
24
+
25
+ copy_file "ecm.products.product_picture.en.yml", "config/locales/ecm.products.product_picture.en.yml"
26
+ copy_file "ecm.products.product_picture.de.yml", "config/locales/ecm.products.product_picture.de.yml"
24
27
  end
25
28
  end
26
29
  end