c80_yax 0.1.0.1 → 0.1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/README.md +50 -13
  5. data/app/admin/c80_yax/cats.rb +47 -0
  6. data/app/admin/c80_yax/items.rb +36 -30
  7. data/app/admin/c80_yax/lib/custom_columns.rb +37 -0
  8. data/app/admin/c80_yax/prop_names.rb +13 -9
  9. data/app/admin/c80_yax/strsubcats.rb +114 -57
  10. data/app/admin/c80_yax/vendors.rb +39 -0
  11. data/app/assets/javascripts/backend/items.js +1 -1
  12. data/app/assets/javascripts/backend/strsubcats.js +26 -0
  13. data/app/assets/javascripts/c80_yax.js.coffee +3 -1
  14. data/app/assets/javascripts/lib_backend/custom_columns.js +73 -0
  15. data/app/assets/javascripts/lib_backend/init.js +28 -0
  16. data/app/assets/javascripts/lib_backend/loading.js +8 -0
  17. data/app/assets/stylesheets/c80_yax/_mixins/_colors.scss +1 -0
  18. data/app/assets/stylesheets/c80_yax/_mixins/color_button.scss +31 -0
  19. data/app/assets/stylesheets/c80_yax/_mixins/shdw.scss +10 -0
  20. data/app/assets/stylesheets/c80_yax/backend/active_admin/admin_items.scss +1 -1
  21. data/app/assets/stylesheets/c80_yax/backend/collapsed.scss +1 -1
  22. data/app/assets/stylesheets/c80_yax/elems/add_to_bucket.scss +11 -0
  23. data/app/assets/stylesheets/c80_yax/lib/bootstrap_checkboxes.scss +58 -0
  24. data/app/assets/stylesheets/c80_yax/lib_custom/bootstrap_checkboxes.scss +6 -0
  25. data/app/assets/stylesheets/c80_yax.scss +1 -0
  26. data/app/assets/stylesheets/c80_yax_backend.scss +2 -1
  27. data/app/helpers/c80_yax/items/asterix_helper.rb +13 -0
  28. data/app/helpers/c80_yax/items/buy_options_helper.rb +33 -0
  29. data/app/helpers/c80_yax/items/item_view_helper.rb +24 -0
  30. data/app/helpers/c80_yax/items/photos/item_photos_helper.rb +43 -0
  31. data/app/helpers/c80_yax/items/render_show_item_helper.rb +17 -0
  32. data/app/helpers/c80_yax/prop_name_helper.rb +11 -0
  33. data/app/helpers/c80_yax/strsubcats/props_helper.rb +81 -0
  34. data/app/helpers/c80_yax/uom_helper.rb +19 -0
  35. data/app/models/c80_yax/cat.rb +25 -0
  36. data/app/models/c80_yax/common_prop.rb +51 -0
  37. data/app/models/c80_yax/concerns/props/parsable.rb +129 -0
  38. data/app/models/c80_yax/item.rb +3 -1
  39. data/app/models/c80_yax/item_observer.rb +29 -0
  40. data/app/models/c80_yax/main_prop.rb +37 -0
  41. data/app/models/c80_yax/mixins/item/database/props.rb +66 -0
  42. data/app/models/c80_yax/mixins/strsubcat/database/prop_names_changed.rb +56 -0
  43. data/app/models/c80_yax/mixins/strsubcat/database/props.rb +37 -0
  44. data/app/models/c80_yax/prefix_prop.rb +35 -0
  45. data/app/models/c80_yax/price_prop.rb +47 -0
  46. data/app/models/c80_yax/prop_name.rb +4 -4
  47. data/app/models/c80_yax/strsubcat.rb +38 -23
  48. data/app/models/c80_yax/strsubcat_observer.rb +47 -0
  49. data/app/models/c80_yax/vendor.rb +16 -0
  50. data/app/views/admin/strsubcats/_view.html.erb +40 -0
  51. data/app/views/c80_yax/items/_buy_options.html.erb +9 -0
  52. data/c80_yax.gemspec +3 -0
  53. data/config/locales/ru.yml +33 -6
  54. data/db/migrate/20161030225354_create_c80_yax_items.rb +2 -0
  55. data/db/migrate/20170620111100_create_c80_yax_cats.rb +11 -0
  56. data/db/migrate/20170620111401_create_c80_yax_join_table_cats_strsubcats.rb +12 -0
  57. data/db/migrate/20170620164848_create_c80_yax_price_props.rb +9 -0
  58. data/db/migrate/20170620164949_create_c80_yax_join_table_price_props_prop_names.rb +12 -0
  59. data/db/migrate/20170620183838_create_c80_yax_main_props.rb +8 -0
  60. data/db/migrate/20170620195757_create_c80_yax_join_table_main_props_prop_names.rb +12 -0
  61. data/db/migrate/20170620200707_create_c80_yax_common_props.rb +8 -0
  62. data/db/migrate/20170620200808_create_c80_yax_join_table_common_props_prop_names.rb +12 -0
  63. data/db/migrate/20170621170202_create_c80_yax_prefix_props.rb +8 -0
  64. data/db/migrate/20170621170808_create_c80_yax_join_table_prefix_props_prop_names.rb +12 -0
  65. data/db/migrate/20170622193535_create_c80_yax_vendors.rb +11 -0
  66. data/db/migrate/20170622194040_create_c80_yax_join_table_items_vendors.rb +12 -0
  67. data/lib/c80_yax/engine.rb +2 -0
  68. data/lib/c80_yax/strsubcat_runtime_tables.rb +668 -0
  69. data/lib/c80_yax/version.rb +1 -1
  70. data/lib/c80_yax.rb +4 -2
  71. data/lib/generators/c80_yax/install_generator.rb +20 -0
  72. data/lib/generators/c80_yax/templates/app/helpers/c80_yax/items/show_item_helper.rb +21 -0
  73. metadata +98 -4
  74. data/app/assets/stylesheets/c80_yax/mixins.scss +0 -89
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5f41616e959e6eadcab3ecee39303ac308d57d3
4
- data.tar.gz: f74adf0891bfeb16286ca6c356538fa5e3bc8698
3
+ metadata.gz: 74f206b661d9c2327e4e9f26b94b7d787593230a
4
+ data.tar.gz: 0b70a2734ea7e66e2ce0fcc72b52bbba1a1dffa7
5
5
  SHA512:
6
- metadata.gz: ae1f05a7b8ebbc262fe8479f77d3b305bf5bc73d7c1721eb303ef04c25fb9a18a885942bc9c095886ec106ffcb6f8313e2874b64579bb16e9ec086eee4013de2
7
- data.tar.gz: 0aeed6d233f00f6c422fde87ee219741e2feb0fdd1227ec44ea1e4976e44d04bb267b4a68c0dd0bb3f5e96207e5ae1505e66fe2dd31afe93bff0c01a6703004e
6
+ metadata.gz: 8106e294dc7c8a9175cde3c26cbe0fc79d0d0f7a4f95ee4f2141270df3b0a476e201b15f58582026b44aa27ef6f3f00923ef4cbc373fc25dddd90801b9a380aa
7
+ data.tar.gz: 7fa219ce73051ce3e0431feacbcffb0629d1cf9d45565d88deba6f75ebc88a280aa149b5699bfc41fe9d1dd3dfe33baf7c5c6c311c5a9635ee692675ac0d9a98
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ c80_yax
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.3
data/README.md CHANGED
@@ -6,36 +6,73 @@ TODO: Delete this and the text above, and describe your gem
6
6
 
7
7
  ## Installation
8
8
 
9
- Add this line to your application's Gemfile:
9
+ Add this line to your application's `Gemfile`:
10
10
 
11
11
  ```ruby
12
12
  gem 'c80_yax'
13
13
  ```
14
14
 
15
+ Add dependencies to app's `Gemfile`:
16
+
17
+ ```ruby
18
+ gem 'rails', '4.2.0'
19
+ gem 'mysql2', '~> 0.3.18'
20
+
21
+ gem 'execjs'
22
+ gem 'therubyracer'
23
+
24
+ gem 'activeadmin'
25
+ gem 'devise'
26
+ gem 'cancan' # or cancancan
27
+ gem 'draper'
28
+ gem 'pundit'
29
+
30
+ gem 'font-awesome-rails'
31
+ gem 'friendly_id'
32
+ gem 'babosa'
33
+
34
+ gem 'bootstrap-select-rails'
35
+ gem 'c80_md'
36
+ gem 'c80_yax'
37
+
38
+ ```
39
+
15
40
  And then execute:
16
41
 
17
42
  $ bundle
18
43
 
19
- Or install it yourself as:
44
+ Add to app's `active_admin.js.coffee`:
20
45
 
21
- $ gem install c80_yax
22
-
23
- ## Usage
46
+ ```coffee
47
+ #= require bootstrap
48
+ #= require bootstrap-select
49
+ #= require c80_yax
50
+ ```
24
51
 
25
- TODO: Write usage instructions here
52
+ Add to app's `active_admin.scss`:
26
53
 
27
- ## Development
54
+ ```scss
55
+ @import "font-awesome";
56
+ @import "bootstrap-sprockets";
57
+ @import "bootstrap";
58
+ @import "bootstrap-select";
59
+ @import "mat_design";
60
+ @import "c80_yax_backend";
61
+ ```
28
62
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
+ Add to app's `application_controller.rb`:
30
64
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
+ ```ruby
66
+ helper C80Yax::Engine.helpers
67
+ ```
32
68
 
33
- ## Contributing
69
+ Add to app's `routes.rb`:
34
70
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/c80_yax. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
71
+ ```ruby
72
+ mount C80Yax::Engine => '/'
73
+ ```
36
74
 
75
+ ## Usage
37
76
 
38
- ## License
39
77
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
78
 
@@ -0,0 +1,47 @@
1
+ # ПОДкатегории строительных материалов
2
+ ActiveAdmin.register C80Yax::Cat, as: 'Cat' do
3
+
4
+ menu :label => proc{ I18n.t('c80_yax.active_admin.menu.cat')},
5
+ :parent => 'x_c80_yax',
6
+ :priority => 1
7
+
8
+ permit_params :title,
9
+ :slug,
10
+ :ord,
11
+ :strsubcat_ids => []
12
+
13
+ config.batch_actions = false
14
+ config.sort_order = 'id_asc'
15
+ before_filter :skip_sidebar!, :only => :index
16
+
17
+ index do
18
+ id_column
19
+ column :ord
20
+ column :title
21
+
22
+ column :strsubcats do |cat|
23
+ res = '-'
24
+ if cat.strsubcats.count > 0
25
+ res = ''
26
+ cat.strsubcats.map do |strsubcat|
27
+ res += "• #{strsubcat.title}<br>"
28
+ end
29
+ end
30
+ res.html_safe
31
+ end
32
+
33
+ actions
34
+ end
35
+
36
+ form(:html => {:multipart => true}) do |f|
37
+
38
+ f.inputs 'Свойства категории' do
39
+ f.input :title
40
+ f.input :ord
41
+ f.input :strsubcats, :as => :check_boxes
42
+ end
43
+
44
+ f.actions
45
+ end
46
+
47
+ end
@@ -1,9 +1,9 @@
1
1
  # категории строительных материалов
2
2
  ActiveAdmin.register C80Yax::Item, as: 'Item' do
3
3
 
4
- menu :label => proc { I18n.t('c80_yax.active_admin.menu.item') },
4
+ menu :label => proc {I18n.t('c80_yax.active_admin.menu.item')},
5
5
  :parent => 'x_c80_yax',
6
- :priority => 2
6
+ :priority => 3
7
7
 
8
8
 
9
9
  permit_params :title,
@@ -17,16 +17,16 @@ ActiveAdmin.register C80Yax::Item, as: 'Item' do
17
17
  :is_available,
18
18
  :strsubcat_id,
19
19
  :iphotos_attributes => [:id, :image, :_destroy],
20
- :item_props_attributes => [:value, :_destroy, :prop_name_id, :id]#,
21
- # :vendor_ids => [],
20
+ :item_props_attributes => [:value, :_destroy, :prop_name_id, :id],
21
+ :vendor_ids => []
22
22
  # :gallery_ids => [],
23
23
  # :related_child_ids => []
24
24
 
25
25
  config.sort_order = 'id_asc'
26
26
 
27
- # controller do
28
- # cache_sweeper :item_sweeper, :only => [:update,:create,:destroy]
29
- # end
27
+ controller do
28
+ C80Yax::Item.add_observer(C80Yax::ItemObserver.instance)
29
+ end
30
30
 
31
31
  # action_item :dublcate_item, :only => :edit do
32
32
  # link_to 'Клонировать', '', class:'dublicate_item'#, method: :post # эта ссылка обработается ajax-ом
@@ -35,43 +35,36 @@ ActiveAdmin.register C80Yax::Item, as: 'Item' do
35
35
  index do
36
36
  selectable_column
37
37
  id_column
38
-
38
+
39
39
  column :iphotos do |item|
40
- r = ''
41
- if item.iphotos.count > 0
42
- r = link_to image_tag(item.iphotos.first.image.thumb_md,
43
- style: 'width:150px'),
44
- item.iphotos.first.image.url,
45
- target: '_blank'
46
- r = "#{r}<br>Всего фотографий: #{item.iphotos.count}".html_safe
47
- end
48
- r
40
+ item_photos_short(item)
49
41
  end
50
-
42
+
51
43
  column :title
44
+ column :strsubcat
52
45
  column :is_hit
53
46
  column :is_sale
54
47
  column :is_main
55
48
  # column :is_ask_price
56
49
 
57
- # column 'Бренд' do |itm|
58
- # str = '-'
59
- # if itm.vendors.count > 0
60
- # str = itm.vendors.first.title
61
- # end
62
- # str
63
- # end
50
+ column :vendors do |itm|
51
+ print_vendor(itm)
52
+ end
64
53
 
65
54
  actions
66
55
  end
67
56
 
57
+ index as: :grid do |product|
58
+ product
59
+ end
60
+
68
61
  form(:html => {:multipart => true}) do |f|
69
62
 
70
63
  f.inputs 'Свойства' do
71
64
  f.input :title
72
65
  f.input :strsubcat,
73
66
  :as => :select,
74
- :collection => C80Yax::Strsubcat.all.map { |s| [s.title, s.id] },
67
+ :collection => C80Yax::Strsubcat.all.map {|s| [s.title, s.id]},
75
68
  :input_html => {
76
69
  :title => '',
77
70
  :class => 'selectpicker',
@@ -95,13 +88,22 @@ ActiveAdmin.register C80Yax::Item, as: 'Item' do
95
88
  # https://github.com/justinfrench/formtastic
96
89
  f.has_many :iphotos, :allow_destroy => true do |iph|
97
90
  iph.input :image,
98
- :as => :file,
99
- :hint => image_tag(iph.object.image.thumb_md)
91
+ :as => :file,
92
+ :hint => image_tag(iph.object.image.thumb_md)
100
93
  end
101
94
 
102
95
  f.input :full_desc, :as => :ckeditor, :input_html => {:style => 'height:500px', rows: 20}
103
- # f.input :vendors, :as => :select, :input_html => {:multiple => false}, :include_blank => true
104
-
96
+ f.input :vendors,
97
+ :as => :select,
98
+ :input_html => {
99
+ :title => '',
100
+ :class => 'selectpicker',
101
+ :data => {
102
+ :size => 10
103
+ },
104
+ :multiple => false
105
+ },
106
+ :include_blank => true
105
107
 
106
108
  end
107
109
 
@@ -125,4 +127,8 @@ ActiveAdmin.register C80Yax::Item, as: 'Item' do
125
127
  f.actions
126
128
  end
127
129
 
130
+ show do
131
+ render_show_item(item)
132
+ end
133
+
128
134
  end
@@ -0,0 +1,37 @@
1
+ module ActiveAdmin
2
+ module Views
3
+ class IndexAsTable < ActiveAdmin::Component
4
+ def editable_text_column resource, attr
5
+ val = resource.send(attr)
6
+ val = "&nbsp;" if val.blank?
7
+
8
+ slug = ''
9
+ begin
10
+ slug = resource.slug
11
+ rescue => e
12
+ slug = resource.id
13
+ end
14
+
15
+ html = %{
16
+ <div id='editable_text_column_#{resource.id}'
17
+ class='editable_text_column'
18
+ onclick='admin.editable_text_column_do(this)' >
19
+ #{val}
20
+ </div>
21
+
22
+ <input
23
+
24
+ data-path='#{resource.class.name.tableize}'
25
+ data-attr='#{attr}'
26
+ data-resource-id='#{resource.id}'
27
+ data-resource-slug='#{slug}'
28
+ class='editable_text_column admin-editable'
29
+ id='editable_text_column_#{resource.id}'
30
+
31
+ style='display:none;' />
32
+ }
33
+ html.html_safe
34
+ end
35
+ end
36
+ end
37
+ end
@@ -11,12 +11,16 @@ ActiveAdmin.register C80Yax::PropName, as: 'PropName' do
11
11
  :is_normal_price,
12
12
  :related_id
13
13
 
14
- config.sort_order = 'title_asc'
14
+ config.sort_order = 'id_asc'
15
+ # config.clear_action_items!
16
+ config.batch_actions = false
15
17
 
16
- filter :title
17
- filter :strsubcats
18
- filter :is_excluded_from_filtering
19
- filter :is_normal_price
18
+ # filter :title
19
+ # filter :strsubcats
20
+ # filter :is_excluded_from_filtering
21
+ # filter :is_normal_price
22
+
23
+ before_filter :skip_sidebar!, :only => :index
20
24
 
21
25
  # controller do
22
26
  # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
@@ -30,10 +34,10 @@ ActiveAdmin.register C80Yax::PropName, as: 'PropName' do
30
34
  column :uom
31
35
  column :is_excluded_from_filtering
32
36
  column :is_normal_price
33
- column :related do |p|
34
- if !p.related.blank?
35
- r = C80Yax::PropName.find(p.related)
36
- r.title
37
+ column :related do |pn|
38
+ if pn.related_id.present?
39
+ rpn = C80Yax::PropName.find(pn.related_id)
40
+ rpn.title
37
41
  end
38
42
  end
39
43
 
@@ -3,16 +3,18 @@ ActiveAdmin.register C80Yax::Strsubcat, as: 'Strsubcat' do
3
3
 
4
4
  menu :label => proc{ I18n.t('c80_yax.active_admin.menu.strsubcat')},
5
5
  :parent => 'x_c80_yax',
6
- :priority => 1
6
+ :priority => 2
7
7
 
8
8
  permit_params :title,
9
9
  :slug,
10
10
  :ord,
11
11
  :parent_id,
12
- :prop_name_ids => []#,
13
- # :main_props_attributes => [:id, :_destroy, :prop_name_ids => []],
14
- # :common_props_attributes => [:id, :_destroy, :prop_name_ids => []],
15
- # :price_props_attributes => [:id, :_destroy, :prop_name_ids => []]
12
+ :cat_ids => [],
13
+ :prop_name_ids => [],
14
+ :main_props_attributes => [:id, :_destroy, :prop_name_ids => []],
15
+ :common_props_attributes => [:id, :_destroy, :prop_name_ids => []],
16
+ :price_props_attributes => [:id, :_destroy, :prop_name_ids => []],
17
+ :prefix_props_attributes => [:id, :_destroy, :prop_name_ids => []]
16
18
 
17
19
  config.sort_order = 'id_asc'
18
20
 
@@ -35,37 +37,24 @@ ActiveAdmin.register C80Yax::Strsubcat, as: 'Strsubcat' do
35
37
  # }
36
38
  # }
37
39
 
38
- # controller do
39
- # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
40
- # end
40
+ controller do
41
+ C80Yax::Strsubcat.add_observer(C80Yax::StrsubcatObserver.instance)
42
+ end
41
43
 
42
44
  index do
43
45
  selectable_column
44
46
  id_column
45
- column :ord do |str_sub_cat|
46
- editable_text_column str_sub_cat, :ord
47
- end
47
+ column :ord
48
48
  column :title
49
49
  # column :parent
50
50
 
51
- column :prop_names do |strsubcat|
52
- res = '-'
53
- if strsubcat.prop_names.count > 0
54
- res = ''
55
- strsubcat.prop_names.map do |prop_name|
56
- res += "• #{prop_name.title}<br>"
57
- end
58
- end
59
- res.html_safe
51
+ column :cats do |str_sub_cat|
52
+ cat_admin_title(str_sub_cat)
60
53
  end
61
54
 
62
- # column :strcats do |str_sub_cat|
63
- # str = '-'
64
- # if str_sub_cat.strcats.count > 0
65
- # str = str_sub_cat.strcats.first.title
66
- # end
67
- # str
68
- # end
55
+ column :prop_names do |strsubcat|
56
+ all_props_list(strsubcat)
57
+ end
69
58
 
70
59
  actions
71
60
  end
@@ -75,9 +64,8 @@ ActiveAdmin.register C80Yax::Strsubcat, as: 'Strsubcat' do
75
64
  f.inputs 'Свойства подкатегории' do
76
65
  f.input :title
77
66
  f.input :ord
78
- f.input :parent,
67
+ f.input :cats,
79
68
  :as => :select,
80
- :collection => C80Yax::Strsubcat.where.not(id:f.object.id).map { |s| ["#{s.title}", s.id]},
81
69
  :input_html => {
82
70
  :class => 'selectpicker',
83
71
  :title => ' ',
@@ -88,41 +76,110 @@ ActiveAdmin.register C80Yax::Strsubcat, as: 'Strsubcat' do
88
76
  :multiple => false
89
77
  },
90
78
  :include_blank => true
79
+
80
+ # f.input :parent,
81
+ # :as => :select,
82
+ # :collection => C80Yax::Strsubcat.where.not(id:f.object.id).map { |s| ["#{s.title}", s.id]},
83
+ # :input_html => {
84
+ # :class => 'selectpicker',
85
+ # :title => ' ',
86
+ # :data => {
87
+ # :size => '10',
88
+ # :width => '400px'
89
+ # },
90
+ # :multiple => false
91
+ # },
92
+ # :include_blank => true
93
+ #
94
+
91
95
  end
92
96
 
93
- f.inputs 'Характеристики, которыми описываются товары из этой подкатегории', :class => 'collapsed' do
97
+ f.inputs I18n.t('c80_yax.active_admin.pages.strsubcat.label_all_props'), :class => 'collapsed' do
94
98
  f.input :prop_names, :as => :check_boxes
95
99
  end
96
100
 
97
- # f.inputs "Характеристки, которые выводятся на странице просмотра товара справа от картинки (<a class='poiasn' href='#{image_url('samples/2015_11_22_item_main_props.jpg')}' target='_blank'>например</a>)", :class => 'collapsed-bug fieldset_main_props' do
98
- # f.has_many :main_props, allow_destroy: true do |main_prop|
99
- # main_prop.input :prop_names,
100
- # :as => :select,
101
- # :input_html => {:multiple => false},
102
- # :collection => PropName.includes(:strsubcats).where(:strsubcats => {:id => f.object.id})
103
- #
104
- # end
105
- # end
106
-
107
- # f.inputs "Ценовые характеристики, которые выводятся на странице просмотра товара под картинкой (<a class='poiasn' href='#{image_url('samples/2015_11_22_item_price_props.jpg')}' target='_blank'>пример 1</a>, <a class='poiasn' href='#{image_url('samples/2015_11_22_item_price_props_list.jpg')}' target='_blank'>пример 2</a>)".html_safe, :class => 'collapsed-bug fieldset_price_props' do
108
- # f.has_many :price_props, allow_destroy: true do |price_prop|
109
- # price_prop.input :prop_names,
110
- # :as => :select,
111
- # :input_html => {:multiple => false},
112
- # :collection => PropName.includes(:strsubcats).where(:strsubcats => {:id => f.object.id}).where(:prop_names => {:is_normal_price => 1})
113
- # end
114
- # end
115
-
116
- # f.inputs "Характеристки, которые выводятся на странице просмотра товара в блоке 'дополнительные характеристики' (<a class='poiasn' href='#{image_url('samples/2015_11_22_item_common_props.jpg')}' target='_blank'>например</a>)", :class => 'collapsed-bug fieldset_common_props' do
117
- # f.has_many :common_props, allow_destroy: true do |common_prop|
118
- # common_prop.input :prop_names,
119
- # :as => :select,
120
- # :input_html => {:multiple => false},
121
- # :collection => PropName.includes(:strsubcats).where(:strsubcats => {:id => f.object.id})
122
- # end
123
- # end
101
+ f.inputs I18n.t('c80_yax.active_admin.pages.strsubcat.label_main_props',
102
+ img: image_url('samples/2017_06_20_item_main_props.jpg')).html_safe,
103
+ :class => 'collapsed fieldset_main_props' do
104
+ f.has_many :main_props, allow_destroy: true do |main_prop|
105
+ main_prop.input :prop_names,
106
+ :as => :select,
107
+ :input_html => {
108
+ :class => 'selectpicker',
109
+ :title => ' ',
110
+ :data => {
111
+ :size => '10',
112
+ :width => '400px'
113
+ },
114
+ :multiple => false
115
+ },
116
+ :collection => f.object.main_props_collection
117
+
118
+ end
119
+ end
120
+
121
+ f.inputs I18n.t('c80_yax.active_admin.pages.strsubcat.label_price_props',
122
+ img: image_url('samples/2017_06_20_item_price_props.jpg')).html_safe,
123
+ :class => 'collapsed fieldset_price_props' do
124
+ f.has_many :price_props, allow_destroy: true do |price_prop|
125
+ price_prop.input :prop_names,
126
+ :as => :select,
127
+ :input_html => {
128
+ :class => 'selectpicker',
129
+ :title => ' ',
130
+ :data => {
131
+ :size => '10',
132
+ :width => '400px'
133
+ },
134
+ :multiple => false
135
+ },
136
+ :collection => f.object.price_props_collection
137
+ end
138
+ end
139
+
140
+ f.inputs I18n.t('c80_yax.active_admin.pages.strsubcat.label_common_props',
141
+ img: image_url('samples/2017_06_20_item_common_props.jpg')).html_safe,
142
+ :class => 'collapsed fieldset_common_props' do
143
+ f.has_many :common_props, allow_destroy: true do |common_prop|
144
+ common_prop.input :prop_names,
145
+ :as => :select,
146
+ :input_html => {
147
+ :class => 'selectpicker',
148
+ :title => ' ',
149
+ :data => {
150
+ :size => '10',
151
+ :width => '400px'
152
+ },
153
+ :multiple => false
154
+ },
155
+ :collection => f.object.common_props_collection
156
+ end
157
+ end
158
+
159
+ f.inputs I18n.t('c80_yax.active_admin.pages.strsubcat.label_prefix_props',
160
+ img: image_url('samples/2017-06-21_item_prefix_props.jpg')),
161
+ :class => 'collapsed fieldset_common_props' do
162
+ f.has_many :prefix_props, allow_destroy: true do |prefix_prop|
163
+ prefix_prop.input :prop_names,
164
+ :as => :select,
165
+ :input_html => {
166
+ :class => 'selectpicker',
167
+ :title => ' ',
168
+ :data => {
169
+ :size => '10',
170
+ :width => '400px'
171
+ },
172
+ :multiple => false
173
+ },
174
+ :collection => f.object.prefix_props_collection
175
+ end
176
+ end
124
177
 
125
178
  f.actions
126
179
  end
127
180
 
181
+ show do
182
+ render 'view', { s: strsubcat }
183
+ end
184
+
128
185
  end
@@ -0,0 +1,39 @@
1
+ ActiveAdmin.register C80Yax::Vendor, as: 'Vendor' do
2
+
3
+ menu :label => 'Производители',
4
+ :parent => 'x_c80_yax',
5
+ :priority => 0
6
+
7
+ permit_params :title,
8
+ :short,
9
+ :content,
10
+ :as_is
11
+
12
+ # controller do
13
+ # cache_sweeper :vendor_sweeper, :only => [:update,:destroy]
14
+ # end
15
+
16
+ index do
17
+ selectable_column
18
+ # id_column
19
+
20
+ column :title
21
+ column :short
22
+
23
+ actions
24
+ end
25
+
26
+ form(:html => {:multipart => true}) do |f|
27
+
28
+ f.inputs 'Свойства' do
29
+
30
+ f.input :title
31
+ f.input :as_is
32
+ f.input :short, :input_html => {:style => 'height:80px', :maxlength => 250}
33
+ f.input :content, :as => :ckeditor
34
+
35
+ end
36
+ f.actions
37
+ end
38
+
39
+ end
@@ -409,7 +409,7 @@ var fEdit = function () {
409
409
  fLoadingShow();
410
410
  };
411
411
 
412
- YOUR_APP.items = {
412
+ C80_YAX.items = {
413
413
  edit: fEdit,
414
414
  "new": jsinit.go//,
415
415
  //create: jsinit.go
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ // при клике по habtm кнопке "добавить",
4
+ // на всякий случай,
5
+ // инициализируем в появившемся на экране блоке
6
+ // возможный bootstrap select picker
7
+ var init_select_picker = function (){
8
+ $('.has_many_add').on('click', function (){
9
+ setTimeout(function() {
10
+ $('.selectpicker').selectpicker();
11
+ }, 40);
12
+ });
13
+ };
14
+
15
+ var f_edit = function (){
16
+ init_select_picker();
17
+ };
18
+
19
+ var f_new = function (){
20
+ init_select_picker();
21
+ };
22
+
23
+ C80_YAX.strsubcats = {
24
+ edit: f_edit,
25
+ "new": f_new
26
+ };
@@ -1,6 +1,8 @@
1
1
 
2
+ #= require lib_backend/init
2
3
  #= require lib_backend/collapsable-groups
3
4
  #= require lib_backend/jalert
5
+ #= require lib_backend/loading
6
+ #= require lib_backend/custom_columns
4
7
 
5
- # require ./backend/init # это должно быть включено в host app
6
8
  #= require_tree ./backend