c80_yax 0.1.0.7 → 0.1.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f969344b2bcf0fc52c5266682ee5581540ec959
4
- data.tar.gz: b9dc152b23bfe3772ca763bebf8727dfddeaf182
3
+ metadata.gz: '0804e766b1342dc657468f4b7fb8057bc44d5c50'
4
+ data.tar.gz: ad39ee25f7c4272fede3cf14e745b61c8bc639cb
5
5
  SHA512:
6
- metadata.gz: a350e97d8c58c91917d585949312d376577be2f4746cb7f14c0d9a1a8e7959f1ae57a11190f3c9f00ca65eb164d0831cf2fdec11fc12fb635c2215bb58070d36
7
- data.tar.gz: 844e89c7a9fe84929718def8039f909bb9d75d55dcf5c3dae56e8a8d4001d6bb33ba21c06afa7e6ddd699bb55f0898cfa104590f216e6e5cb170abb8cca46021
6
+ metadata.gz: b30de510b7481ef42394f42cc4caf3f8bec341af295991207b2a831d05481e4df083ee7e189fbb418b4b43008c9fa7038875108af8c4fa5fa4400df30aaf1cdf
7
+ data.tar.gz: 7537c2bf4139138a3ee54be202a6cdca0d7030e4933cebab8e13894575a8fa5422a5198acc1c0790866246917183b46ec75a91e6ba5945bb17db3f478eea356b
@@ -6,6 +6,18 @@
6
6
  text-transform: uppercase;
7
7
  text-align: center;
8
8
 
9
+ position: relative;
10
+ &:before {
11
+ content: '';
12
+ display: block;
13
+ width: 44px;
14
+ height: 44px;
15
+ position: absolute;
16
+ background: transparent image-url('cart_icon.png') no-repeat 35% 50%;
17
+ left: 18%;
18
+ top: 14%;
19
+ }
20
+
9
21
  // TODO-1:: добавить иконку корзины
10
22
 
11
23
  }
@@ -0,0 +1,14 @@
1
+ ul.item_images_no_main {
2
+ white-space: nowrap;
3
+ list-style: none;
4
+ padding: 0;
5
+ margin: 15px 0 15px 0;
6
+
7
+ > li {
8
+ display: inline;
9
+ > a {
10
+ display: block;
11
+ margin-right: 5px;
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ ul.item_index {
2
+ @include clearfix;
3
+ list-style: none;
4
+ margin: 20px -30px 20px 0;
5
+ padding: 0;
6
+
7
+ > .li_item {
8
+ float: left;
9
+ margin-right: 35px;
10
+ margin-bottom: 20px;
11
+ }
12
+
13
+ }
@@ -55,4 +55,8 @@
55
55
  .checkbox label input[type="checkbox"]:disabled + .cr,
56
56
  .radio label input[type="radio"]:disabled + .cr {
57
57
  opacity: .5;
58
+ }
59
+
60
+ .fa-check:before {
61
+ font-family: FontAwesome !important;
58
62
  }
@@ -1,3 +1,4 @@
1
1
  @import 'c80_yax/_mixins/**/*';
2
2
  @import 'c80_yax/lib/**/*';
3
+ @import 'c80_yax/lib_custom/**/*';
3
4
  @import 'c80_yax/elems/**/*';
@@ -0,0 +1,173 @@
1
+ module C80Yax
2
+ class ItemDecorator < ::ApplicationDecorator
3
+ decorates 'C80Yax::Item'
4
+ delegate_all
5
+
6
+ def my_url
7
+ "/katalog/#{model.strsubcat.slug}/#{model.id}"
8
+ end
9
+
10
+ def main_image(thumb_size = 'thumb_md', options = {})
11
+
12
+ rel = options.fetch(:rel, 'follow')
13
+ a_href = options.fetch(:a_href, my_url)
14
+
15
+ ww = fetch_ww(thumb_size)
16
+ hh = fetch_hh(thumb_size)
17
+
18
+ h.render_image_link_lazy({
19
+ :alt_image => model.title,
20
+ # :image => main_image_tag(thumb_size),
21
+ :image => self.fetch_first_photo(thumb_size),
22
+ :a_href => a_href,
23
+ :rel => rel,
24
+ :a_class => 'item_main_image',
25
+ :a_css_style => "width:#{ww}px;height:#{hh}px",
26
+ :image_width => ww,
27
+ :image_height => hh
28
+ })
29
+ end
30
+
31
+ def h3_title(thumb_size = 'thumb_md')
32
+ ww = fetch_ww(thumb_size)
33
+ h.content_tag :h3, model.title, style: "width:#{ww}px"
34
+ end
35
+
36
+ def div_prices
37
+ # Rails.logger.debug '[TRACE] <ItemDecorator.div_prices> ------[begin]--------'
38
+ result = ''
39
+
40
+ if model.is_ask_price
41
+ result =
42
+ "<p class='is_ask_price c80_refine_price_button'
43
+ data-item-url='#{ my_url }'
44
+ data-item-id='#{ model.id }'
45
+ data-item-title='#{ model.title }'>Уточнить цену</p>
46
+ "
47
+ else
48
+
49
+ # <editor-fold desc="# парсим данные в структуру для view">
50
+ props = {
51
+ titles: [],
52
+ values: [],
53
+ uoms: [],
54
+ values_old: []
55
+ }
56
+
57
+ model.item_props.each do |ip|
58
+ # Rails.logger.debug "[TRACE] <ItemDecorator.div_prices> ip.prop_name.related.present? = #{ip.prop_name.related.present?}"
59
+ if ip.prop_name.is_normal_price
60
+ props[:titles] << ip.prop_name.title
61
+ props[:values] << ip.value
62
+ props[:uoms] << ip.prop_name.uom_title
63
+
64
+ # у свойства "нормальная цена" может быть "старый вариант"
65
+ if ip.prop_name.related.present?
66
+ # фиксируем айдишник свойства "старый вариант этой цены"
67
+ related_id = ip.prop_name.related.id
68
+ # и зафиксирем его значение
69
+ model.item_props.each do |iip|
70
+ # Rails.logger.debug "[TRACE] <ItemDecorator.div_prices> iip.prop_name.id = #{iip.prop_name.id} VS #{related_id}"
71
+
72
+ if iip.prop_name.id == related_id
73
+ # props[:titles] << iip.prop_name.title
74
+ props[:values_old] << iip.value
75
+ # props[:uoms] << iip.prop_name.uom_title
76
+ break
77
+ end
78
+ end
79
+ end
80
+
81
+ end
82
+ end
83
+
84
+ # Rails.logger.debug "[TRACE] <ItemDecorator.div_prices> props: #{props}"
85
+
86
+ # </editor-fold>
87
+
88
+ # <editor-fold desc="# собираем html-строку (список)">
89
+ res = ''
90
+ props[:titles].each_with_index do |title, i|
91
+ e = "<p data-title='#{title}' class='old'><span class='pvalue bold'>#{props[:values_old][i]}</span> <span class='puom'>#{_uom(props[:uoms][i])}</span></p>" # 1212,80 руб
92
+ e += "<p data-title='#{title}'><span class='pvalue bold'>#{props[:values][i]}</span> <span class='puom'>#{_uom(props[:uoms][i])}</span></p>" # 1212,80 руб
93
+ e = "<li>#{e}</li>"
94
+ res += e
95
+ end
96
+
97
+ # Rails.logger.debug '[TRACE] <ItemDecorator.div_prices> ------- [end] ------- '
98
+ result = "<ul>#{res}</ul>"
99
+ # </editor-fold>
100
+
101
+ end
102
+
103
+ "<div class='price_props'>#{result}</div>".html_safe
104
+
105
+ end
106
+
107
+ def _uom(v)
108
+ return '' if v.nil?
109
+ v
110
+ end
111
+
112
+ def btn_order
113
+
114
+ end
115
+
116
+
117
+ def h1_title
118
+ h.content_tag :h1, model.title
119
+ end
120
+
121
+ def props_list
122
+ res = ''
123
+ ps = %w(customer price duration when)
124
+ ds = %w(клиент бюджет срок\ выполнения дата)
125
+ ps.each_with_index do |p, index|
126
+ v = model.send(p)
127
+ next if v.blank?
128
+ res += "<li><span class='def'>#{ds[index]}:</span> #{model.send(p)}</li>"
129
+ end
130
+ "<ul class='work_props_list'>#{res}</ul>".html_safe
131
+ end
132
+
133
+ def images_no_main(thumb_size = 'thumb_sm')
134
+ res = ''
135
+ model.iphotos.each_with_index do |wp, index|
136
+ next if index.zero?
137
+ img = h.image_tag wp.image.send(thumb_size).url
138
+ lnk = h.link_to img, wp.image.thumb_lg.url
139
+ res += "<li>#{lnk}</li>"
140
+ end
141
+ "<ul class='item_images_no_main'>#{res}</ul>".html_safe
142
+ end
143
+
144
+ def div_p_desc
145
+ res = ''
146
+ res = model.desc.html_safe if model.desc.present?
147
+ "<div class='work_desc'>#{res}</div>".html_safe
148
+ end
149
+
150
+
151
+ # выдать url миниатюры указанного +thumb_size+ типа
152
+ # первой попавшейся фотки обьекта
153
+ def fetch_first_photo(thumb_size = 'thumb_md')
154
+ Rails.logger.debug '[TRACE] <ItemDecorator.fetch_first_photo>'
155
+ res = ''
156
+ if model.iphotos.size > 0
157
+ res = model.iphotos.first.image.send(thumb_size)
158
+ end
159
+ res
160
+ end
161
+
162
+ def fetch_ww(thumb_size = 'thumb_md')
163
+ Rails.logger.debug '[TRACE] <ItemDecorator.fetch_ww>'
164
+ @ww ||= ItemPhotosSizesCache.instance.thumb_width(thumb_size)
165
+ end
166
+
167
+ def fetch_hh(thumb_size = 'thumb_md')
168
+ Rails.logger.debug '[TRACE] <ItemDecorator.fetch_hh>'
169
+ @hh ||= ItemPhotosSizesCache.instance.thumb_height(thumb_size)
170
+ end
171
+
172
+ end
173
+ end
@@ -2,11 +2,13 @@ module C80Yax
2
2
  module Cats
3
3
  module CatListsHelper
4
4
 
5
- def render_cats_iconed_list(n = 4)
5
+ def render_cats_iconed_list(n = 4, &make_url)
6
+ proc_make_url = proc &make_url
6
7
  cats = Cat.iconed_list(n)
7
8
  render :partial => 'c80_yax/cats/cats_iconed_list',
8
9
  :locals => {
9
- cats: cats
10
+ cats: cats,
11
+ proc_make_url: proc_make_url
10
12
  }
11
13
  end
12
14
 
@@ -0,0 +1,39 @@
1
+ module C80Yax
2
+ module Frontend
3
+ module CatalogIndexHelper
4
+
5
+ def c80_yax_render_catalog_index(thumb_size = 'thumb_md', page=1, per_page = 16)
6
+ itms = C80Yax::Item.includes(item_props: {prop_name: [:uom, :related]})
7
+ .includes(:iphotos)
8
+ .includes(:strsubcat)
9
+ .paginate(page: page, per_page: per_page)
10
+ items = ItemDecorator.decorate_collection(itms)
11
+ render partial: 'c80_yax/items/index',
12
+ locals: {
13
+ items: items,
14
+ without_paginator: false,
15
+ will_paginate_items: itms,
16
+ thumb_size: thumb_size
17
+ }
18
+ end
19
+
20
+ def c80_yax_render_related(item, thumb_size = 'thumb_md', count = 4)
21
+ itms = C80Yax::Item.includes(item_props: {prop_name: [:uom, :related]})
22
+ .includes(:iphotos)
23
+ .includes(:strsubcat)
24
+ .where(c80_yax_items: { strsubcat_id: item.strsubcat.id })
25
+ .limit(count)
26
+ items = ItemDecorator.decorate_collection(itms)
27
+ render partial: 'c80_yax/items/index',
28
+ locals: {
29
+ items: items,
30
+ without_paginator: true,
31
+ thumb_size: thumb_size
32
+ }
33
+ end
34
+
35
+ private
36
+
37
+ end
38
+ end
39
+ end
@@ -28,5 +28,10 @@ module C80Yax
28
28
  # validates_with PropNameValidator
29
29
  # TODO:: добавить валидацию title на уникальность и длину
30
30
 
31
+ def uom_title
32
+ return uom.title if uom.present?
33
+ ''
34
+ end
35
+
31
36
  end
32
37
  end
@@ -11,7 +11,7 @@
11
11
  <% k = index % 4 %>
12
12
  <li class="child-<%=k+1%>th">
13
13
 
14
- <%= link_to "#{cat_normal_url(cat)}",
14
+ <%= link_to "#{proc_make_url.call(cat)}",
15
15
  :title => cat.title,
16
16
  :class => 'a_cat_nav',
17
17
  :id => "a_#{cat.slug}",
@@ -0,0 +1,17 @@
1
+ <ul class="item_index">
2
+ <% items.each do |item| %>
3
+ <li class="li_item i_<%= item.id%>">
4
+ <%= item.main_image(thumb_size) %>
5
+ <%= item.h3_title(thumb_size) %>
6
+ <%= item.div_prices %>
7
+ <%= item.btn_order %>
8
+ </li>
9
+ <% end %>
10
+ </ul>
11
+
12
+ <div class="will_paginate">
13
+ <%= will_paginate(will_paginate_items,
14
+ :previous_label => '<',
15
+ :next_label => '>',
16
+ :inner_window => 3) unless without_paginator %>
17
+ </div>
@@ -0,0 +1,17 @@
1
+ require 'singleton'
2
+ # require 'sizes_cache'
3
+
4
+ module C80Yax
5
+
6
+ # Оптимизируем высокочастотные запросы к базе.
7
+
8
+ class ItemPhotosSizesCache < ::SizesCache
9
+ include Singleton
10
+
11
+ def initialize
12
+ super(C80Yax::Prop)
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -1,3 +1,3 @@
1
1
  module C80Yax
2
- VERSION = '0.1.0.7'
2
+ VERSION = '0.1.0.8'
3
3
  end
data/lib/c80_yax.rb CHANGED
@@ -2,6 +2,7 @@ require 'c80_yax/version'
2
2
  require 'c80_yax/engine'
3
3
  require 'c80_yax/strsubcat_runtime_tables'
4
4
  require 'c80_yax/watermarker'
5
+ require 'c80_yax/item_photos_sizes_cache'
5
6
  require 'rails-observers'
6
7
  require 'mini_magick'
7
8
  require_relative '../engines/pack/lib/pack'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_yax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.7
4
+ version: 0.1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-27 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -151,16 +151,19 @@ files:
151
151
  - app/assets/stylesheets/c80_yax/backend/jquery-my-dialog.scss
152
152
  - app/assets/stylesheets/c80_yax/elems/add_to_bucket.scss
153
153
  - app/assets/stylesheets/c80_yax/elems/cats_iconed_list.scss
154
+ - app/assets/stylesheets/c80_yax/elems/item_images_no_main.scss
155
+ - app/assets/stylesheets/c80_yax/elems/ul_item_index.scss
154
156
  - app/assets/stylesheets/c80_yax/lib/bootstrap_checkboxes.scss
155
157
  - app/assets/stylesheets/c80_yax/lib/loading.scss
156
158
  - app/assets/stylesheets/c80_yax/lib_custom/bootstrap_checkboxes.scss
157
159
  - app/assets/stylesheets/c80_yax_backend.scss
158
160
  - app/controllers/c80_yax/admin_data_controller.rb
159
161
  - app/controllers/c80_yax/app_controller.rb
162
+ - app/decorators/c80_yax/item_decorator.rb
160
163
  - app/helpers/c80_yax/cats/cat_lists_helper.rb
161
- - app/helpers/c80_yax/cats/cat_url_helper.rb
162
164
  - app/helpers/c80_yax/cats/cat_view_helper.rb
163
165
  - app/helpers/c80_yax/data_helper.rb
166
+ - app/helpers/c80_yax/frontend/catalog_index_helper.rb
164
167
  - app/helpers/c80_yax/items/asterix_helper.rb
165
168
  - app/helpers/c80_yax/items/buy_options_helper.rb
166
169
  - app/helpers/c80_yax/items/item_view_helper.rb
@@ -195,6 +198,7 @@ files:
195
198
  - app/views/admin/strsubcats/_view.html.erb
196
199
  - app/views/c80_yax/cats/_cats_iconed_list.html.erb
197
200
  - app/views/c80_yax/items/_buy_options.html.erb
201
+ - app/views/c80_yax/items/_index.html.erb
198
202
  - bin/console
199
203
  - bin/setup
200
204
  - c80_yax.gemspec
@@ -242,6 +246,7 @@ files:
242
246
  - engines/pack/lib/pack/engine.rb
243
247
  - lib/c80_yax.rb
244
248
  - lib/c80_yax/engine.rb
249
+ - lib/c80_yax/item_photos_sizes_cache.rb
245
250
  - lib/c80_yax/strsubcat_runtime_tables.rb
246
251
  - lib/c80_yax/version.rb
247
252
  - lib/c80_yax/watermarker.rb
@@ -1,11 +0,0 @@
1
- module C80Yax
2
- module Cats
3
- module CatUrlHelper
4
-
5
- def cat_normal_url(cat)
6
- '#'
7
- end
8
-
9
- end
10
- end
11
- end