caboose-store 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose_store/modules/product.js +17 -8
- data/app/controllers/caboose_store/checkout_controller.rb +9 -0
- data/app/controllers/caboose_store/products_controller.rb +48 -3
- data/app/models/caboose_store/product.rb +13 -1
- data/app/models/caboose_store/schema.rb +4 -1
- data/app/views/caboose_store/products/_admin_header.html.erb +5 -5
- data/app/views/caboose_store/products/admin_edit_variant_sort_order.html.erb +63 -0
- data/app/views/caboose_store/products/admin_edit_variants.html.erb +64 -48
- data/config/routes.rb +6 -2
- data/lib/caboose-store/version.rb +1 -1
- data/lib/tasks/caboose-store.rake +12 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTE4N2M4ZWE4NjYwZDEzYzM2MmY3YTA5Y2ViNjc5ZjgwNWU5Yjc2MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWZmZmYzNzMyMjJjYjA4MWRjOTk2YTI3ZWNhYzllNDU4NzZlNGI0Yw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yjg2MzI2OThmMWM1OTk3MzkxMThiM2ZlODk4M2Y4OGVlOWIxMjE5YTM1YjQ2
|
10
|
+
YWNhNzc0YWYzMmE3OTkzZmQzN2M2NWUyNzRhNTA5MjU4NGVkODM2MTk2MzM0
|
11
|
+
MjY4YTk3MzNlOTE1YmY2Y2U0ZWQyM2JmYWY2MDU0N2RhZDZmY2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDg1OTllZjE0MWJhMDY4MDAzMzA0MmU3MmI3NTFhYTcwMjRjNGQ4YzU4YTY4
|
14
|
+
M2FkYmY0MTkzZmU3MGM0ZjVlZjIxNDE3YTc0MzdhY2FkMTI0MTg0NGE4NjU0
|
15
|
+
NjZlZTI3ZTg4ZDliZjg4YzgyOTc0OWJlOTkzNDNjYjJiOWIwMDU=
|
@@ -21,6 +21,9 @@ Caboose.Store.Modules.Product = (function() {
|
|
21
21
|
|
22
22
|
$.get('/products/' + self.$product.data('id') + '/info', function(response) {
|
23
23
|
self.product = response.product;
|
24
|
+
self.option1_values = response.option1_values;
|
25
|
+
self.option2_values = response.option2_values;
|
26
|
+
self.option3_values = response.option3_values;
|
24
27
|
self.render();
|
25
28
|
self.bindEvents();
|
26
29
|
self.setVariant(self.getInitialVariant());
|
@@ -173,14 +176,20 @@ Caboose.Store.Modules.Product = (function() {
|
|
173
176
|
};
|
174
177
|
|
175
178
|
self.getOptionsWithAllValues = function() {
|
176
|
-
return _.map(self.getOptionsFromProduct(), function(optionName) {
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
});
|
179
|
+
//return _.map(self.getOptionsFromProduct(), function(optionName) {
|
180
|
+
// return {
|
181
|
+
// name: optionName,
|
182
|
+
// values: _.uniq(_.map(self.product.variants, function(variant) {
|
183
|
+
// return variant[self.getOptionAttribute(optionName)];
|
184
|
+
// }))
|
185
|
+
// };
|
186
|
+
//});
|
187
|
+
|
188
|
+
var options = [];
|
189
|
+
if (self.product.option1) options.push({ name: self.product.option1, values: self.option1_values });
|
190
|
+
if (self.product.option2) options.push({ name: self.product.option2, values: self.option2_values });
|
191
|
+
if (self.product.option3) options.push({ name: self.product.option3, values: self.option3_values });
|
192
|
+
return options;
|
184
193
|
};
|
185
194
|
|
186
195
|
self.getOptionAttribute = function(option) {
|
@@ -37,6 +37,15 @@ module CabooseStore
|
|
37
37
|
redirect_to '/checkout/step-two' and return if @order.shipping_address.nil? || @order.billing_address.nil?
|
38
38
|
redirect_to '/checkout/step-three' and return if @order.shipping_code.nil?
|
39
39
|
|
40
|
+
# Make sure all the variants still exist
|
41
|
+
@order.line_items.each do |li|
|
42
|
+
v = Variant.where(:id => li.variant_id).first
|
43
|
+
if v.nil? || v.status == 'Deleted'
|
44
|
+
render :file => 'caboose_store/checkout/deleted_variant'
|
45
|
+
return
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
40
49
|
case CabooseStore::payment_processor
|
41
50
|
when 'authorize.net'
|
42
51
|
@sim_transaction = AuthorizeNet::SIM::Transaction.new(
|
@@ -97,7 +97,13 @@ module CabooseStore
|
|
97
97
|
|
98
98
|
# GET /product/info
|
99
99
|
def info
|
100
|
-
|
100
|
+
p = Product.find(params[:id])
|
101
|
+
render :json => {
|
102
|
+
:product => p,
|
103
|
+
:option1_values => p.option1_values,
|
104
|
+
:option2_values => p.option2_values,
|
105
|
+
:option3_values => p.option3_values
|
106
|
+
}
|
101
107
|
end
|
102
108
|
|
103
109
|
# GET /api/products
|
@@ -458,6 +464,13 @@ module CabooseStore
|
|
458
464
|
render :layout => 'caboose/admin'
|
459
465
|
end
|
460
466
|
|
467
|
+
# GET /admin/products/:id/variants/sort-order
|
468
|
+
def admin_edit_variant_sort_order
|
469
|
+
return if !user_is_allowed('products', 'edit')
|
470
|
+
@product = Product.find(params[:id])
|
471
|
+
render :layout => 'caboose/admin'
|
472
|
+
end
|
473
|
+
|
461
474
|
# GET /admin/products/:id/delete
|
462
475
|
def admin_delete_form
|
463
476
|
return if !user_is_allowed('products', 'edit')
|
@@ -638,8 +651,40 @@ module CabooseStore
|
|
638
651
|
def admin_update_sort_order
|
639
652
|
params[:product_ids].each_with_index do |product_id, index|
|
640
653
|
Product.find(product_id.to_i).update_attribute(:sort_order, index)
|
641
|
-
end
|
642
|
-
|
654
|
+
end
|
655
|
+
render :json => { :success => true }
|
656
|
+
end
|
657
|
+
|
658
|
+
# PUT /admin/products/:id/variants/option1-sort-order
|
659
|
+
def admin_update_variant_option1_sort_order
|
660
|
+
product_id = params[:id]
|
661
|
+
params[:values].each_with_index do |value, i|
|
662
|
+
Variant.where(:product_id => product_id, :option1 => value).all.each do |v|
|
663
|
+
v.update_attribute(:option1_sort_order, i)
|
664
|
+
end
|
665
|
+
end
|
666
|
+
render :json => { :success => true }
|
667
|
+
end
|
668
|
+
|
669
|
+
# PUT /admin/products/:id/variants/option1-sort-order
|
670
|
+
def admin_update_variant_option2_sort_order
|
671
|
+
product_id = params[:id]
|
672
|
+
params[:values].each_with_index do |value, i|
|
673
|
+
Variant.where(:product_id => product_id, :option2 => value).all.each do |v|
|
674
|
+
v.update_attribute(:option2_sort_order, i)
|
675
|
+
end
|
676
|
+
end
|
677
|
+
render :json => { :success => true }
|
678
|
+
end
|
679
|
+
|
680
|
+
# PUT /admin/products/:id/variants/option1-sort-order
|
681
|
+
def admin_update_variant_option3_sort_order
|
682
|
+
product_id = params[:id]
|
683
|
+
params[:values].each_with_index do |value, i|
|
684
|
+
Variant.where(:product_id => product_id, :option3 => value).all.each do |v|
|
685
|
+
v.update_attribute(:option3_sort_order, i)
|
686
|
+
end
|
687
|
+
end
|
643
688
|
render :json => { :success => true }
|
644
689
|
end
|
645
690
|
end
|
@@ -8,7 +8,7 @@ module CabooseStore
|
|
8
8
|
has_many :customization_memberships, :class_name => 'CabooseStore::CustomizationMembership'
|
9
9
|
has_many :categories, :class_name => 'CabooseStore::Category', :through => :category_memberships
|
10
10
|
has_many :category_memberships, :class_name => 'CabooseStore::CategoryMembership'
|
11
|
-
has_many :variants, :class_name => 'CabooseStore::Variant'
|
11
|
+
has_many :variants, :class_name => 'CabooseStore::Variant', :order => 'sort_order'
|
12
12
|
has_many :product_images, :class_name => 'CabooseStore::ProductImage'
|
13
13
|
has_many :proudct_inputs, :class_name => 'CabooseStore::ProductInput'
|
14
14
|
has_many :reviews, :class_name => 'CabooseStore::Review'
|
@@ -130,5 +130,17 @@ module CabooseStore
|
|
130
130
|
# Return variants that haven't been "deleted"
|
131
131
|
self.variants.where(:status => ['Active', 'Inactive'])
|
132
132
|
end
|
133
|
+
|
134
|
+
def option1_values
|
135
|
+
arr = self.variants.reorder(:option1_sort_order).pluck(:option1).uniq.reject { |x| x.nil? || x.empty? }
|
136
|
+
end
|
137
|
+
|
138
|
+
def option2_values
|
139
|
+
self.variants.reorder(:option2_sort_order).pluck(:option2).uniq.reject { |x| x.nil? || x.empty? }
|
140
|
+
end
|
141
|
+
|
142
|
+
def option3_values
|
143
|
+
self.variants.reorder(:option3_sort_order).pluck(:option3).uniq.reject { |x| x.nil? || x.empty? }
|
144
|
+
end
|
133
145
|
end
|
134
146
|
end
|
@@ -197,7 +197,10 @@ class CabooseStore::Schema < Caboose::Utilities::Schema
|
|
197
197
|
[ :product_id , :integer ],
|
198
198
|
[ :shipping_unit_value , :numeric ],
|
199
199
|
[ :alternate_id , :string ],
|
200
|
-
[ :status , :string ]
|
200
|
+
[ :status , :string ],
|
201
|
+
[ :option1_sort_order , :integer , { :defult => 0 }],
|
202
|
+
[ :option2_sort_order , :integer , { :defult => 0 }],
|
203
|
+
[ :option3_sort_order , :integer , { :defult => 0 }]
|
201
204
|
],
|
202
205
|
|
203
206
|
CabooseStore::Vendor => [
|
@@ -15,11 +15,11 @@ tabs = {
|
|
15
15
|
"/admin/products/#{@product.id}/categories" => 'Categories'
|
16
16
|
}
|
17
17
|
|
18
|
-
tabs["/admin/products/#{@product.id}/options"
|
19
|
-
tabs["/admin/products/#{@product.id}/variants"
|
20
|
-
|
21
|
-
tabs["/admin/products/#{@product.id}/images"
|
22
|
-
tabs["/admin/products/#{@product.id}/delete"
|
18
|
+
tabs["/admin/products/#{@product.id}/options" ] = 'Options <span style="font-size: 65%">(size, color, style, etc.)</span>' if @product.options && @product.options.count > 0
|
19
|
+
tabs["/admin/products/#{@product.id}/variants/sort-order" ] = 'Sort Option Values' if @product.options && @product.options.count > 0
|
20
|
+
tabs["/admin/products/#{@product.id}/variants" ] = 'Inventory & Variants'
|
21
|
+
tabs["/admin/products/#{@product.id}/images" ] = 'Images'
|
22
|
+
tabs["/admin/products/#{@product.id}/delete" ] = 'Delete Product'
|
23
23
|
|
24
24
|
#tabs["/admin/products/#{@product.id}/seo" ] = 'SEO'
|
25
25
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<%
|
2
|
+
p = @product
|
3
|
+
%>
|
4
|
+
|
5
|
+
<%= render :partial => 'caboose_store/products/admin_header' %>
|
6
|
+
|
7
|
+
<div id='options'>
|
8
|
+
<% if p.option1 %><div id='option1_container'><h2><%= p.option1 %></h2><ul id='option1'><% p.option1_values.each do |option| %><li id='values_<%= option %>'><%= option %></li><% end %></ul></div><% end %>
|
9
|
+
<% if p.option2 %><div id='option2_container'><h2><%= p.option2 %></h2><ul id='option2'><% p.option2_values.each do |option| %><li id='values_<%= option %>'><%= option %></li><% end %></ul></div><% end %>
|
10
|
+
<% if p.option3 %><div id='option3_container'><h2><%= p.option3 %></h2><ul id='option3'><% p.option3_values.each do |option| %><li id='values_<%= option %>'><%= option %></li><% end %></ul></div><% end %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div id='message'></div>
|
14
|
+
|
15
|
+
<%= render :partial => 'caboose_store/products/admin_footer' %>
|
16
|
+
|
17
|
+
<% content_for :caboose_css do %>
|
18
|
+
<style type='text/css'>
|
19
|
+
#options div { width: 33%; float: left; }
|
20
|
+
#options ul { margin: 0 10px 0 0; padding: 0; list-style: none; }
|
21
|
+
#options li { margin: 0; padding: 4px 8px; list-style: none; border: #ccc 1px solid; }
|
22
|
+
#message { clear: left; }
|
23
|
+
</style>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% content_for :caboose_js do %>
|
27
|
+
<script type='text/javascript'>
|
28
|
+
|
29
|
+
$(document).ready(function() {
|
30
|
+
$('#option1').sortable({
|
31
|
+
update: function(event, ui) {
|
32
|
+
$.ajax({
|
33
|
+
url: '/admin/products/<%= p.id %>/variants/option1-sort-order',
|
34
|
+
type: 'put',
|
35
|
+
data: $('#option1').sortable('serialize'),
|
36
|
+
success: function(resp) {}
|
37
|
+
});
|
38
|
+
}
|
39
|
+
});
|
40
|
+
$('#option2').sortable({
|
41
|
+
update: function(event, ui) {
|
42
|
+
$.ajax({
|
43
|
+
url: '/admin/products/<%= p.id %>/variants/option2-sort-order',
|
44
|
+
type: 'put',
|
45
|
+
data: $('#option2').sortable('serialize'),
|
46
|
+
success: function(resp) {}
|
47
|
+
});
|
48
|
+
}
|
49
|
+
});
|
50
|
+
$('#option3').sortable({
|
51
|
+
update: function(event, ui) {
|
52
|
+
$.ajax({
|
53
|
+
url: '/admin/products/<%= p.id %>/variants/option3-sort-order',
|
54
|
+
type: 'put',
|
55
|
+
data: $('#option3').sortable('serialize'),
|
56
|
+
success: function(resp) {}
|
57
|
+
});
|
58
|
+
}
|
59
|
+
});
|
60
|
+
});
|
61
|
+
|
62
|
+
</script>
|
63
|
+
<% end %>
|
@@ -30,60 +30,64 @@ end
|
|
30
30
|
%></div>
|
31
31
|
|
32
32
|
<div id='variants_wrapper'>
|
33
|
-
<table id='variants'>
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
</
|
78
|
-
|
33
|
+
<table id='variants'>
|
34
|
+
<tr>
|
35
|
+
<th> </th>
|
36
|
+
<% if @cols['option1' ] && p.option1 %><th valign='bottom'><%= p.option1 %></th><% end %>
|
37
|
+
<% if @cols['option2' ] && p.option2 %><th valign='bottom'><%= p.option2 %></th><% end %>
|
38
|
+
<% if @cols['option3' ] && p.option3 %><th valign='bottom'><%= p.option3 %></th><% end %>
|
39
|
+
<% if @cols['status' ] == true %><th valign='bottom'>Status </th><% end %>
|
40
|
+
<% if @cols['alternate_id' ] == true %><th valign='bottom'>Alternate ID </th><% end %>
|
41
|
+
<% if @cols['barcode' ] == true %><th valign='bottom'>Barcode </th><% end %>
|
42
|
+
<% if @cols['price' ] == true %><th valign='bottom'>Price </th><% end %>
|
43
|
+
<% if @cols['quantity_in_stock' ] == true %><th valign='bottom'>Quantity </th><% end %>
|
44
|
+
<% if @cols['weight' ] == true %><th valign='bottom'>Weight </th><% end %>
|
45
|
+
<% if @cols['length' ] == true %><th valign='bottom'>Length </th><% end %>
|
46
|
+
<% if @cols['width' ] == true %><th valign='bottom'>Width </th><% end %>
|
47
|
+
<% if @cols['height' ] == true %><th valign='bottom'>Height </th><% end %>
|
48
|
+
<% if @cols['cylinder' ] == true %><th valign='bottom'>Cylinder </th><% end %>
|
49
|
+
<% if @cols['requires_shipping' ] == true %><th valign='bottom'>Requires Shipping </th><% end %>
|
50
|
+
<% if @cols['allow_backorder' ] == true %><th valign='bottom'>Allow Backorder </th><% end %>
|
51
|
+
<% if @cols['taxable' ] == true %><th valign='bottom'>Taxable </th><% end %>
|
52
|
+
<th> </th>
|
53
|
+
<th> </th>
|
54
|
+
</tr>
|
55
|
+
<tbody id='variants_tbody'>
|
56
|
+
<% p.variants.where(:status => ['Active', 'Inactive']).each do |v| %>
|
57
|
+
<tr id='variant_<%= v.id %>' <% if @highlight_variant_id && v.id == @highlight_variant_id %>class='highlight'<% end %>>
|
58
|
+
<td class='sort_handle'> </td>
|
59
|
+
<% if @cols['option1' ] && p.option1 %><td><div id='variant_<%= v.id %>_option1' ></div></td><% end %>
|
60
|
+
<% if @cols['option2' ] && p.option2 %><td><div id='variant_<%= v.id %>_option2' ></div></td><% end %>
|
61
|
+
<% if @cols['option3' ] && p.option3 %><td><div id='variant_<%= v.id %>_option3' ></div></td><% end %>
|
62
|
+
<% if @cols['status' ] == true %><td><div id='variant_<%= v.id %>_status' ></div></td><% end %>
|
63
|
+
<% if @cols['alternate_id' ] == true %><td><div id='variant_<%= v.id %>_alternate_id' ></div></td><% end %>
|
64
|
+
<% if @cols['barcode' ] == true %><td><div id='variant_<%= v.id %>_barcode' ></div></td><% end %>
|
65
|
+
<% if @cols['price' ] == true %><td><div id='variant_<%= v.id %>_price' ></div></td><% end %>
|
66
|
+
<% if @cols['quantity_in_stock' ] == true %><td><div id='variant_<%= v.id %>_quantity_in_stock' ></div></td><% end %>
|
67
|
+
<% if @cols['weight' ] == true %><td><div id='variant_<%= v.id %>_weight' ></div></td><% end %>
|
68
|
+
<% if @cols['length' ] == true %><td><div id='variant_<%= v.id %>_length' ></div></td><% end %>
|
69
|
+
<% if @cols['width' ] == true %><td><div id='variant_<%= v.id %>_width' ></div></td><% end %>
|
70
|
+
<% if @cols['height' ] == true %><td><div id='variant_<%= v.id %>_height' ></div></td><% end %>
|
71
|
+
<% if @cols['cylinder' ] == true %><td><div id='variant_<%= v.id %>_cylinder' ></div></td><% end %>
|
72
|
+
<% if @cols['requires_shipping' ] == true %><td><div id='variant_<%= v.id %>_requires_shipping' ></div></td><% end %>
|
73
|
+
<% if @cols['allow_backorder' ] == true %><td><div id='variant_<%= v.id %>_allow_backorder' ></div></td><% end %>
|
74
|
+
<% if @cols['taxable' ] == true %><td><div id='variant_<%= v.id %>_taxable' ></div></td><% end %>
|
75
|
+
<td class='edit'><a href='/admin/products/<%= p.id %>/variants/<%= v.id %>/edit'>Edit</a></td>
|
76
|
+
<td class='delete'><a href='#' onclick='delete_variant(<%= v.id %>);'>Delete</a></td>
|
77
|
+
</tr>
|
78
|
+
<% end %>
|
79
|
+
</tbody>
|
80
|
+
</table>
|
79
81
|
</div>
|
82
|
+
|
80
83
|
<p><input type='button' value='New Variant' onclick="add_variant(<%= p.id %>);" /></p>
|
81
84
|
|
82
85
|
<%= render :partial => 'caboose_store/products/admin_footer' %>
|
83
86
|
|
84
87
|
<% content_for :caboose_css do %>
|
85
88
|
<style type='text/css'>
|
86
|
-
tr.highlight td { background: #ffff99 }
|
89
|
+
tr.highlight td { background: #ffff99 }
|
90
|
+
td.sort_handle { background: #ccc; width: 20px; }
|
87
91
|
</style>
|
88
92
|
<% end %>
|
89
93
|
|
@@ -117,7 +121,19 @@ $(document).ready(function() {
|
|
117
121
|
<% if @cols['allow_backorder' ] == true %>{ name: 'allow_backorder' , nice_name: 'Allow backorder' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.allow_backorder ) %>, width: 50, fixed_placeholder: false } <% end %>
|
118
122
|
]
|
119
123
|
});
|
120
|
-
<% end %>
|
124
|
+
<% end %>
|
125
|
+
|
126
|
+
$('#variants_tbody').sortable({
|
127
|
+
handle: '.sort_handle',
|
128
|
+
update: function(event, ui) {
|
129
|
+
$.ajax({
|
130
|
+
url: '/admin/products/<%= p.id %>/variants/sort-order',
|
131
|
+
type: 'put',
|
132
|
+
data: $('#variants_tbody').sortable('serialize', { key: 'variant_ids[]' }),
|
133
|
+
success: function(resp) {}
|
134
|
+
});
|
135
|
+
}
|
136
|
+
});
|
121
137
|
});
|
122
138
|
|
123
139
|
var modal = false;
|
data/config/routes.rb
CHANGED
@@ -66,7 +66,7 @@ CabooseStore::Engine.routes.draw do
|
|
66
66
|
|
67
67
|
get "/admin/products" => "products#admin_index"
|
68
68
|
get '/admin/products/sort' => 'products#admin_sort'
|
69
|
-
put '/admin/products/update-sort-order' => 'products#admin_update_sort_order'
|
69
|
+
put '/admin/products/update-sort-order' => 'products#admin_update_sort_order'
|
70
70
|
put "/admin/products/update-vendor-status/:id" => "products#admin_update_vendor_status"
|
71
71
|
get "/admin/products/new" => "products#admin_new"
|
72
72
|
get "/admin/products/status-options" => "products#admin_status_options"
|
@@ -78,7 +78,11 @@ CabooseStore::Engine.routes.draw do
|
|
78
78
|
get "/admin/products/:id/variants" => "products#admin_edit_variants"
|
79
79
|
get "/admin/products/:id/variants/json" => "products#admin_variants_json"
|
80
80
|
get "/admin/products/:id/variant-cols" => "products#admin_edit_variant_columns"
|
81
|
-
put "/admin/products/:id/variant-cols" => "products#admin_update_variant_columns"
|
81
|
+
put "/admin/products/:id/variant-cols" => "products#admin_update_variant_columns"
|
82
|
+
get "/admin/products/:id/variants/sort-order" => "products#admin_edit_variant_sort_order"
|
83
|
+
put '/admin/products/:id/variants/option1-sort-order' => 'products#admin_update_variant_option1_sort_order'
|
84
|
+
put '/admin/products/:id/variants/option2-sort-order' => 'products#admin_update_variant_option2_sort_order'
|
85
|
+
put '/admin/products/:id/variants/option3-sort-order' => 'products#admin_update_variant_option3_sort_order'
|
82
86
|
get "/admin/products/:id/images" => "products#admin_edit_images"
|
83
87
|
post "/admin/products/:id/images" => "products#admin_add_image"
|
84
88
|
get "/admin/products/:id/collections" => "products#admin_edit_collections"
|
@@ -12,4 +12,16 @@ namespace :caboose_store do
|
|
12
12
|
|
13
13
|
desc "Loads data into caboose tables"
|
14
14
|
task :load_data => :environment do CabooseStore::Schema.load_data end
|
15
|
+
|
16
|
+
desc "Fix variant sort order"
|
17
|
+
task :set_variant_sort_order => :environment do
|
18
|
+
CabooseStore::Product.all.each do |p|
|
19
|
+
puts "Setting sort order for product #{p.id}..."
|
20
|
+
i = 1
|
21
|
+
CabooseStore::Variant.where(:product_id => p.id).reorder(:id).all.each do |v|
|
22
|
+
v.update_attribute('sort_order', i)
|
23
|
+
i = i + 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
15
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- app/views/caboose_store/products/admin_edit_options.html.erb
|
201
201
|
- app/views/caboose_store/products/admin_edit_seo.html.erb
|
202
202
|
- app/views/caboose_store/products/admin_edit_variant_columns.html.erb
|
203
|
+
- app/views/caboose_store/products/admin_edit_variant_sort_order.html.erb
|
203
204
|
- app/views/caboose_store/products/admin_edit_variants.html.erb
|
204
205
|
- app/views/caboose_store/products/admin_edit_variants_single.html.erb
|
205
206
|
- app/views/caboose_store/products/admin_group_variants.html.erb
|