caboose-cms 0.5.145 → 0.5.146

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Zjk4OTU1YWUyMzU5YmFiOWNjYzc3NTMyYThkOWFjMDcxYzNjYjBlOQ==
4
+ ZDg5NjBiNWNmY2UzNTI3YWY0YzIwYmRkZWNmZjRiNmRjODQ3MjVmNg==
5
5
  data.tar.gz: !binary |-
6
- YWI0OTVkODQyOTY5Yjc0NmQzOGQyMzBlMTRlNGJiYTgzNTRjYWM5Mw==
6
+ Y2I1YTJmMWRhYzE4NmNiZGVlMjllODM0MjZiNDEyZjg4MzNhOTE2Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTE1OTI2ZGQ5MzIyMmIwOTBiNGRmMDJkZjdkMjBhZjUwMDczYmFjYTcwYjJl
10
- MjMwMWRiY2Y1OGYzZTM4MjQ0MThlYTg0NGIyMTM0NjI1YmQ2ZjI1NTk2ZDU5
11
- OTEyYTg2ZmQzOGE3OTRmYWVjMjU5ODMzOTU5MGVhN2QxMmY5ODc=
9
+ MzA4YTM2ZmVhNjQxMDk2M2UyMWFjNGNjNjA0YTY4YTY5ZWZmNTY4NThhODNh
10
+ MDQxNGU1MzRjN2VlZDhhNjE0MWI0N2QyNmNiNWI1NzFiMjA2YTI4N2ZmY2Yz
11
+ ZDg4ZjBiMzk0MmZhZDY1NzVmOWJjYzM1ZGMzNmFlNmRjMmMwNzk=
12
12
  data.tar.gz: !binary |-
13
- MmQwZjQ1MTA2YTQ4ZGFmOWI0MjFjZDZlMTA0NGUyYTcwMWNmYjI4NWVkYjg4
14
- NTIyNmYxYjNkMjBkNTBmMzJkYWRmZjhhNzlkOWQ4NzBlOTU4MjI0ZWJmZGMx
15
- MTc1YTk5YzI3ZTE1NTljOGJiOWZlNmVjMjAxODQ5MzcxMjhkYTI=
13
+ MTYxZGU4ZDczZmUwYzEyOGQ0MmVhNWY0ZWZlZmYxZGVjMDE3MjJiYWJiNmEz
14
+ MWMzYjZlNWUxNGQ4MmYyMzM5MGEyYTUzMzlhYTE3M2RhYjJlZGNhNjJjMTVk
15
+ NDgyYjEwNTVkNDA1NWZjNGI4MzI0MjRiMzcyNDNkOWExOThjYjQ=
@@ -250,7 +250,8 @@ OrderController.prototype = {
250
250
  var table = $('<table/>').addClass('data');
251
251
  table.append($('<tr/>')
252
252
  .append($('<th/>').html('Customer'))
253
- .append($('<th/>').html('Shipping Address'))
253
+ .append($('<th/>').html('Shipping Address'))
254
+ .append($('<th/>').html('Billing Address'))
254
255
  .append($('<th/>').html('Order Status'))
255
256
  .append($('<th/>').html('Payment Status'))
256
257
  );
@@ -275,6 +276,16 @@ OrderController.prototype = {
275
276
  });
276
277
  }))
277
278
  )
279
+ .append($('<td/>').attr('valign', 'top')
280
+ .append($('<div/>').attr('id', 'billing_address').append(that.noneditable_billing_address(true)))
281
+ .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
282
+ var a = $(this);
283
+ that.refresh_order(function() {
284
+ if (a.html() == 'Edit') { that.edit_billing_address(); a.html('Finished'); }
285
+ else { that.noneditable_billing_address(); a.html('Edit'); }
286
+ });
287
+ }))
288
+ )
278
289
  .append($('<td/>').attr('valign', 'top').append($('<div/>').attr('id', 'order_' + that.order.id + '_status')))
279
290
  .append($('<td/>').attr('valign', 'top').attr('align', 'center').append(fstatus))
280
291
  );
@@ -370,6 +381,62 @@ OrderController.prototype = {
370
381
  });
371
382
  },
372
383
 
384
+ noneditable_billing_address: function(return_element)
385
+ {
386
+ var that = this;
387
+ var sa = that.order.billing_address;
388
+ if (!sa) sa = {};
389
+ var str = '';
390
+ str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
391
+ str += (sa.last_name ? sa.last_name : '[Empty last name]');
392
+ str += '<br />' + (sa.address1 ? sa.address1 : '[Empty address]');
393
+ if (sa.address2) str += "<br />" + sa.address2;
394
+ str += '<br/>' + (sa.city ? sa.city : '[Empty city]') + ", " + (sa.state ? sa.state : '[Empty state]') + " " + (sa.zip ? sa.zip : '[Empty zip]');
395
+ if (return_element)
396
+ return str;
397
+ $('#billing_address').empty().append(str);
398
+ },
399
+
400
+ edit_billing_address: function()
401
+ {
402
+ var that = this;
403
+ var sa = that.order.billing_address;
404
+ if (!sa) sa = { id: 1 };
405
+ var table = $('<table/>').addClass('billing_address')
406
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
407
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_first_name')))
408
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_last_name')))
409
+ ))))
410
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
411
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address1')))
412
+ ))))
413
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
414
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address2')))
415
+ ))))
416
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
417
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_city')))
418
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_state')))
419
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_zip')))
420
+ ))));
421
+ $('#billing_address').empty().append(table);
422
+
423
+ new ModelBinder({
424
+ name: 'BillingAddress',
425
+ id: sa.id,
426
+ update_url: '/admin/orders/' + that.order.id + '/billing-address',
427
+ authenticity_token: that.authenticity_token,
428
+ attributes: [
429
+ { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
430
+ { name: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: 150, fixed_placeholder: false },
431
+ { name: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: 320, fixed_placeholder: false },
432
+ { name: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: 320, fixed_placeholder: false },
433
+ { name: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: 180, fixed_placeholder: false },
434
+ { name: 'state' , nice_name: 'State' , type: 'text' , value: sa.state , width: 40, fixed_placeholder: false },
435
+ { name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
436
+ ]
437
+ });
438
+ },
439
+
373
440
  // Show all the packages and the line items in each package
374
441
  order_packages_table: function(table)
375
442
  {
@@ -637,8 +704,8 @@ OrderController.prototype = {
637
704
  url: '/admin/orders/' + that.order.id + '/void',
638
705
  success: function(resp) {
639
706
  if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
640
- if (resp.success) $('#message').html("<p class='note success'>" + resp.success + "</p>");
641
- if (resp.refresh) window.location.reload(true);
707
+ if (resp.success) that.refresh();
708
+ if (resp.refresh) that.refresh();
642
709
  }
643
710
  });
644
711
  },
@@ -661,8 +728,8 @@ OrderController.prototype = {
661
728
  url: '/admin/orders/' + that.order.id + '/capture',
662
729
  success: function(resp) {
663
730
  if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
664
- if (resp.success) $('#message').html("<p class='note success'>" + resp.success + "</p>");
665
- if (resp.refresh) window.location.reload(true);
731
+ if (resp.success) that.refresh();
732
+ if (resp.refresh) that.refresh();
666
733
  }
667
734
  });
668
735
  }
@@ -0,0 +1,50 @@
1
+ module Caboose
2
+ class BillingAddressesController < Caboose::ApplicationController
3
+
4
+ # GET /admin/orders/:order_id/billing-address/json
5
+ def admin_json
6
+ return if !user_is_allowed('orders', 'edit')
7
+ order = Order.find(params[:order_id])
8
+ render :json => order.billing_address
9
+ end
10
+
11
+ # PUT /admin/orders/:order_id/billing-address
12
+ def admin_update
13
+ return if !user_is_allowed('orders', 'edit')
14
+
15
+ resp = Caboose::StdClass.new({'attributes' => {}})
16
+ order = Order.find(params[:order_id])
17
+ sa = order.billing_address
18
+
19
+ if sa.nil?
20
+ sa = Address.create
21
+ order.billing_address_id = sa.id
22
+ order.save
23
+ end
24
+
25
+ save = true
26
+ params.each do |name, value|
27
+ case name
28
+ when 'name' then sa.name = value
29
+ when 'first_name' then sa.first_name = value
30
+ when 'last_name' then sa.last_name = value
31
+ when 'street' then sa.street = value
32
+ when 'address1' then sa.address1 = value
33
+ when 'address2' then sa.address2 = value
34
+ when 'company' then sa.company = value
35
+ when 'city' then sa.city = value
36
+ when 'state' then sa.state = value
37
+ when 'province' then sa.province = value
38
+ when 'province_code' then sa.province_code = value
39
+ when 'zip' then sa.zip = value
40
+ when 'country' then sa.country = value
41
+ when 'country_code' then sa.country_code = value
42
+ when 'phone' then sa.phone = value
43
+ end
44
+ end
45
+ resp.success = save && sa.save
46
+ render :json => resp
47
+ end
48
+
49
+ end
50
+ end
@@ -118,15 +118,18 @@ module Caboose
118
118
  # GET /admin/line-items/product-stubs
119
119
  def admin_product_stubs
120
120
  title = params[:title].strip.downcase.split(' ')
121
- render :json => [] and return if title.length == 0
122
- where = ["site_id = ?"]
123
- query = [@site.id]
121
+ render :json => [] and return if title.length == 0
122
+
123
+ where = ["site_id = ?"]
124
+ vars = [@site.id]
124
125
  title.each do |str|
125
126
  where << 'lower(title) like ?'
126
- query << "%#{str}%"
127
- end
127
+ vars << "%#{str}%"
128
+ end
128
129
  where = where.join(' and ')
129
- query[0] = "select id, title from store_products where #{where} order by title limit 20"
130
+ query = ["select id, title from store_products where #{where} order by title limit 20"]
131
+ vars.each{ |v| query << v }
132
+
130
133
  rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, query))
131
134
  arr = rows.collect{ |row| { :id => row[0], :title => row[1] }}
132
135
  render :json => arr
@@ -15,7 +15,7 @@ module Caboose
15
15
  resp = Caboose::StdClass.new({'attributes' => {}})
16
16
  order = Order.find(params[:order_id])
17
17
  sa = order.shipping_address
18
- Caboose.log(sa.first_name)
18
+
19
19
  save = true
20
20
  params.each do |name, value|
21
21
  case name
@@ -35,10 +35,8 @@ module Caboose
35
35
  when 'country_code' then sa.country_code = value
36
36
  when 'phone' then sa.phone = value
37
37
  end
38
- end
39
- Caboose.log(sa.first_name)
40
- resp.success = save && sa.save
41
- Caboose.log(sa.first_name)
38
+ end
39
+ resp.success = save && sa.save
42
40
  render :json => resp
43
41
  end
44
42
 
@@ -43,7 +43,8 @@ $(document).ready(function() {
43
43
  <% content_for :caboose_css do %>
44
44
  <style type='text/css'>
45
45
 
46
- table.shipping_address td {
46
+ table.shipping_address td,
47
+ table.billing_address td {
47
48
  padding: 0 !important;
48
49
  margin: 0 !important;
49
50
  border: 0 !important;
data/config/routes.rb CHANGED
@@ -532,6 +532,8 @@ Caboose::Engine.routes.draw do
532
532
  put "/admin/orders/:order_id/line-items/:id" => "line_items#admin_update"
533
533
  delete "/admin/orders/:order_id/line-items/:id" => "line_items#admin_delete"
534
534
 
535
+ get "admin/orders/:order_id/billing-address/json" => "billing_addresses#admin_json"
536
+ put "admin/orders/:order_id/billing-address" => "billing_addresses#admin_update"
535
537
  get "admin/orders/:order_id/shipping-address/json" => "shipping_addresses#admin_json"
536
538
  put "admin/orders/:order_id/shipping-address" => "shipping_addresses#admin_update"
537
539
 
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.145'
2
+ VERSION = '0.5.146'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.145
4
+ version: 0.5.146
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
@@ -510,6 +510,7 @@ files:
510
510
  - app/controllers/caboose/ab_variants_controller.rb
511
511
  - app/controllers/caboose/admin_controller.rb
512
512
  - app/controllers/caboose/application_controller.rb
513
+ - app/controllers/caboose/billing_addresses_controller.rb
513
514
  - app/controllers/caboose/block_type_categories_controller.rb
514
515
  - app/controllers/caboose/block_type_sources_controller.rb
515
516
  - app/controllers/caboose/block_type_store_controller.rb