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.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +50 -13
- data/app/admin/c80_yax/cats.rb +47 -0
- data/app/admin/c80_yax/items.rb +36 -30
- data/app/admin/c80_yax/lib/custom_columns.rb +37 -0
- data/app/admin/c80_yax/prop_names.rb +13 -9
- data/app/admin/c80_yax/strsubcats.rb +114 -57
- data/app/admin/c80_yax/vendors.rb +39 -0
- data/app/assets/javascripts/backend/items.js +1 -1
- data/app/assets/javascripts/backend/strsubcats.js +26 -0
- data/app/assets/javascripts/c80_yax.js.coffee +3 -1
- data/app/assets/javascripts/lib_backend/custom_columns.js +73 -0
- data/app/assets/javascripts/lib_backend/init.js +28 -0
- data/app/assets/javascripts/lib_backend/loading.js +8 -0
- data/app/assets/stylesheets/c80_yax/_mixins/_colors.scss +1 -0
- data/app/assets/stylesheets/c80_yax/_mixins/color_button.scss +31 -0
- data/app/assets/stylesheets/c80_yax/_mixins/shdw.scss +10 -0
- data/app/assets/stylesheets/c80_yax/backend/active_admin/admin_items.scss +1 -1
- data/app/assets/stylesheets/c80_yax/backend/collapsed.scss +1 -1
- data/app/assets/stylesheets/c80_yax/elems/add_to_bucket.scss +11 -0
- data/app/assets/stylesheets/c80_yax/lib/bootstrap_checkboxes.scss +58 -0
- data/app/assets/stylesheets/c80_yax/lib_custom/bootstrap_checkboxes.scss +6 -0
- data/app/assets/stylesheets/c80_yax.scss +1 -0
- data/app/assets/stylesheets/c80_yax_backend.scss +2 -1
- data/app/helpers/c80_yax/items/asterix_helper.rb +13 -0
- data/app/helpers/c80_yax/items/buy_options_helper.rb +33 -0
- data/app/helpers/c80_yax/items/item_view_helper.rb +24 -0
- data/app/helpers/c80_yax/items/photos/item_photos_helper.rb +43 -0
- data/app/helpers/c80_yax/items/render_show_item_helper.rb +17 -0
- data/app/helpers/c80_yax/prop_name_helper.rb +11 -0
- data/app/helpers/c80_yax/strsubcats/props_helper.rb +81 -0
- data/app/helpers/c80_yax/uom_helper.rb +19 -0
- data/app/models/c80_yax/cat.rb +25 -0
- data/app/models/c80_yax/common_prop.rb +51 -0
- data/app/models/c80_yax/concerns/props/parsable.rb +129 -0
- data/app/models/c80_yax/item.rb +3 -1
- data/app/models/c80_yax/item_observer.rb +29 -0
- data/app/models/c80_yax/main_prop.rb +37 -0
- data/app/models/c80_yax/mixins/item/database/props.rb +66 -0
- data/app/models/c80_yax/mixins/strsubcat/database/prop_names_changed.rb +56 -0
- data/app/models/c80_yax/mixins/strsubcat/database/props.rb +37 -0
- data/app/models/c80_yax/prefix_prop.rb +35 -0
- data/app/models/c80_yax/price_prop.rb +47 -0
- data/app/models/c80_yax/prop_name.rb +4 -4
- data/app/models/c80_yax/strsubcat.rb +38 -23
- data/app/models/c80_yax/strsubcat_observer.rb +47 -0
- data/app/models/c80_yax/vendor.rb +16 -0
- data/app/views/admin/strsubcats/_view.html.erb +40 -0
- data/app/views/c80_yax/items/_buy_options.html.erb +9 -0
- data/c80_yax.gemspec +3 -0
- data/config/locales/ru.yml +33 -6
- data/db/migrate/20161030225354_create_c80_yax_items.rb +2 -0
- data/db/migrate/20170620111100_create_c80_yax_cats.rb +11 -0
- data/db/migrate/20170620111401_create_c80_yax_join_table_cats_strsubcats.rb +12 -0
- data/db/migrate/20170620164848_create_c80_yax_price_props.rb +9 -0
- data/db/migrate/20170620164949_create_c80_yax_join_table_price_props_prop_names.rb +12 -0
- data/db/migrate/20170620183838_create_c80_yax_main_props.rb +8 -0
- data/db/migrate/20170620195757_create_c80_yax_join_table_main_props_prop_names.rb +12 -0
- data/db/migrate/20170620200707_create_c80_yax_common_props.rb +8 -0
- data/db/migrate/20170620200808_create_c80_yax_join_table_common_props_prop_names.rb +12 -0
- data/db/migrate/20170621170202_create_c80_yax_prefix_props.rb +8 -0
- data/db/migrate/20170621170808_create_c80_yax_join_table_prefix_props_prop_names.rb +12 -0
- data/db/migrate/20170622193535_create_c80_yax_vendors.rb +11 -0
- data/db/migrate/20170622194040_create_c80_yax_join_table_items_vendors.rb +12 -0
- data/lib/c80_yax/engine.rb +2 -0
- data/lib/c80_yax/strsubcat_runtime_tables.rb +668 -0
- data/lib/c80_yax/version.rb +1 -1
- data/lib/c80_yax.rb +4 -2
- data/lib/generators/c80_yax/install_generator.rb +20 -0
- data/lib/generators/c80_yax/templates/app/helpers/c80_yax/items/show_item_helper.rb +21 -0
- metadata +98 -4
- data/app/assets/stylesheets/c80_yax/mixins.scss +0 -89
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
var admin = {
|
3
|
+
|
4
|
+
init: function(){
|
5
|
+
admin.set_admin_editable_events();
|
6
|
+
},
|
7
|
+
|
8
|
+
set_admin_editable_events: function(){
|
9
|
+
$(".admin-editable").on("keypress", function(e){
|
10
|
+
if ( e.keyCode==27 )
|
11
|
+
$( e.currentTarget ).hide();
|
12
|
+
|
13
|
+
if ( e.keyCode==13 ){
|
14
|
+
var path = $( e.currentTarget ).attr("data-path");
|
15
|
+
var attr = $( e.currentTarget ).attr("data-attr");
|
16
|
+
var resource_id = $( e.currentTarget ).attr("data-resource-id");
|
17
|
+
var resour_slug = $( e.currentTarget ).attr("data-resource-slug");
|
18
|
+
var val = $( e.currentTarget ).val();
|
19
|
+
|
20
|
+
val = $.trim(val);
|
21
|
+
if (val.length==0)
|
22
|
+
val = " ";
|
23
|
+
|
24
|
+
$("div#"+$( e.currentTarget ).attr("id")).html(val);
|
25
|
+
$( e.currentTarget ).hide();
|
26
|
+
|
27
|
+
var payload = {};
|
28
|
+
resource_class = path.slice(0,-1); // e.g. path = meters, resource_class = meter
|
29
|
+
payload[resource_class] = {};
|
30
|
+
payload[resource_class][attr] = val;
|
31
|
+
|
32
|
+
// NOTE:: исправить непонятку, когда сервер отвечает 302 ответ, скрипт считает, что ответ неудачный, и шлёт запрос 20 раз, в итоге, всё завершается исполнением error колбэка, но данные на сервере изменены
|
33
|
+
|
34
|
+
$.ajax({
|
35
|
+
url: "/admin/"+path+"/"+resour_slug,
|
36
|
+
data: payload,
|
37
|
+
type: 'POST'
|
38
|
+
}).done(function() {
|
39
|
+
//alert( "success" );
|
40
|
+
})
|
41
|
+
.fail(function(jqXHR, textStatus) {
|
42
|
+
//alert( textStatus );
|
43
|
+
})
|
44
|
+
.always(function() {
|
45
|
+
//alert( "complete" );
|
46
|
+
});
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
$(".admin-editable").on("blur", function(e){
|
51
|
+
$( e.currentTarget ).hide();
|
52
|
+
});
|
53
|
+
},
|
54
|
+
|
55
|
+
editable_text_column_do: function(el){
|
56
|
+
var input = "input#"+$(el).attr("id")
|
57
|
+
|
58
|
+
$(input).width( $(el).width()+4 ).height( $(el).height()+4 );
|
59
|
+
$(input).css({top: ( $(el).offset().top-2 ), left: ( $(el).offset().left-2 ), position:'absolute'});
|
60
|
+
|
61
|
+
val = $.trim( $(el).html() );
|
62
|
+
if (val==" ")
|
63
|
+
val = "";
|
64
|
+
|
65
|
+
$(input).val( val );
|
66
|
+
$(input).show();
|
67
|
+
$(input).focus();
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
$( document ).ready(function() {
|
72
|
+
admin.init();
|
73
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// initialize your global object will all your model names
|
2
|
+
var C80_YAX = {
|
3
|
+
|
4
|
+
};
|
5
|
+
|
6
|
+
jQuery(document).ready(function ($) {
|
7
|
+
// get the page action
|
8
|
+
var action, model, b = $("body");
|
9
|
+
if (b.hasClass("edit")) {
|
10
|
+
action = "edit";
|
11
|
+
} else if (b.hasClass("view")) {
|
12
|
+
action = "view";
|
13
|
+
} else if (b.hasClass("index")) {
|
14
|
+
action = "index"
|
15
|
+
} else if (b.hasClass("new")) {
|
16
|
+
action = "new"
|
17
|
+
}
|
18
|
+
|
19
|
+
// run the code specific to a model and an action
|
20
|
+
for (var m in C80_YAX) {
|
21
|
+
if (b.hasClass("admin_" + m)) {
|
22
|
+
if (C80_YAX[m][action] && typeof C80_YAX[m][action] == "function") {
|
23
|
+
C80_YAX[m][action]();
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
$red: #DF0019;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@mixin color_button($color: #ffffff, $bg_color: #3190e7) {
|
2
|
+
display: inline-block;
|
3
|
+
position: relative;
|
4
|
+
|
5
|
+
/*font-family: "Open Sans" !important;*/
|
6
|
+
font-weight: bold;
|
7
|
+
font-size: 14px;
|
8
|
+
line-height: 16px;
|
9
|
+
text-decoration: none !important;
|
10
|
+
text-shadow: none;
|
11
|
+
color: $color !important;
|
12
|
+
|
13
|
+
border: 1px solid $bg_color !important;
|
14
|
+
border-radius: 3px !important;
|
15
|
+
padding: 13px 15px;
|
16
|
+
margin: 0;
|
17
|
+
background: $bg_color;
|
18
|
+
box-shadow: none;
|
19
|
+
|
20
|
+
transition: all 0.2s ease-in-out;
|
21
|
+
-webkit-transition: all 0.2s ease-in-out;
|
22
|
+
-moz-transition: all 0.2s ease-in-out;
|
23
|
+
-ms-transition: all 0.2s ease-in-out;
|
24
|
+
-o-transition: all 0.2s ease-in-out;
|
25
|
+
|
26
|
+
&:hover {
|
27
|
+
background-color: darken($bg_color, 10%) !important;
|
28
|
+
background-image: none !important;
|
29
|
+
color: lighten($color, 10%) !important;
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
// тень
|
2
|
+
@mixin shdw($val) {
|
3
|
+
-webkit-box-shadow: 0 0 7px 0 rgba(0, 0, 0, $val);
|
4
|
+
-moz-box-shadow: 0 0 7px 0 rgba(0, 0, 0, $val);
|
5
|
+
box-shadow: 0 0 7px 0 rgba(0, 0, 0, $val);
|
6
|
+
/* For IE 8 */
|
7
|
+
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=$val, Direction=135, Color='#000000')";
|
8
|
+
/* For IE 5.5 - 7 */
|
9
|
+
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=$val, Direction=135, Color='#000000');
|
10
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
.checkbox label:after,
|
2
|
+
.radio label:after {
|
3
|
+
content: '';
|
4
|
+
display: table;
|
5
|
+
clear: both;
|
6
|
+
}
|
7
|
+
|
8
|
+
.checkbox .cr,
|
9
|
+
.radio .cr {
|
10
|
+
position: relative;
|
11
|
+
display: inline-block;
|
12
|
+
border: 1px solid #a9a9a9;
|
13
|
+
border-radius: 0;
|
14
|
+
width: 32px;
|
15
|
+
height: 32px;
|
16
|
+
float: left;
|
17
|
+
margin-right: .5em;
|
18
|
+
}
|
19
|
+
|
20
|
+
.radio .cr {
|
21
|
+
border-radius: 50%;
|
22
|
+
}
|
23
|
+
|
24
|
+
.checkbox .cr .cr-icon,
|
25
|
+
.radio .cr .cr-icon {
|
26
|
+
position: absolute;
|
27
|
+
font-size: 25px;
|
28
|
+
line-height: 0;
|
29
|
+
left: 2px;
|
30
|
+
top: 50%;
|
31
|
+
}
|
32
|
+
|
33
|
+
.radio .cr .cr-icon {
|
34
|
+
margin-left: 0.04em;
|
35
|
+
}
|
36
|
+
|
37
|
+
.checkbox label input[type="checkbox"],
|
38
|
+
.radio label input[type="radio"] {
|
39
|
+
display: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
.checkbox label input[type="checkbox"] + .cr > .cr-icon,
|
43
|
+
.radio label input[type="radio"] + .cr > .cr-icon {
|
44
|
+
transform: scale(3) rotateZ(-20deg);
|
45
|
+
opacity: 0;
|
46
|
+
transition: all .3s ease-in;
|
47
|
+
}
|
48
|
+
|
49
|
+
.checkbox label input[type="checkbox"]:checked + .cr > .cr-icon,
|
50
|
+
.radio label input[type="radio"]:checked + .cr > .cr-icon {
|
51
|
+
transform: scale(1) rotateZ(0deg);
|
52
|
+
opacity: 1;
|
53
|
+
}
|
54
|
+
|
55
|
+
.checkbox label input[type="checkbox"]:disabled + .cr,
|
56
|
+
.radio label input[type="radio"]:disabled + .cr {
|
57
|
+
opacity: .5;
|
58
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
@import 'c80_yax/_mixins/**/*';
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module Items
|
3
|
+
module AsterixHelper
|
4
|
+
|
5
|
+
def render_asterix
|
6
|
+
# TODO-5:: перенести этот текст в базу, в свойства модуля
|
7
|
+
a = '*точная стоимость будет озвучена нашим менеджером при телефонном разговоре с клиентом'
|
8
|
+
"<p>#{a}</p>".html_safe
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module Items
|
3
|
+
module BuyOptionsHelper
|
4
|
+
|
5
|
+
def render_buy_options
|
6
|
+
|
7
|
+
elems = [
|
8
|
+
{
|
9
|
+
label: 'Нестандартные цвета<br>(+20% к стоимости)',
|
10
|
+
value: '1',
|
11
|
+
style: 'small'
|
12
|
+
},
|
13
|
+
{
|
14
|
+
label: 'Цвета с металлическим блеском<br>(+20% к стоимости)',
|
15
|
+
value: '2',
|
16
|
+
style: 'small'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: 'Заказать доставку',
|
20
|
+
value: '3',
|
21
|
+
style: 'huge'
|
22
|
+
}
|
23
|
+
]
|
24
|
+
|
25
|
+
render :partial => 'c80_yax/items/buy_options',
|
26
|
+
:locals => {
|
27
|
+
elems: elems
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module Items
|
3
|
+
module ItemViewHelper
|
4
|
+
|
5
|
+
# вывести первого попавшегося Производителя, назначенного Товару
|
6
|
+
def print_vendor(itm)
|
7
|
+
str = '-'
|
8
|
+
# noinspection RubyResolve
|
9
|
+
if itm.vendors.count > 0
|
10
|
+
str = itm.vendors.first.title
|
11
|
+
end
|
12
|
+
str
|
13
|
+
end
|
14
|
+
|
15
|
+
def item_print_full_desc(itm)
|
16
|
+
r = ''
|
17
|
+
# noinspection RubyResolve
|
18
|
+
r = itm.full_desc if itm.full_desc.present?
|
19
|
+
r.html_safe
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module Items
|
3
|
+
module Photos
|
4
|
+
module ItemPhotosHelper
|
5
|
+
|
6
|
+
# вывести первую фотку и кол-во всего
|
7
|
+
# noinspection RubyResolve
|
8
|
+
def item_photos_short(item)
|
9
|
+
r = ''
|
10
|
+
if item.iphotos.count > 0
|
11
|
+
r = link_to image_tag(item.iphotos.first.image.thumb_md,
|
12
|
+
style: 'width:150px'),
|
13
|
+
item.iphotos.first.image.url,
|
14
|
+
target: '_blank'
|
15
|
+
r = "#{r}<br><sup>Всего фотографий: #{item.iphotos.count}</sup>".html_safe
|
16
|
+
end
|
17
|
+
r
|
18
|
+
end
|
19
|
+
|
20
|
+
# вывести lazy magnific popup slider фотографий товара
|
21
|
+
# С помощью +thumb_type+ можно задать, какие версии фотографий будут использованы в слайдере
|
22
|
+
def item_photos(item, thumb_type = 'thumb_lg')
|
23
|
+
|
24
|
+
# TODO-0:: реализовать gem и использовать его тут в том виде, какой описан в комментах
|
25
|
+
#
|
26
|
+
# photos = {
|
27
|
+
# thumb_list: ['image01_thumb_lg.jpg'], # на основе этого строится slider
|
28
|
+
# big_list: ['image01.jpg'] # эти фотки magnific открываются
|
29
|
+
# }
|
30
|
+
# c80_lazy_maginific_popup_slider(photos)
|
31
|
+
|
32
|
+
r = ''
|
33
|
+
if item.iphotos.count > 0
|
34
|
+
r = image_tag(item.iphotos.first.image.send(thumb_type))
|
35
|
+
end
|
36
|
+
r.html_safe
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module Items
|
3
|
+
module RenderShowItemHelper
|
4
|
+
|
5
|
+
# render partial, отображающий полуню информацию о товаре +item+
|
6
|
+
# с помощью +is_render_title+ можно отключить печать названия товара
|
7
|
+
def render_show_item(item, is_render_title = true)
|
8
|
+
render partial: 'c80_yax/items/show',
|
9
|
+
locals: {
|
10
|
+
item: item,
|
11
|
+
is_render_title: is_render_title
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module Strsubcats
|
3
|
+
|
4
|
+
# помогает оформлять списки свойств подкатегории
|
5
|
+
|
6
|
+
# noinspection ALL
|
7
|
+
module PropsHelper
|
8
|
+
|
9
|
+
# include C80Yax::UomHelper
|
10
|
+
|
11
|
+
# выдать название родительской категории в виде active_admin-ссылки
|
12
|
+
def cat_admin_title(strsubcat)
|
13
|
+
str = '-'
|
14
|
+
if strsubcat.cats.count > 0
|
15
|
+
c = strsubcat.cats.first
|
16
|
+
t = c.title
|
17
|
+
slug = c.slug
|
18
|
+
str = "<a href='/admin/cats/#{slug}' title='#{t}'>#{t}</a>"
|
19
|
+
end
|
20
|
+
str.html_safe
|
21
|
+
end
|
22
|
+
|
23
|
+
# выдать html unordered list всех характеристик, которыми описывается подкатегория
|
24
|
+
def all_props_list(strsubcat)
|
25
|
+
res = '-'
|
26
|
+
if strsubcat.prop_names.count > 0
|
27
|
+
res = ''
|
28
|
+
strsubcat.prop_names.each do |prop_name|
|
29
|
+
res += "• #{title_with_uom(prop_name)}<br>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
res.html_safe
|
33
|
+
end
|
34
|
+
|
35
|
+
# выдать html unordered list of 'main props'
|
36
|
+
def main_props_list(strsubcat)
|
37
|
+
res = ''
|
38
|
+
C80Yax::MainProp.select_props_sql(strsubcat.id).each do |el|
|
39
|
+
s = el[3]
|
40
|
+
s += pretty_uom_print_title(el[4]) unless el[4].nil?
|
41
|
+
res += "• #{s}<br>"
|
42
|
+
end
|
43
|
+
res.html_safe
|
44
|
+
end
|
45
|
+
|
46
|
+
# выдать html unordered list of 'price props'
|
47
|
+
def price_props_list(strsubcat)
|
48
|
+
res = ''
|
49
|
+
C80Yax::PriceProp.select_props_sql(strsubcat.id).each do |el|
|
50
|
+
s = el[2]
|
51
|
+
s += pretty_uom_print_title(el[3]) unless el[3].nil?
|
52
|
+
res += "• #{s}<br>"
|
53
|
+
end
|
54
|
+
res.html_safe
|
55
|
+
end
|
56
|
+
|
57
|
+
# выдать html unordered list of 'common props'
|
58
|
+
def common_props_list(strsubcat)
|
59
|
+
res = ''
|
60
|
+
C80Yax::CommonProp.select_props_sql(strsubcat.id).each do |el|
|
61
|
+
s = el[3]
|
62
|
+
s += pretty_uom_print_title(el[4]) unless el[4].nil?
|
63
|
+
res += "• #{s}<br>"
|
64
|
+
end
|
65
|
+
res.html_safe
|
66
|
+
end
|
67
|
+
|
68
|
+
# выдать html unordered list of 'common props'
|
69
|
+
def prefix_props_list(strsubcat)
|
70
|
+
res = ''
|
71
|
+
C80Yax::PrefixProp.select_props_sql(strsubcat.id).each do |el|
|
72
|
+
s = el[3]
|
73
|
+
s += pretty_uom_print_title(el[4]) unless el[4].nil?
|
74
|
+
res += "• #{s}<br>"
|
75
|
+
end
|
76
|
+
res.html_safe
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module C80Yax
|
2
|
+
module UomHelper
|
3
|
+
|
4
|
+
# на вход подаётся Uom
|
5
|
+
# выдать оформленную html строку, которая содержит единицу измерения
|
6
|
+
def pretty_uom_print(uom)
|
7
|
+
return '' if uom.nil?
|
8
|
+
str = uom.title
|
9
|
+
pretty_uom_print_title(str)
|
10
|
+
end
|
11
|
+
|
12
|
+
# на вход подаётся строка
|
13
|
+
# выдать оформленную html строку, которая содержит единицу измерения
|
14
|
+
def pretty_uom_print_title(str)
|
15
|
+
" (<span class='c80_md_link_color'>#{str}</span>)".html_safe
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'babosa'
|
2
|
+
|
3
|
+
class C80Yax::Cat < ActiveRecord::Base
|
4
|
+
|
5
|
+
validates :title,
|
6
|
+
presence: true,
|
7
|
+
uniqueness: true,
|
8
|
+
length: { in: 6..50 }
|
9
|
+
|
10
|
+
has_and_belongs_to_many :strsubcats
|
11
|
+
|
12
|
+
extend FriendlyId
|
13
|
+
friendly_id :slug_candidates, :use => :slugged
|
14
|
+
|
15
|
+
def slug_candidates
|
16
|
+
[:title] + Array.new(6) {|index| [:title, index+2]}
|
17
|
+
end
|
18
|
+
|
19
|
+
def normalize_friendly_id(input)
|
20
|
+
input.to_s.to_slug.normalize(transliterations: :russian).to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
scope :menu_order, -> {order(:ord => :asc)}
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module C80Yax
|
2
|
+
class CommonProp < ActiveRecord::Base
|
3
|
+
belongs_to :strsubcat
|
4
|
+
has_and_belongs_to_many :prop_names
|
5
|
+
|
6
|
+
include C80Yax::Concerns::Props::Parsable
|
7
|
+
|
8
|
+
# +--------------+----------------+--------------+--------------------------------------------------------+---------------+
|
9
|
+
# | strsubcat_id | common_prop_id | prop_name_id | title | uom_title |
|
10
|
+
# +--------------+----------------+--------------+--------------------------------------------------------+---------------+
|
11
|
+
# | 7 | 1 | 37 | Артикул | NULL |
|
12
|
+
# | 7 | 2 | 30 | Пустотность | NULL |
|
13
|
+
# | 7 | 3 | 38 | Формат | NULL |
|
14
|
+
# | 7 | 4 | 23 | Размер | NULL |
|
15
|
+
# | 7 | 5 | 36 | Бренд | NULL |
|
16
|
+
# | 7 | 6 | 46 | Завод | NULL |
|
17
|
+
# | 7 | 7 | 24 | Страна | NULL |
|
18
|
+
# | 7 | 8 | 25 | Прочность на сжатие | кгс/см² |
|
19
|
+
# | 7 | 9 | 27 | Марка по морозостойкости | NULL |
|
20
|
+
# | 7 | 10 | 28 | Водопоглощение | % |
|
21
|
+
# | 7 | 11 | 67 | Средняя плотность | кг/м³ |
|
22
|
+
# | 7 | 12 | 70 | Класс средней плотности | NULL |
|
23
|
+
# | 7 | 13 | 26 | Коэффициент теплопроводности | Вт/(м°C) |
|
24
|
+
# | 7 | 14 | 71 | Коэффициент теплопроводности (условия эксплуатации A) | Вт/(м°C) |
|
25
|
+
# | 7 | 15 | 72 | Коэффициент теплопроводности (условия эксплуатации Б) | Вт/(м°C) |
|
26
|
+
# | 7 | 16 | 33 | Вес | кг |
|
27
|
+
# | 7 | 17 | 34 | Количество на поддоне | шт |
|
28
|
+
# | 7 | 18 | 58 | Норма загрузки | шт |
|
29
|
+
# +--------------+----------------+--------------+--------------------------------------------------------+---------------+
|
30
|
+
|
31
|
+
def self.select_props_sql(strsubcat_id)
|
32
|
+
sql = "
|
33
|
+
SELECT
|
34
|
+
c80_yax_common_props.strsubcat_id,
|
35
|
+
c80_yax_common_props_prop_names.*,
|
36
|
+
c80_yax_prop_names.title,
|
37
|
+
c80_yax_uoms.title as uom_title
|
38
|
+
FROM c80_yax_common_props
|
39
|
+
LEFT JOIN c80_yax_common_props_prop_names ON c80_yax_common_props.id = c80_yax_common_props_prop_names.common_prop_id
|
40
|
+
LEFT JOIN c80_yax_prop_names ON c80_yax_common_props_prop_names.prop_name_id = c80_yax_prop_names.id
|
41
|
+
LEFT JOIN c80_yax_uoms ON c80_yax_prop_names.uom_id = c80_yax_uoms.id
|
42
|
+
WHERE c80_yax_common_props.strsubcat_id = #{strsubcat_id};
|
43
|
+
"
|
44
|
+
rows = ActiveRecord::Base.connection.execute(sql)
|
45
|
+
rows
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|