caboose-cms 0.5.55 → 0.5.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/products_controller.rb +2 -76
- data/app/controllers/caboose/variants_controller.rb +140 -69
- data/app/models/caboose/page_cacher.rb +3 -1
- data/app/views/caboose/products/admin_edit_categories.html.erb +18 -46
- data/app/views/caboose/products/admin_edit_images.html.erb +12 -39
- data/app/views/caboose/products/admin_edit_variants.html.erb +36 -115
- data/app/views/caboose/products/admin_edit_variants_old.html.erb +171 -0
- data/app/views/caboose/products/admin_index.html.erb +1 -2
- data/config/routes.rb +17 -19
- data/lib/caboose/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTkzNGRkMmQ3YWRiMDVmOWE1NjA3MjExMTM5ZDI2NGI5MWUxODc3MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGI4NjU2ZGU5ZDUzOTQzMDc4NmVkZDcxMzRlOTUxMzIxMmJkZmYyOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzM1NzQ4MGE0MTAxMzIyNjQ5YzE3YWY2MDJjY2E2MjdiZThlYjI1NmQ2OWYx
|
10
|
+
MzA5YzE4MWYwZTUyYTJmNGQ2YzVjYmE2YjgxYzliZjU5ZTU2ZDdlYmE3NmM4
|
11
|
+
YTMyMGZlYTMxZGQ3ZWVmZGM5MjZiMjllNWY1OGVkM2EzMmFiYmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWY5NmJiOTdmNmVkZGRiYzExM2QyNTZkMmI3YjM4MWIxNmE2YmFiYTZjYmY0
|
14
|
+
MDVlOWFhODc5ZThhOGNhMTAzYzBiMjQ3NGUzZDdjMWQ1MzU0NGI1Mjc5NzMz
|
15
|
+
YWQwNTVkNDhmM2NlMjM5ZThiZWViOWNlMjQzMjgwZTEwY2JiNzI=
|
@@ -378,41 +378,6 @@ module Caboose
|
|
378
378
|
render :layout => 'caboose/admin'
|
379
379
|
end
|
380
380
|
|
381
|
-
# GET /admin/products/:id/variants
|
382
|
-
# GET /admin/products/:id/variants/:variant_id
|
383
|
-
def admin_edit_variants
|
384
|
-
return if !user_is_allowed('products', 'edit')
|
385
|
-
@product = Product.find(params[:id])
|
386
|
-
|
387
|
-
if @product.variants.nil? || @product.variants.count == 0
|
388
|
-
v = Variant.new
|
389
|
-
v.option1 = @product.default1 if @product.option1
|
390
|
-
v.option2 = @product.default2 if @product.option2
|
391
|
-
v.option3 = @product.default3 if @product.option3
|
392
|
-
v.status = 'Active'
|
393
|
-
@product.variants = [v]
|
394
|
-
@product.save
|
395
|
-
end
|
396
|
-
@variant = params[:variant_id] ? Variant.find(params[:variant_id]) : @product.variants[0]
|
397
|
-
session['variant_cols'] = self.default_variant_cols if session['variant_cols'].nil?
|
398
|
-
@cols = session['variant_cols']
|
399
|
-
|
400
|
-
@highlight_variant_id = params[:highlight] ? params[:highlight].to_i : nil
|
401
|
-
|
402
|
-
if @product.options.nil? || @product.options.count == 0
|
403
|
-
render 'caboose/products/admin_edit_variants_single', :layout => 'caboose/admin'
|
404
|
-
else
|
405
|
-
render 'caboose/products/admin_edit_variants', :layout => 'caboose/admin'
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
# GET /admin/products/:id/variants/json
|
410
|
-
def admin_variants_json
|
411
|
-
render :json => false if !user_is_allowed('products', 'edit')
|
412
|
-
p = Product.find(params[:id])
|
413
|
-
render :json => p.variants
|
414
|
-
end
|
415
|
-
|
416
381
|
# GET /admin/products/:id/variant-cols
|
417
382
|
def admin_edit_variant_columns
|
418
383
|
return if !user_is_allowed('products', 'edit')
|
@@ -560,13 +525,6 @@ module Caboose
|
|
560
525
|
render :layout => 'caboose/admin'
|
561
526
|
end
|
562
527
|
|
563
|
-
# GET /admin/products/:id/variants/sort-order
|
564
|
-
def admin_edit_variant_sort_order
|
565
|
-
return if !user_is_allowed('products', 'edit')
|
566
|
-
@product = Product.find(params[:id])
|
567
|
-
render :layout => 'caboose/admin'
|
568
|
-
end
|
569
|
-
|
570
528
|
# GET /admin/products/:id/delete
|
571
529
|
def admin_delete_form
|
572
530
|
return if !user_is_allowed('products', 'edit')
|
@@ -596,7 +554,7 @@ module Caboose
|
|
596
554
|
when 'seo_description' then product.seo_description = value
|
597
555
|
when 'status' then product.status = value
|
598
556
|
when 'category_id' then product.toggle_category(value[0], value[1])
|
599
|
-
when 'stackable_group_id' then product.stackable_group_id = value
|
557
|
+
when 'stackable_group_id' then product.stackable_group_id = value
|
600
558
|
when 'option1' then product.option1 = value
|
601
559
|
when 'option2' then product.option2 = value
|
602
560
|
when 'option3' then product.option3 = value
|
@@ -754,39 +712,7 @@ module Caboose
|
|
754
712
|
end
|
755
713
|
render :json => { :success => true }
|
756
714
|
end
|
757
|
-
|
758
|
-
# PUT /admin/products/:id/variants/option1-sort-order
|
759
|
-
def admin_update_variant_option1_sort_order
|
760
|
-
product_id = params[:id]
|
761
|
-
params[:values].each_with_index do |value, i|
|
762
|
-
Variant.where(:product_id => product_id, :option1 => value).all.each do |v|
|
763
|
-
v.update_attribute(:option1_sort_order, i)
|
764
|
-
end
|
765
|
-
end
|
766
|
-
render :json => { :success => true }
|
767
|
-
end
|
768
|
-
|
769
|
-
# PUT /admin/products/:id/variants/option1-sort-order
|
770
|
-
def admin_update_variant_option2_sort_order
|
771
|
-
product_id = params[:id]
|
772
|
-
params[:values].each_with_index do |value, i|
|
773
|
-
Variant.where(:product_id => product_id, :option2 => value).all.each do |v|
|
774
|
-
v.update_attribute(:option2_sort_order, i)
|
775
|
-
end
|
776
|
-
end
|
777
|
-
render :json => { :success => true }
|
778
|
-
end
|
779
|
-
|
780
|
-
# PUT /admin/products/:id/variants/option1-sort-order
|
781
|
-
def admin_update_variant_option3_sort_order
|
782
|
-
product_id = params[:id]
|
783
|
-
params[:values].each_with_index do |value, i|
|
784
|
-
Variant.where(:product_id => product_id, :option3 => value).all.each do |v|
|
785
|
-
v.update_attribute(:option3_sort_order, i)
|
786
|
-
end
|
787
|
-
end
|
788
|
-
render :json => { :success => true }
|
789
|
-
end
|
715
|
+
|
790
716
|
end
|
791
717
|
end
|
792
718
|
|
@@ -29,53 +29,61 @@ module Caboose
|
|
29
29
|
# Admin actions
|
30
30
|
#=============================================================================
|
31
31
|
|
32
|
+
# GET /admin/products/:product_id/variants/json
|
33
|
+
def admin_json
|
34
|
+
return if !user_is_allowed('products', 'view')
|
35
|
+
|
36
|
+
pager = Caboose::PageBarGenerator.new(params, {
|
37
|
+
'product_id' => params[:product_id]
|
38
|
+
}, {
|
39
|
+
'model' => 'Caboose::Variant',
|
40
|
+
'sort' => 'option1, option2, option3',
|
41
|
+
'desc' => false,
|
42
|
+
'base_url' => "/admin/products/#{params[:product_id]}/variants",
|
43
|
+
'items_per_page' => 100,
|
44
|
+
'use_url_params' => false
|
45
|
+
})
|
46
|
+
render :json => {
|
47
|
+
:pager => pager,
|
48
|
+
:models => pager.items
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
32
52
|
# GET /admin/variants/:variant_id/edit
|
33
53
|
# GET /admin/products/:product_id/variants/:variant_id/edit
|
34
54
|
def admin_edit
|
35
55
|
return if !user_is_allowed('variants', 'edit')
|
36
56
|
@variant = Variant.find(params[:variant_id])
|
37
57
|
@product = @variant.product
|
38
|
-
render :layout => 'caboose/admin'
|
58
|
+
render :layout => 'caboose/admin'
|
39
59
|
end
|
40
60
|
|
41
|
-
# GET /admin/variants
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
where = ''
|
47
|
-
values = []
|
48
|
-
|
49
|
-
if params[:category_ids]
|
50
|
-
joins << [:category_memberships]
|
51
|
-
where << 'store_category_memberships.category_id IN (?)'
|
52
|
-
values << params[:category_ids]
|
53
|
-
end
|
54
|
-
|
55
|
-
if params[:vendor_ids]
|
56
|
-
joins << [:vendor]
|
57
|
-
where << 'store_vendors.id IN (?)'
|
58
|
-
values << params[:vendor_ids]
|
59
|
-
end
|
61
|
+
# GET /admin/products/:id/variants
|
62
|
+
# GET /admin/products/:id/variants/:variant_id
|
63
|
+
def admin_edit_variants
|
64
|
+
return if !user_is_allowed('products', 'edit')
|
65
|
+
@product = Product.find(params[:id])
|
60
66
|
|
61
|
-
if
|
62
|
-
|
63
|
-
|
67
|
+
if @product.variants.nil? || @product.variants.count == 0
|
68
|
+
v = Variant.new
|
69
|
+
v.option1 = @product.default1 if @product.option1
|
70
|
+
v.option2 = @product.default2 if @product.option2
|
71
|
+
v.option3 = @product.default3 if @product.option3
|
72
|
+
v.status = 'Active'
|
73
|
+
@product.variants = [v]
|
74
|
+
@product.save
|
64
75
|
end
|
76
|
+
@variant = params[:variant_id] ? Variant.find(params[:variant_id]) : @product.variants[0]
|
77
|
+
session['variant_cols'] = self.default_variant_cols if session['variant_cols'].nil?
|
78
|
+
@cols = session['variant_cols']
|
65
79
|
|
66
|
-
|
67
|
-
products = values.any? ? Caboose::Product.joins(joins).where([where].concat(values)) : []
|
68
|
-
|
69
|
-
# Grab variants for each product
|
70
|
-
@variants = products.collect { |product| product.variants }.flatten
|
71
|
-
|
72
|
-
# Grab all categories; except for all and uncategorized
|
73
|
-
@categories = Caboose::Category.where('parent_id IS NOT NULL')
|
80
|
+
@highlight_variant_id = params[:highlight] ? params[:highlight].to_i : nil
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
82
|
+
if @product.options.nil? || @product.options.count == 0
|
83
|
+
render 'caboose/products/admin_edit_variants_single', :layout => 'caboose/admin'
|
84
|
+
else
|
85
|
+
render 'caboose/products/admin_edit_variants', :layout => 'caboose/admin'
|
86
|
+
end
|
79
87
|
end
|
80
88
|
|
81
89
|
# PUT /admin/variants/:id
|
@@ -88,40 +96,23 @@ module Caboose
|
|
88
96
|
save = true
|
89
97
|
params.each do |name,value|
|
90
98
|
case name
|
91
|
-
when 'alternate_id'
|
92
|
-
|
93
|
-
when '
|
94
|
-
|
95
|
-
when '
|
96
|
-
|
97
|
-
when '
|
98
|
-
|
99
|
-
when '
|
100
|
-
|
101
|
-
when '
|
102
|
-
|
103
|
-
when '
|
104
|
-
v.
|
105
|
-
when '
|
106
|
-
|
107
|
-
when '
|
108
|
-
v.weight = value
|
109
|
-
when 'length'
|
110
|
-
v.length = value
|
111
|
-
when 'width'
|
112
|
-
v.width = value
|
113
|
-
when 'height'
|
114
|
-
v.height = value
|
115
|
-
when 'option1'
|
116
|
-
v.option1 = value
|
117
|
-
when 'option2'
|
118
|
-
v.option2 = value
|
119
|
-
when 'option3'
|
120
|
-
v.option3 = value
|
121
|
-
when 'requires_shipping'
|
122
|
-
v.requires_shipping = value
|
123
|
-
when 'taxable'
|
124
|
-
v.taxable = value
|
99
|
+
when 'alternate_id' then v.alternate_id = value
|
100
|
+
when 'sku' then v.sku = value
|
101
|
+
when 'barcode' then v.barcode = value
|
102
|
+
when 'price' then v.price = value
|
103
|
+
when 'quantity_in_stock' then v.quantity_in_stock = value
|
104
|
+
when 'ignore_quantity' then v.ignore_quantity = value
|
105
|
+
when 'allow_backorder' then v.allow_backorder = value
|
106
|
+
when 'status' then v.status = value
|
107
|
+
when 'weight' then v.weight = value
|
108
|
+
when 'length' then v.length = value
|
109
|
+
when 'width' then v.width = value
|
110
|
+
when 'height' then v.height = value
|
111
|
+
when 'option1' then v.option1 = value
|
112
|
+
when 'option2' then v.option2 = value
|
113
|
+
when 'option3' then v.option3 = value
|
114
|
+
when 'requires_shipping' then v.requires_shipping = value
|
115
|
+
when 'taxable' then v.taxable = value
|
125
116
|
end
|
126
117
|
end
|
127
118
|
resp.success = save && v.save
|
@@ -201,7 +192,87 @@ module Caboose
|
|
201
192
|
:redirect => "/admin/products/#{v.product_id}/variants"
|
202
193
|
})
|
203
194
|
end
|
195
|
+
|
196
|
+
# GET /admin/products/:product_id/variants/sort-order
|
197
|
+
def admin_edit_sort_order
|
198
|
+
return if !user_is_allowed('products', 'edit')
|
199
|
+
@product = Product.find(params[:product_id])
|
200
|
+
render :layout => 'caboose/admin'
|
201
|
+
end
|
202
|
+
|
203
|
+
# PUT /admin/products/:product_id/variants/option1-sort-order
|
204
|
+
def admin_update_option1_sort_order
|
205
|
+
product_id = params[:product_id]
|
206
|
+
params[:values].each_with_index do |value, i|
|
207
|
+
Variant.where(:product_id => product_id, :option1 => value).all.each do |v|
|
208
|
+
v.update_attribute(:option1_sort_order, i)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
render :json => { :success => true }
|
212
|
+
end
|
213
|
+
|
214
|
+
# PUT /admin/products/:product_id/variants/option1-sort-order
|
215
|
+
def admin_update_option2_sort_order
|
216
|
+
product_id = params[:product_id]
|
217
|
+
params[:values].each_with_index do |value, i|
|
218
|
+
Variant.where(:product_id => product_id, :option2 => value).all.each do |v|
|
219
|
+
v.update_attribute(:option2_sort_order, i)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
render :json => { :success => true }
|
223
|
+
end
|
224
|
+
|
225
|
+
# PUT /admin/products/:product_id/variants/option1-sort-order
|
226
|
+
def admin_update_option3_sort_order
|
227
|
+
product_id = params[:product_id]
|
228
|
+
params[:values].each_with_index do |value, i|
|
229
|
+
Variant.where(:product_id => product_id, :option3 => value).all.each do |v|
|
230
|
+
v.update_attribute(:option3_sort_order, i)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
render :json => { :success => true }
|
234
|
+
end
|
204
235
|
|
236
|
+
# GET /admin/variants
|
237
|
+
def admin_group
|
238
|
+
return if !user_is_allowed('variants', 'edit')
|
239
|
+
|
240
|
+
joins = []
|
241
|
+
where = ''
|
242
|
+
values = []
|
243
|
+
|
244
|
+
if params[:category_ids]
|
245
|
+
joins << [:category_memberships]
|
246
|
+
where << 'store_category_memberships.category_id IN (?)'
|
247
|
+
values << params[:category_ids]
|
248
|
+
end
|
249
|
+
|
250
|
+
if params[:vendor_ids]
|
251
|
+
joins << [:vendor]
|
252
|
+
where << 'store_vendors.id IN (?)'
|
253
|
+
values << params[:vendor_ids]
|
254
|
+
end
|
255
|
+
|
256
|
+
if params[:title]
|
257
|
+
where << 'LOWER(store_products.title) LIKE ?'
|
258
|
+
values << "%#{params[:title].downcase}%"
|
259
|
+
end
|
260
|
+
|
261
|
+
# Query for all relevant products
|
262
|
+
products = values.any? ? Caboose::Product.joins(joins).where([where].concat(values)) : []
|
263
|
+
|
264
|
+
# Grab variants for each product
|
265
|
+
@variants = products.collect { |product| product.variants }.flatten
|
266
|
+
|
267
|
+
# Grab all categories; except for all and uncategorized
|
268
|
+
@categories = Caboose::Category.where('parent_id IS NOT NULL')
|
269
|
+
|
270
|
+
# Grab all vendors
|
271
|
+
@vendors = Caboose::Vendor.all
|
272
|
+
|
273
|
+
render :layout => 'caboose/admin'
|
274
|
+
end
|
275
|
+
|
205
276
|
# GET /admin/variants/status-options
|
206
277
|
def admin_status_options
|
207
278
|
arr = ['Active', 'Inactive', 'Deleted']
|
@@ -75,12 +75,14 @@ module Caboose
|
|
75
75
|
block.children.each{ |b2| self.cache_helper(site, p, b2) }
|
76
76
|
end
|
77
77
|
|
78
|
-
def self.cache_helper2(site, p, bt)
|
78
|
+
def self.cache_helper2(site, p, bt)
|
79
|
+
return if bt.nil?
|
79
80
|
self.add_block_type(site, p, bt)
|
80
81
|
bt.children.each{ |bt2| self.cache_helper2(site, p, bt2) }
|
81
82
|
end
|
82
83
|
|
83
84
|
def self.add_block_type(site, p, bt)
|
85
|
+
return if bt.nil?
|
84
86
|
if !@render_functions.has_key?(bt.id)
|
85
87
|
f = ''
|
86
88
|
if bt.use_render_function && bt.render_function
|
@@ -3,22 +3,7 @@ p = @product
|
|
3
3
|
%>
|
4
4
|
<%= render :partial => 'caboose/products/admin_header' %>
|
5
5
|
|
6
|
-
<div id='
|
7
|
-
<table>
|
8
|
-
<tr>
|
9
|
-
<% @top_categories.each do |cat| %>
|
10
|
-
<% next if cat.children && cat.children.count > 0 %>
|
11
|
-
<td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
|
12
|
-
<% end %>
|
13
|
-
</tr>
|
14
|
-
<tr>
|
15
|
-
<% @top_categories.each do |cat| %>
|
16
|
-
<% next if cat.children.nil? || cat.children.count == 0 %>
|
17
|
-
<td valign='top'><%= raw category_checkboxes([cat], @selected_ids) %></td>
|
18
|
-
<% end %>
|
19
|
-
</tr>
|
20
|
-
</table>
|
21
|
-
</div>
|
6
|
+
<div id='product_<%= p.id %>_category_id'></div>
|
22
7
|
|
23
8
|
<%= render :partial => 'caboose/products/admin_footer' %>
|
24
9
|
|
@@ -35,39 +20,26 @@ p = @product
|
|
35
20
|
<% content_for :caboose_js do %>
|
36
21
|
<script type='text/javascript'>
|
37
22
|
|
23
|
+
var mb = false;
|
38
24
|
$(document).ready(function() {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
mb = new ModelBinder({
|
26
|
+
name: 'Product',
|
27
|
+
id: <%= p.id %>,
|
28
|
+
update_url: '/admin/products/<%= p.id %>',
|
29
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
30
|
+
attributes: [
|
31
|
+
{
|
32
|
+
name: 'category_id',
|
33
|
+
nice_name: 'Categories',
|
34
|
+
type: 'checkbox-multiple',
|
35
|
+
options_url: '/admin/categories/options',
|
36
|
+
value: <%= raw Caboose.json(p.categories.collect{ |cat| cat.id }) %>,
|
37
|
+
fixed_placeholder: false,
|
38
|
+
width: 400
|
39
|
+
}
|
40
|
+
]
|
45
41
|
});
|
46
42
|
});
|
47
43
|
|
48
|
-
var modal = false;
|
49
|
-
$(window).load(function() {
|
50
|
-
modal = new CabooseModal(800);
|
51
|
-
});
|
52
|
-
|
53
|
-
function add_product_to_category(product_id, cat_id)
|
54
|
-
{
|
55
|
-
$.ajax({
|
56
|
-
url: '/admin/products/' + product_id + '/categories',
|
57
|
-
type: 'post',
|
58
|
-
data: { category_id: cat_id },
|
59
|
-
success: function(resp) {}
|
60
|
-
});
|
61
|
-
}
|
62
|
-
|
63
|
-
function remove_product_from_category(product_id, cat_id)
|
64
|
-
{
|
65
|
-
$.ajax({
|
66
|
-
url: '/admin/products/' + product_id + '/categories/' + cat_id,
|
67
|
-
type: 'delete',
|
68
|
-
success: function(resp) {}
|
69
|
-
});
|
70
|
-
}
|
71
|
-
|
72
44
|
</script>
|
73
45
|
<% end %>
|
@@ -15,10 +15,7 @@ p = @product
|
|
15
15
|
<div id='images'>
|
16
16
|
<% if p.product_images.count > 0 %>
|
17
17
|
<% p.product_images.each do |img| %>
|
18
|
-
<%
|
19
|
-
#url = "https://s3.amazonaws.com/tuskwear/products/#{img.product_id}_#{img.id}_tiny.jpg"
|
20
|
-
url = img.image.url(:tiny)
|
21
|
-
%>
|
18
|
+
<% url = img.image.url(:tiny) %>
|
22
19
|
<div id='img_<%= img.id %>_container'><a href="javascript:select_image(<%= img.id %>);"><img src='<%= url %>' width='75' /></a></div>
|
23
20
|
<% end %>
|
24
21
|
<% else %>
|
@@ -42,13 +39,7 @@ p = @product
|
|
42
39
|
<% content_for :caboose_js do %>
|
43
40
|
<script type='text/javascript'>
|
44
41
|
|
45
|
-
|
46
|
-
$(window).load(function() {
|
47
|
-
modal.autosize();
|
48
|
-
});
|
49
|
-
|
50
|
-
$(document).ready(function() {
|
51
|
-
modal = new CabooseModal(900);
|
42
|
+
$(document).ready(function() {
|
52
43
|
<% if p.product_images.count > 0 %>
|
53
44
|
select_image(<%= p.product_images[0].id %>);
|
54
45
|
<% end %>
|
@@ -76,7 +67,7 @@ function select_image(image_id, confirm)
|
|
76
67
|
{
|
77
68
|
if (!variants)
|
78
69
|
{
|
79
|
-
|
70
|
+
$('#variants').html("<p class='loading'>Getting attached product variants...</p>");
|
80
71
|
$.ajax({
|
81
72
|
url: '/admin/products/<%= p.id %>/variants/json',
|
82
73
|
success: function(resp) { variants = resp; select_image(image_id); }
|
@@ -109,8 +100,7 @@ function select_image(image_id, confirm)
|
|
109
100
|
$('#variants').empty().append('<br/>');
|
110
101
|
$('#variants').append($('<div/>').attr('id','delete_message'));
|
111
102
|
$('#variants').append($('<input/>').attr('type','button').val('Delete Image').click(function() { delete_image(image_id); }));
|
112
|
-
$('#variants').append(tbl);
|
113
|
-
modal.autosize();
|
103
|
+
$('#variants').append(tbl);
|
114
104
|
}
|
115
105
|
|
116
106
|
function variants_subtable(image_id, x, y)
|
@@ -121,20 +111,6 @@ function variants_subtable(image_id, x, y)
|
|
121
111
|
var v = variants[i];
|
122
112
|
if (!v) break;
|
123
113
|
checked = image_is_attached_to_variant(v.id);
|
124
|
-
|
125
|
-
//var a = $('<a/>')
|
126
|
-
// .attr('href', '#')
|
127
|
-
// .attr('id', 'v_' + v.id)
|
128
|
-
// .html(variant_title(v))
|
129
|
-
// .click(function(e) {
|
130
|
-
// e.preventDefault();
|
131
|
-
// variant_id = $(this).attr('id').split('_')[1];
|
132
|
-
// var attach = false;
|
133
|
-
// if ($(this).hasClass('selected')) { attach = false; $(this).removeClass('selected'); }
|
134
|
-
// else { attch = true; $(this).addClass('selected'); }
|
135
|
-
// attach_image_to_variant(image_id, variant_id, attach);
|
136
|
-
// });
|
137
|
-
//tbody.append($('<tr/>').append($('<td/>').append(a)));
|
138
114
|
|
139
115
|
tbody.append($('<tr/>')
|
140
116
|
.append($('<td/>')
|
@@ -145,8 +121,8 @@ function variants_subtable(image_id, x, y)
|
|
145
121
|
.css('position','relative')
|
146
122
|
.val('1')
|
147
123
|
.click(function() {
|
148
|
-
variant_id = $(this).attr('id').split('_')[1];
|
149
|
-
attach_image_to_variant(image_id, variant_id, $(this).
|
124
|
+
variant_id = $(this).attr('id').split('_')[1];
|
125
|
+
attach_image_to_variant(image_id, variant_id, $(this).prop('checked'));
|
150
126
|
})
|
151
127
|
)
|
152
128
|
)
|
@@ -173,9 +149,7 @@ function variant_title(v)
|
|
173
149
|
}
|
174
150
|
|
175
151
|
function attach_image_to_variant(image_id, variant_id, attach)
|
176
|
-
{
|
177
|
-
attach = attach || true;
|
178
|
-
|
152
|
+
{
|
179
153
|
if (attach)
|
180
154
|
image_variant_ids[image_variant_ids.length] = variant_id;
|
181
155
|
else
|
@@ -193,8 +167,7 @@ function attach_image_to_variant(image_id, variant_id, attach)
|
|
193
167
|
|
194
168
|
function add_image()
|
195
169
|
{
|
196
|
-
$('#new_image_message').html("<p class='loading'>Adding image...</p>");
|
197
|
-
modal.autosize();
|
170
|
+
$('#new_image_message').html("<p class='loading'>Adding image...</p>");
|
198
171
|
}
|
199
172
|
|
200
173
|
function delete_image(image_id, confirm)
|
@@ -204,17 +177,17 @@ function delete_image(image_id, confirm)
|
|
204
177
|
var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
|
205
178
|
.append("Are you sure you want to delete the image?<br />This can't be undone.<br /><br />")
|
206
179
|
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_image(image_id, true); })).append(' ')
|
207
|
-
.append($('<input/>').attr('type', 'button').val('No').click(function() { $('#delete_message').empty();
|
208
|
-
|
180
|
+
.append($('<input/>').attr('type', 'button').val('No').click(function() { $('#delete_message').empty(); }));
|
181
|
+
$('#delete_message').empty().append(p);
|
209
182
|
return;
|
210
183
|
}
|
211
|
-
|
184
|
+
$('#delete_message').empty().append("<p class='loading'>Deleting the image...</p>");
|
212
185
|
$.ajax({
|
213
186
|
url: '/admin/product-images/' + image_id,
|
214
187
|
type: 'delete',
|
215
188
|
success: function(resp) {
|
216
189
|
if (resp.error)
|
217
|
-
|
190
|
+
$('#delete_message').html("<p class='note error'>" + resp.error + "</p>");
|
218
191
|
else
|
219
192
|
window.location.reload(true);
|
220
193
|
}
|
@@ -15,7 +15,7 @@ v = @variant
|
|
15
15
|
|
16
16
|
<%= render :partial => 'caboose/products/admin_header' %>
|
17
17
|
|
18
|
-
<
|
18
|
+
<div id='variants'></div>
|
19
19
|
|
20
20
|
<div id='message'><%
|
21
21
|
# Make sure we're not trying to highlight a deleted variant
|
@@ -29,57 +29,6 @@ if @highlight_variant_id
|
|
29
29
|
end
|
30
30
|
%></div>
|
31
31
|
|
32
|
-
<div id='variants_wrapper'>
|
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>
|
81
|
-
</div>
|
82
|
-
|
83
32
|
<p><input type='button' value='New Variant' onclick="add_variant(<%= p.id %>);" /></p>
|
84
33
|
|
85
34
|
<form id="add-multiple" action="/admin/products/<%= @product.id %>/variants/add-multiple" method="post">
|
@@ -102,69 +51,41 @@ td.sort_handle { background: #ccc; width: 20px; }
|
|
102
51
|
<script type='text/javascript'>
|
103
52
|
|
104
53
|
$(document).ready(function() {
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
<% if
|
136
|
-
<% if
|
137
|
-
<% if
|
138
|
-
|
139
|
-
|
140
|
-
<% if @cols['weight' ] == true %>{ name: 'weight' , nice_name: 'Weight (grams)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.weight ) %>, width: 50, fixed_placeholder: false },<% end %>
|
141
|
-
<% if @cols['length' ] == true %>{ name: 'length' , nice_name: 'Length (in)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.length ) %>, width: 50, fixed_placeholder: false },<% end %>
|
142
|
-
<% if @cols['width' ] == true %>{ name: 'width' , nice_name: 'Width (in)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.width ) %>, width: 50, fixed_placeholder: false },<% end %>
|
143
|
-
<% if @cols['height' ] == true %>{ name: 'height' , nice_name: 'Height (in)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.height ) %>, width: 50, fixed_placeholder: false },<% end %>
|
144
|
-
<% if @cols['cylinder' ] == true %>{ name: 'cylinder' , nice_name: 'Cylinder' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.cylinder ) %>, width: 50, fixed_placeholder: false },<% end %>
|
145
|
-
<% if @cols['requires_shipping' ] == true %>{ name: 'requires_shipping' , nice_name: 'Requires shipping' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.requires_shipping ) %>, width: 50, fixed_placeholder: false },<% end %>
|
146
|
-
<% if @cols['taxable' ] == true %>{ name: 'taxable' , nice_name: 'Taxable' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.taxable ) %>, width: 50, fixed_placeholder: false },<% end %>
|
147
|
-
<% 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 %>
|
148
|
-
]
|
149
|
-
});
|
150
|
-
<% end %>
|
151
|
-
|
152
|
-
$('#variants_tbody').sortable({
|
153
|
-
handle: '.sort_handle',
|
154
|
-
update: function(event, ui) {
|
155
|
-
$.ajax({
|
156
|
-
url: '/admin/products/<%= p.id %>/variants/sort-order',
|
157
|
-
type: 'put',
|
158
|
-
data: $('#variants_tbody').sortable('serialize', { key: 'variant_ids[]' }),
|
159
|
-
success: function(resp) {}
|
160
|
-
});
|
161
|
-
}
|
162
|
-
});
|
163
|
-
});
|
164
|
-
|
165
|
-
var modal = false;
|
166
|
-
$(window).load(function() {
|
167
|
-
modal = new CabooseModal('100%');
|
54
|
+
var that = this;
|
55
|
+
var table = new IndexTable({
|
56
|
+
form_authenticity_token: '<%= form_authenticity_token %>',
|
57
|
+
container: 'variants',
|
58
|
+
base_url: '/admin/products/<%= p.id %>/variants',
|
59
|
+
allow_bulk_edit: false,
|
60
|
+
allow_bulk_delete: true,
|
61
|
+
allow_duplicate: false,
|
62
|
+
allow_advanced_edit: true,
|
63
|
+
fields: [
|
64
|
+
<% if p.option1 %>{ show: true , name: 'option1' , nice_name: <%= raw Caboose.json(p.option1) %> , sort: 'option1' , type: 'text' , value: function(v) { return v.option1 }, width: 75, align: 'left' },<% end %>
|
65
|
+
<% if p.option2 %>{ show: true , name: 'option2' , nice_name: <%= raw Caboose.json(p.option2) %> , sort: 'option2' , type: 'text' , value: function(v) { return v.option2 }, width: 75, align: 'left' },<% end %>
|
66
|
+
<% if p.option3 %>{ show: true , name: 'option3' , nice_name: <%= raw Caboose.json(p.option3) %> , sort: 'option3' , type: 'text' , value: function(v) { return v.option3 }, width: 75, align: 'left' },<% end %>
|
67
|
+
{ show: true , name: 'status' , nice_name: 'Status' , sort: 'status' , type: 'text' , value: function(v) { return v.status }, width: 75, align: 'left' },
|
68
|
+
{ show: true , name: 'alternate_id' , nice_name: 'Alternate ID' , sort: 'alternate_id' , type: 'text' , value: function(v) { return v.alternate_id }, width: 75, align: 'left' },
|
69
|
+
{ show: true , name: 'sku' , nice_name: 'SKU' , sort: 'sku' , type: 'text' , value: function(v) { return v.sku }, width: 75, align: 'left' },
|
70
|
+
{ show: true , name: 'barcode' , nice_name: 'Barcode' , sort: 'barcode' , type: 'text' , value: function(v) { return v.barcode }, width: 75, align: 'left' },
|
71
|
+
{ show: true , name: 'price' , nice_name: 'Price' , sort: 'price' , type: 'text' , value: function(v) { return v.price }, width: 75, align: 'right' },
|
72
|
+
{ show: true , name: 'quantity_in_stock' , nice_name: 'Quantity' , sort: 'quantity_in_stock' , type: 'text' , value: function(v) { return v.quantity_in_stock }, width: 50, align: 'right' },
|
73
|
+
{ show: true , name: 'weight' , nice_name: 'Weight (grams)' , sort: 'weight' , type: 'text' , value: function(v) { return v.weight }, width: 50, align: 'right' },
|
74
|
+
{ show: true , name: 'length' , nice_name: 'Length (in)' , sort: 'length' , type: 'text' , value: function(v) { return v.length }, width: 50, align: 'right' },
|
75
|
+
{ show: true , name: 'width' , nice_name: 'Width (in)' , sort: 'width' , type: 'text' , value: function(v) { return v.width }, width: 50, align: 'right' },
|
76
|
+
{ show: true , name: 'height' , nice_name: 'Height (in)' , sort: 'height' , type: 'text' , value: function(v) { return v.height }, width: 50, align: 'right' },
|
77
|
+
{ show: true , name: 'cylinder' , nice_name: 'Cylinder' , sort: 'cylinder' , type: 'checkbox' , value: function(v) { return v.cylinder }, width: 50, align: 'center' },
|
78
|
+
{ show: true , name: 'requires_shipping' , nice_name: 'Requires shipping' , sort: 'requires_shipping' , type: 'checkbox' , value: function(v) { return v.requires_shipping }, width: 50, align: 'center' },
|
79
|
+
{ show: true , name: 'taxable' , nice_name: 'Taxable' , sort: 'taxable' , type: 'checkbox' , value: function(v) { return v.taxable }, width: 50, align: 'center' },
|
80
|
+
{ show: true , name: 'allow_backorder' , nice_name: 'Allow backorder' , sort: 'allow_backorder' , type: 'checkbox' , value: function(v) { return v.allow_backorder }, width: 50, align: 'center' }
|
81
|
+
],
|
82
|
+
new_model_text: 'New Variant',
|
83
|
+
new_model_fields: [
|
84
|
+
<% if p.option1 %>{ name: 'name', nice_name: 'Name', type: 'text', width: 400 },<% end %>
|
85
|
+
<% if p.option1 %>{ name: 'name', nice_name: 'Name', type: 'text', width: 400 },<% end %>
|
86
|
+
<% if p.option1 %>{ name: 'name', nice_name: 'Name', type: 'text', width: 400 },<% end %>
|
87
|
+
],
|
88
|
+
});
|
168
89
|
});
|
169
90
|
|
170
91
|
</script>
|
@@ -0,0 +1,171 @@
|
|
1
|
+
<% content_for :caboose_css do %>
|
2
|
+
<style>
|
3
|
+
ul {
|
4
|
+
list-style-type: square;
|
5
|
+
padding: 0 0 0 24px;
|
6
|
+
margin: 12px 0 24px;
|
7
|
+
}
|
8
|
+
</style>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%
|
12
|
+
p = @product
|
13
|
+
v = @variant
|
14
|
+
%>
|
15
|
+
|
16
|
+
<%= render :partial => 'caboose/products/admin_header' %>
|
17
|
+
|
18
|
+
<p style='font-size: 75%;'><a href='/admin/products/<%= p.id %>/variant-cols'>Edit visible columns</a></p>
|
19
|
+
|
20
|
+
<div id='message'><%
|
21
|
+
# Make sure we're not trying to highlight a deleted variant
|
22
|
+
if @highlight_variant_id
|
23
|
+
v = Variant.where(:id => @highlight_variant_id).first
|
24
|
+
if v.nil?
|
25
|
+
%><p class='note error'>The variant you want to highlight is not in the database.</p><%
|
26
|
+
elsif v.status == 'Deleted'
|
27
|
+
%><p class='note error'>The variant you want to highlight has been deleted.</p><%
|
28
|
+
end
|
29
|
+
end
|
30
|
+
%></div>
|
31
|
+
|
32
|
+
<div id='variants_wrapper'>
|
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>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<p><input type='button' value='New Variant' onclick="add_variant(<%= p.id %>);" /></p>
|
84
|
+
|
85
|
+
<form id="add-multiple" action="/admin/products/<%= @product.id %>/variants/add-multiple" method="post">
|
86
|
+
<p style="margin: 0 0 12px"><small>CSV format: Alternate ID, Quantity, Price<%= ', ' if @product.option1 || @product.option2 || @product.option3 %><%= [@product.option1, @product.option2, @product.option3].compact.join(', ') %></small></p>
|
87
|
+
<textarea id="variants_csv" name="variants_csv" rows="8" cols="12" style="min-width: 500px; min-height: 250px; margin: 0 0 16px; padding: 12px"></textarea><br />
|
88
|
+
<input type="submit" value="Submit" />
|
89
|
+
<p class="message" style="margin: 12px 0 0; color: red"></p>
|
90
|
+
</form>
|
91
|
+
|
92
|
+
<%= render :partial => 'caboose/products/admin_footer' %>
|
93
|
+
|
94
|
+
<% content_for :caboose_css do %>
|
95
|
+
<style type='text/css'>
|
96
|
+
tr.highlight td { background: #ffff99 }
|
97
|
+
td.sort_handle { background: #ccc; width: 20px; }
|
98
|
+
</style>
|
99
|
+
<% end %>
|
100
|
+
|
101
|
+
<% content_for :caboose_js do %>
|
102
|
+
<script type='text/javascript'>
|
103
|
+
|
104
|
+
$(document).ready(function() {
|
105
|
+
$('form#add-multiple').on('submit', function(event) {
|
106
|
+
event.preventDefault();
|
107
|
+
var $form = $(event.target);
|
108
|
+
|
109
|
+
$.ajax({
|
110
|
+
type: $form.attr('method'),
|
111
|
+
url: $form.attr('action'),
|
112
|
+
data: $form.serialize(),
|
113
|
+
success: function(response) {
|
114
|
+
console.log(response);
|
115
|
+
if (response.success) {
|
116
|
+
location.reload();
|
117
|
+
} else {
|
118
|
+
$form.find('.message').empty().text(response.error);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
});
|
122
|
+
});
|
123
|
+
|
124
|
+
<% p.variants.each do |v| %>
|
125
|
+
new ModelBinder({
|
126
|
+
name: 'Variant',
|
127
|
+
id: <%= v.id %>,
|
128
|
+
update_url: '/admin/variants/<%= v.id %>',
|
129
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
130
|
+
attributes: [
|
131
|
+
<% if @cols['option1' ] && p.option1 %>{ name: 'option1' , nice_name: <%= raw Caboose.json(p.option1) %> , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.option1 ) %>, width: 75, fixed_placeholder: false },<% end %>
|
132
|
+
<% if @cols['option2' ] && p.option2 %>{ name: 'option2' , nice_name: <%= raw Caboose.json(p.option2) %> , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.option2 ) %>, width: 75, fixed_placeholder: false },<% end %>
|
133
|
+
<% if @cols['option3' ] && p.option3 %>{ name: 'option3' , nice_name: <%= raw Caboose.json(p.option3) %> , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.option3 ) %>, width: 75, fixed_placeholder: false },<% end %>
|
134
|
+
<% if @cols['status' ] == true %>{ name: 'status' , nice_name: 'Status' , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.status ) %>, width: 75, fixed_placeholder: false },<% end %>
|
135
|
+
<% if @cols['alternate_id' ] == true %>{ name: 'alternate_id' , nice_name: 'Alternate ID' , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.alternate_id ) %>, width: 75, fixed_placeholder: false },<% end %>
|
136
|
+
<% if @cols['sku' ] == true %>{ name: 'sku' , nice_name: 'SKU' , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.sku ) %>, width: 75, fixed_placeholder: false },<% end %>
|
137
|
+
<% if @cols['barcode' ] == true %>{ name: 'barcode' , nice_name: 'Barcode' , type: 'text' , align: 'left' , value: <%= raw Caboose.json(v.barcode ) %>, width: 75, fixed_placeholder: false },<% end %>
|
138
|
+
<% if @cols['price' ] == true %>{ name: 'price' , nice_name: 'Price' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.price ) %>, width: 75, fixed_placeholder: false },<% end %>
|
139
|
+
<% if @cols['quantity_in_stock' ] == true %>{ name: 'quantity_in_stock' , nice_name: 'Quantity' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.quantity_in_stock ) %>, width: 50, fixed_placeholder: false },<% end %>
|
140
|
+
<% if @cols['weight' ] == true %>{ name: 'weight' , nice_name: 'Weight (grams)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.weight ) %>, width: 50, fixed_placeholder: false },<% end %>
|
141
|
+
<% if @cols['length' ] == true %>{ name: 'length' , nice_name: 'Length (in)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.length ) %>, width: 50, fixed_placeholder: false },<% end %>
|
142
|
+
<% if @cols['width' ] == true %>{ name: 'width' , nice_name: 'Width (in)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.width ) %>, width: 50, fixed_placeholder: false },<% end %>
|
143
|
+
<% if @cols['height' ] == true %>{ name: 'height' , nice_name: 'Height (in)' , type: 'text' , align: 'right' , value: <%= raw Caboose.json(v.height ) %>, width: 50, fixed_placeholder: false },<% end %>
|
144
|
+
<% if @cols['cylinder' ] == true %>{ name: 'cylinder' , nice_name: 'Cylinder' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.cylinder ) %>, width: 50, fixed_placeholder: false },<% end %>
|
145
|
+
<% if @cols['requires_shipping' ] == true %>{ name: 'requires_shipping' , nice_name: 'Requires shipping' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.requires_shipping ) %>, width: 50, fixed_placeholder: false },<% end %>
|
146
|
+
<% if @cols['taxable' ] == true %>{ name: 'taxable' , nice_name: 'Taxable' , type: 'checkbox' , align: 'center', value: <%= raw Caboose.json(v.taxable ) %>, width: 50, fixed_placeholder: false },<% end %>
|
147
|
+
<% 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 %>
|
148
|
+
]
|
149
|
+
});
|
150
|
+
<% end %>
|
151
|
+
|
152
|
+
$('#variants_tbody').sortable({
|
153
|
+
handle: '.sort_handle',
|
154
|
+
update: function(event, ui) {
|
155
|
+
$.ajax({
|
156
|
+
url: '/admin/products/<%= p.id %>/variants/sort-order',
|
157
|
+
type: 'put',
|
158
|
+
data: $('#variants_tbody').sortable('serialize', { key: 'variant_ids[]' }),
|
159
|
+
success: function(resp) {}
|
160
|
+
});
|
161
|
+
}
|
162
|
+
});
|
163
|
+
});
|
164
|
+
|
165
|
+
var modal = false;
|
166
|
+
$(window).load(function() {
|
167
|
+
modal = new CabooseModal('100%');
|
168
|
+
});
|
169
|
+
|
170
|
+
</script>
|
171
|
+
<% end %>
|
@@ -1,8 +1,7 @@
|
|
1
1
|
<h1>Products</h1>
|
2
2
|
|
3
3
|
<p style="margin: 12px 0">
|
4
|
-
<a href="/admin/vendors/new">New Vendor</a><span style="margin: 0 3px">|</span>
|
5
|
-
<a href="/admin/products/new">New Product</a><span style="margin: 0 3px">|</span>
|
4
|
+
<a href="/admin/vendors/new">New Vendor</a><span style="margin: 0 3px">|</span>
|
6
5
|
<a href="/admin/products/sort">Sort Products</a><span style="margin: 0 3px">|</span>
|
7
6
|
<a href='#'>Search Form</a>
|
8
7
|
</p>
|
data/config/routes.rb
CHANGED
@@ -303,7 +303,7 @@ Caboose::Engine.routes.draw do
|
|
303
303
|
get '/admin/orders/:id/refund' => 'orders#admin_refund'
|
304
304
|
post '/admin/orders/:id/resend-confirmation' => 'orders#admin_resend_confirmation'
|
305
305
|
|
306
|
-
post "/reviews/add" => "reviews#add"
|
306
|
+
post "/reviews/add" => "reviews#add"
|
307
307
|
|
308
308
|
get "/admin/products" => "products#admin_index"
|
309
309
|
get "/admin/products/json" => "products#admin_json"
|
@@ -317,14 +317,22 @@ Caboose::Engine.routes.draw do
|
|
317
317
|
get "/admin/products/:id/categories" => "products#admin_edit_categories"
|
318
318
|
post "/admin/products/:id/categories" => "products#admin_add_to_category"
|
319
319
|
delete "/admin/products/:id/categories/:category_id" => "products#admin_remove_from_category"
|
320
|
-
|
321
|
-
get "/admin/products/:
|
322
|
-
get "/admin/products/:
|
323
|
-
|
324
|
-
|
325
|
-
put '/admin/products/:
|
326
|
-
put '/admin/products/:
|
327
|
-
|
320
|
+
|
321
|
+
get "/admin/products/:product_id/variants" => "variants#admin_index"
|
322
|
+
get "/admin/products/:product_id/variants/json" => "variants#admin_json"
|
323
|
+
get "/admin/products/:product_id/variants/sort-order" => "products#admin_edit_variant_sort_order"
|
324
|
+
put '/admin/products/:product_id/variants/option1-sort-order' => 'products#admin_update_option1_sort_order'
|
325
|
+
put '/admin/products/:product_id/variants/option2-sort-order' => 'products#admin_update_option2_sort_order'
|
326
|
+
put '/admin/products/:product_id/variants/option3-sort-order' => 'products#admin_update_option3_sort_order'
|
327
|
+
get "/admin/products/:product_id/variants/:variant_id/edit" => "variants#admin_edit"
|
328
|
+
put "/admin/products/:product_id/variants/:id/attach-to-image" => "variants#admin_attach_to_image"
|
329
|
+
put "/admin/products/:product_id/variants/:id/unattach-from-image" => "variants#admin_unattach_from_image"
|
330
|
+
put "/admin/products/:product_id/variants/:id" => "variants#admin_update"
|
331
|
+
get "/admin/products/:id/variants/new" => "variants#admin_new"
|
332
|
+
post "/admin/products/:id/variants" => "variants#admin_add"
|
333
|
+
delete "/admin/variants/:id" => "variants#admin_delete"
|
334
|
+
get "/admin/variants/status-options" => "variants#admin_status_options"
|
335
|
+
|
328
336
|
get "/admin/products/:id/images" => "products#admin_edit_images"
|
329
337
|
post "/admin/products/:id/images" => "products#admin_add_image"
|
330
338
|
get "/admin/products/:id/collections" => "products#admin_edit_collections"
|
@@ -338,16 +346,6 @@ Caboose::Engine.routes.draw do
|
|
338
346
|
delete "/admin/products/:id" => "products#admin_delete"
|
339
347
|
put "/admin/products/:id/update-vendor" => "products#admin_update_vendor"
|
340
348
|
|
341
|
-
get "/admin/products/:product_id/variants/:variant_id/edit" => "variants#admin_edit"
|
342
|
-
get "/admin/variants/status-options" => "variants#admin_status_options"
|
343
|
-
get "/admin/variants/:variant_id/edit" => "variants#admin_edit"
|
344
|
-
put "/admin/variants/:id/attach-to-image" => "variants#admin_attach_to_image"
|
345
|
-
put "/admin/variants/:id/unattach-from-image" => "variants#admin_unattach_from_image"
|
346
|
-
put "/admin/variants/:id" => "variants#admin_update"
|
347
|
-
get "/admin/products/:id/variants/new" => "variants#admin_new"
|
348
|
-
post "/admin/products/:id/variants" => "variants#admin_add"
|
349
|
-
delete "/admin/variants/:id" => "variants#admin_delete"
|
350
|
-
|
351
349
|
get "/admin/stackable-groups/options" => "stackable_groups#admin_options"
|
352
350
|
get "/admin/stackable-groups/json" => "stackable_groups#admin_json"
|
353
351
|
get "/admin/stackable-groups/:id/json" => "stackable_groups#admin_json_single"
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -757,6 +757,7 @@ files:
|
|
757
757
|
- app/views/caboose/products/admin_edit_variant_columns.html.erb
|
758
758
|
- app/views/caboose/products/admin_edit_variant_sort_order.html.erb
|
759
759
|
- app/views/caboose/products/admin_edit_variants.html.erb
|
760
|
+
- app/views/caboose/products/admin_edit_variants_old.html.erb
|
760
761
|
- app/views/caboose/products/admin_edit_variants_single.html.erb
|
761
762
|
- app/views/caboose/products/admin_group_variants.html.erb
|
762
763
|
- app/views/caboose/products/admin_index.html.erb
|