c80_yax 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/CODE_OF_CONDUCT.md +49 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +41 -0
  7. data/Rakefile +2 -0
  8. data/app/admin/c80_yax/items.rb +128 -0
  9. data/app/admin/c80_yax/prop_names.rb +90 -0
  10. data/app/admin/c80_yax/strsubcats.rb +128 -0
  11. data/app/admin/c80_yax/uoms.rb +35 -0
  12. data/app/admin/c80_yax/x_c80_yax.rb +5 -0
  13. data/app/assets/javascripts/backend/items.js +416 -0
  14. data/app/assets/javascripts/c80_yax.js.coffee +6 -0
  15. data/app/assets/javascripts/lib_backend/collapsable-groups.js +22 -0
  16. data/app/assets/javascripts/lib_backend/jalert.js +16 -0
  17. data/app/assets/stylesheets/c80_yax/backend/active_admin/admin_items.scss +152 -0
  18. data/app/assets/stylesheets/c80_yax/backend/collapsed.scss +56 -0
  19. data/app/assets/stylesheets/c80_yax/backend/jquery-my-dialog.scss +22 -0
  20. data/app/assets/stylesheets/c80_yax/lib/loading.scss +13 -0
  21. data/app/assets/stylesheets/c80_yax/mixins.scss +89 -0
  22. data/app/assets/stylesheets/c80_yax_backend.scss +7 -0
  23. data/app/controllers/c80_yax/admin_data_controller.rb +22 -0
  24. data/app/controllers/c80_yax/app_controller.rb +6 -0
  25. data/app/helpers/c80_yax/data_helper.rb +84 -0
  26. data/app/models/c80_yax/iphoto.rb +7 -0
  27. data/app/models/c80_yax/item.rb +169 -0
  28. data/app/models/c80_yax/item_prop.rb +83 -0
  29. data/app/models/c80_yax/prop.rb +5 -0
  30. data/app/models/c80_yax/prop_name.rb +32 -0
  31. data/app/models/c80_yax/strsubcat.rb +71 -0
  32. data/app/models/c80_yax/uom.rb +5 -0
  33. data/app/uploaders/c80_yax/iphoto_uploader.rb +41 -0
  34. data/bin/console +14 -0
  35. data/bin/setup +8 -0
  36. data/c80_yax.gemspec +26 -0
  37. data/config/locales/ru.yml +52 -0
  38. data/config/routes.rb +3 -0
  39. data/db/migrate/20161030061203_create_c80_yax_strsubcats.rb +12 -0
  40. data/db/migrate/20161030225354_create_c80_yax_items.rb +20 -0
  41. data/db/migrate/20161107202727_create_c80_yax_iphotos.rb +11 -0
  42. data/db/migrate/20161107210000_create_c80_yax_props.rb +15 -0
  43. data/db/migrate/20161108095505_create_c80_yax_uoms.rb +11 -0
  44. data/db/migrate/20161108095950_create_c80_yax_prop_names.rb +13 -0
  45. data/db/migrate/20161108100707_create_c80_yax_join_table_prop_names_strsubcats.rb +12 -0
  46. data/db/migrate/20161108102828_create_c80_yax_item_props.rb +13 -0
  47. data/db/seeds/c80_yax_01_fill_props.rb +11 -0
  48. data/lib/c80_yax/engine.rb +23 -0
  49. data/lib/c80_yax/version.rb +3 -0
  50. data/lib/c80_yax.rb +8 -0
  51. metadata +135 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f5f41616e959e6eadcab3ecee39303ac308d57d3
4
+ data.tar.gz: f74adf0891bfeb16286ca6c356538fa5e3bc8698
5
+ SHA512:
6
+ metadata.gz: ae1f05a7b8ebbc262fe8479f77d3b305bf5bc73d7c1721eb303ef04c25fb9a18a885942bc9c095886ec106ffcb6f8313e2874b64579bb16e9ec086eee4013de2
7
+ data.tar.gz: 0aeed6d233f00f6c422fde87ee219741e2feb0fdd1227ec44ea1e4976e44d04bb267b4a68c0dd0bb3f5e96207e5ae1505e66fe2dd31afe93bff0c01a6703004e
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.idea/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.gem
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at c080609a@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in c80_yax.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 C80609A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # C80Yax
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/c80_yax`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'c80_yax'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install c80_yax
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
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.
30
+
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).
32
+
33
+ ## Contributing
34
+
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.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,128 @@
1
+ # категории строительных материалов
2
+ ActiveAdmin.register C80Yax::Item, as: 'Item' do
3
+
4
+ menu :label => proc { I18n.t('c80_yax.active_admin.menu.item') },
5
+ :parent => 'x_c80_yax',
6
+ :priority => 2
7
+
8
+
9
+ permit_params :title,
10
+ :short_desc,
11
+ :full_desc,
12
+ :is_hit,
13
+ :is_sale,
14
+ :is_main,
15
+ :is_gift,
16
+ :is_starting,
17
+ :is_available,
18
+ :strsubcat_id,
19
+ :iphotos_attributes => [:id, :image, :_destroy],
20
+ :item_props_attributes => [:value, :_destroy, :prop_name_id, :id]#,
21
+ # :vendor_ids => [],
22
+ # :gallery_ids => [],
23
+ # :related_child_ids => []
24
+
25
+ config.sort_order = 'id_asc'
26
+
27
+ # controller do
28
+ # cache_sweeper :item_sweeper, :only => [:update,:create,:destroy]
29
+ # end
30
+
31
+ # action_item :dublcate_item, :only => :edit do
32
+ # link_to 'Клонировать', '', class:'dublicate_item'#, method: :post # эта ссылка обработается ajax-ом
33
+ # end
34
+
35
+ index do
36
+ selectable_column
37
+ id_column
38
+
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
49
+ end
50
+
51
+ column :title
52
+ column :is_hit
53
+ column :is_sale
54
+ column :is_main
55
+ # column :is_ask_price
56
+
57
+ # column 'Бренд' do |itm|
58
+ # str = '-'
59
+ # if itm.vendors.count > 0
60
+ # str = itm.vendors.first.title
61
+ # end
62
+ # str
63
+ # end
64
+
65
+ actions
66
+ end
67
+
68
+ form(:html => {:multipart => true}) do |f|
69
+
70
+ f.inputs 'Свойства' do
71
+ f.input :title
72
+ f.input :strsubcat,
73
+ :as => :select,
74
+ :collection => C80Yax::Strsubcat.all.map { |s| [s.title, s.id] },
75
+ :input_html => {
76
+ :title => '',
77
+ :class => 'selectpicker',
78
+ :data => {
79
+ :size => 10
80
+ }
81
+ }
82
+
83
+ f.input :is_hit
84
+ f.input :is_sale
85
+ f.input :is_main
86
+ f.input :is_gift
87
+ f.input :is_starting
88
+ f.input :is_available
89
+
90
+ f.input :short_desc, :input_html => {:style => 'height:80px', :maxlength => 250}
91
+
92
+ # Как поменять надпись на кнопке? Хочу убрать добавить Iphoto
93
+ # http://stackoverflow.com/questions/9266496/translate-rails-model-association-not-working
94
+ # http://stackoverflow.com/questions/8310997/configure-the-label-of-active-admin-has-many
95
+ # https://github.com/justinfrench/formtastic
96
+ f.has_many :iphotos, :allow_destroy => true do |iph|
97
+ iph.input :image,
98
+ :as => :file,
99
+ :hint => image_tag(iph.object.image.thumb_md)
100
+ end
101
+
102
+ 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
+
105
+
106
+ end
107
+
108
+ f.inputs 'Характеристики' do
109
+
110
+ f.has_many :item_props, :allow_destroy => true do |item_prop|
111
+ item_prop.input :prop_name
112
+ item_prop.input :value
113
+ end
114
+
115
+ end
116
+
117
+ # f.inputs "Укажите товары, которые будут выводиться в блоке 'Похожие товары'", :class => 'collapsed' do
118
+ # f.input :related_childs,
119
+ # :as => :check_boxes,
120
+ # :member_label => Proc.new { |p|
121
+ # p.title
122
+ # }
123
+ # end
124
+
125
+ f.actions
126
+ end
127
+
128
+ end
@@ -0,0 +1,90 @@
1
+ # категории строительных материалов
2
+ ActiveAdmin.register C80Yax::PropName, as: 'PropName' do
3
+
4
+ menu :label => 'Имена свойств',
5
+ :parent => 'x_c80_yax',
6
+ :priority => 6
7
+
8
+ permit_params :title,
9
+ :uom_id,
10
+ :is_excluded_from_filtering,
11
+ :is_normal_price,
12
+ :related_id
13
+
14
+ config.sort_order = 'title_asc'
15
+
16
+ filter :title
17
+ filter :strsubcats
18
+ filter :is_excluded_from_filtering
19
+ filter :is_normal_price
20
+
21
+ # controller do
22
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
23
+ # end
24
+
25
+ index do
26
+ # selectable_column
27
+ id_column
28
+
29
+ column :title
30
+ column :uom
31
+ column :is_excluded_from_filtering
32
+ 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
+ end
38
+ end
39
+
40
+ actions
41
+ end
42
+
43
+ form(:html => {:multipart => true}) do |f|
44
+
45
+ f.inputs "Свойства" do
46
+ f.input :title,
47
+ :hint => 'Например: цвет, размер, ширина'
48
+ f.input :uom,
49
+ :as => :select,
50
+ :input_html => {
51
+ :class => 'selectpicker',
52
+ :title => '',
53
+ :data => {
54
+ :size => 10,
55
+ :width => '400px'
56
+ },
57
+ :multiple => false
58
+ },
59
+ :include_blank => true
60
+
61
+ f.input :related,
62
+ as: :select,
63
+ collection: C80Yax::PropName.all,
64
+ :hint => 'Только для цен. Если есть подобная "старая" цена, то необходимо указать'.html_safe,
65
+ :input_html => {
66
+ :class => 'selectpicker',
67
+ :title => '',
68
+ :data => {
69
+ :size => 10,
70
+ :width => '400px'
71
+ },
72
+ :multiple => false
73
+ },
74
+ :include_blank => true
75
+
76
+ end
77
+
78
+ f.inputs 'Дополнительные характеристики' do
79
+ f.input :is_excluded_from_filtering,
80
+ :hint => "Свойство не будет фигурировать в списке фильтрации (<a class='poiasn' href='#{image_url('samples/20151022_prop_name_is_excluded_from_filtering.jpg')}' target='_blank'>например</a>)".html_safe
81
+
82
+ f.input :is_normal_price,
83
+ :hint => "Является ли свойство 'нормальной' (нестарой) ценой?".html_safe
84
+ end
85
+
86
+ f.actions
87
+
88
+ end
89
+
90
+ end
@@ -0,0 +1,128 @@
1
+ # ПОДкатегории строительных материалов
2
+ ActiveAdmin.register C80Yax::Strsubcat, as: 'Strsubcat' do
3
+
4
+ menu :label => proc{ I18n.t('c80_yax.active_admin.menu.strsubcat')},
5
+ :parent => 'x_c80_yax',
6
+ :priority => 1
7
+
8
+ permit_params :title,
9
+ :slug,
10
+ :ord,
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 => []]
16
+
17
+ config.sort_order = 'id_asc'
18
+
19
+ # controller do
20
+ # cache_sweeper :strsubcat_sweeper, :only => [:update,:create,:destroy]
21
+ # end
22
+
23
+ # before_filter :skip_sidebar!, :only => :index
24
+
25
+ filter :title
26
+ # filter :parent_id_in,
27
+ # :as => :select,
28
+ # :collection => -> { C80Yax::Strsubcat.all.map { |s| [s.title,s.id] }},
29
+ # :input_html => {
30
+ # :class => 'selectpicker',
31
+ # :title => '',
32
+ # :data => {
33
+ # :size => 10,
34
+ # :width => '100%'
35
+ # }
36
+ # }
37
+
38
+ # controller do
39
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
40
+ # end
41
+
42
+ index do
43
+ selectable_column
44
+ id_column
45
+ column :ord do |str_sub_cat|
46
+ editable_text_column str_sub_cat, :ord
47
+ end
48
+ column :title
49
+ # column :parent
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
60
+ end
61
+
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
69
+
70
+ actions
71
+ end
72
+
73
+ form(:html => {:multipart => true}) do |f|
74
+
75
+ f.inputs 'Свойства подкатегории' do
76
+ f.input :title
77
+ f.input :ord
78
+ f.input :parent,
79
+ :as => :select,
80
+ :collection => C80Yax::Strsubcat.where.not(id:f.object.id).map { |s| ["#{s.title}", s.id]},
81
+ :input_html => {
82
+ :class => 'selectpicker',
83
+ :title => ' ',
84
+ :data => {
85
+ :size => '10',
86
+ :width => '400px'
87
+ },
88
+ :multiple => false
89
+ },
90
+ :include_blank => true
91
+ end
92
+
93
+ f.inputs 'Характеристики, которыми описываются товары из этой подкатегории', :class => 'collapsed' do
94
+ f.input :prop_names, :as => :check_boxes
95
+ end
96
+
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
124
+
125
+ f.actions
126
+ end
127
+
128
+ end
@@ -0,0 +1,35 @@
1
+ # единицы измерения
2
+ ActiveAdmin.register C80Yax::Uom, as: 'Uom' do
3
+
4
+ menu :label => 'Единицы измерения',
5
+ :parent => 'x_c80_yax',
6
+ :priority => 7
7
+
8
+ permit_params :title, :comment, :is_number
9
+
10
+ config.sort_order = 'title_desc'
11
+
12
+ filter :title
13
+
14
+ index do
15
+ # selectable_column
16
+ # id_column
17
+
18
+ column :title
19
+ column :comment
20
+ column :is_number
21
+
22
+ # actions
23
+ end
24
+
25
+ form(:html => {:multipart => true}) do |f|
26
+
27
+ f.inputs "Свойства" do
28
+ f.input :title
29
+ f.input :comment
30
+ f.input :is_number
31
+ end
32
+ f.actions
33
+ end
34
+
35
+ end
@@ -0,0 +1,5 @@
1
+ ActiveAdmin.register_page 'x_c80_yax' do
2
+ menu :label => proc{ I18n.t("c80_yax.active_admin.menu.core_item") },
3
+ :priority => 2,
4
+ :url => '#'
5
+ end