caboose-cms 0.9.29 → 0.9.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 283e17b034bdd0cb3bc0a343d592141a4febd4aa
4
- data.tar.gz: bfb91798884a5bfbab943eca89738fb9083979b3
3
+ metadata.gz: eb82d8896301aa81a5dd5c31515e674a8d94ca3e
4
+ data.tar.gz: a99eeebf6c56d93dc437fd3ec6126e57f8ea360d
5
5
  SHA512:
6
- metadata.gz: 1f2a734ff80bbab2afc20c1c6982ccfc66b42491cab113ecbf1f211f951e802dc575bec807fce8c45ec8b9d544947ef60b12aa4d7e478b71bc47e660ca7f1a41
7
- data.tar.gz: 4516a5ecdefbf9567ee9d3f1ac5f278d8e10f3fb4170e4586514d63abe3236f1911c64991b41ea7a231cf07b716dac003df151cf16cac4e8f37fce933e6827e1
6
+ metadata.gz: 91bfbab79102337d1f8faa9e7ddd389d27a88a4e0e0286c41a196976d8deea9bcb42d29c335a1c6897839cecc367c873de0d6de8a90264c5b7275f7614e63ac9
7
+ data.tar.gz: 409be109f1ab404760d03222a93b180e97c099d878604cd508d310e9419b1428eb04d90aa2317e2d9f89656d628882f78fffb96fb778c6306ca4bf28c1269a1e
@@ -81,7 +81,7 @@ CheckoutController.prototype = {
81
81
  success: function(resp) {
82
82
  that.invoice = resp;
83
83
  $.each(that.invoice.invoice_packages, function(i, op) {
84
- that.invoice.invoice_packages[i].shipping_method_controller = new ShippingMethodController({ cc: that, invoice_package_id: op.id });
84
+ that.invoice.invoice_packages[i].shipping_method_controller = new ShippingMethodController({ cc: that, invoice_package_id: op.id, package_number: i });
85
85
  });
86
86
  if (!that.invoice.shipping_address) that.invoice.shipping_address = that.empty_address();
87
87
  //if (!that.invoice.billing_address) that.invoice.billing_address = that.empty_address();
@@ -188,31 +188,35 @@ CheckoutController.prototype = {
188
188
 
189
189
  print_ready_message: function()
190
190
  {
191
- var that = this;
192
- var ready = true;
193
- if (!that.shipping_address_controller.ready()) ready = false;
194
- if (that.invoice.payment_terms == 'pia' && !that.payment_method_controller.ready()) ready = false;
191
+ var that = this;
192
+ var msg = that.shipping_address_controller.ready_error();
193
+ if (!msg && that.invoice.payment_terms == 'pia') msg = that.payment_method_controller.ready_error()
194
+ $.each(that.invoice.invoice_packages, function(i, op) {
195
+ if (!msg) msg = that.invoice.invoice_packages[i].shipping_method_controller.ready_error();
196
+ });
195
197
 
196
- if (ready)
198
+ if (msg)
197
199
  {
198
- $('#message').empty().append($('<p/>').append($('<input/>').attr('type', 'button').val('Continue to Confirmation').click(function(e) {
199
- that.print(true);
200
- })));
200
+ $('#message').empty().append($('<p/>').addClass('note warning').append(msg));
201
201
  }
202
202
  else
203
203
  {
204
- $('#message').empty().append($('<p/>').addClass('note warning').append("Please complete all the fields."));
204
+ $('#message').empty().append($('<p/>').append($('<input/>').attr('type', 'button').val('Continue to Confirmation').click(function(e) {
205
+ that.print(true);
206
+ })));
205
207
  }
206
208
  },
207
209
 
208
210
  print_confirm_message: function()
209
211
  {
210
212
  var that = this;
211
- var ready = true;
212
- if (!that.shipping_address_controller.ready()) ready = false;
213
- if (that.invoice.payment_terms == 'pia' && !that.payment_method_controller.ready()) ready = false;
214
-
215
- if (!ready)
213
+ var msg = that.shipping_address_controller.ready_error();
214
+ if (!msg && that.invoice.payment_terms == 'pia') msg = that.payment_method_controller.ready_error();
215
+ $.each(that.invoice.invoice_packages, function(i, op) {
216
+ if (!msg) msg = that.invoice.invoice_packages[i].shipping_method_controller.ready_error();
217
+ });
218
+
219
+ if (msg)
216
220
  {
217
221
  that.refresh_and_print();
218
222
  return;
@@ -83,33 +83,34 @@ ShippingAddressController.prototype = {
83
83
  update_url: '/checkout/shipping-address',
84
84
  authenticity_token: that.cc.authenticity_token,
85
85
  attributes: [
86
- { name: 'first_name' , wrapper_class: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: '50%' , fixed_placeholder: false },
87
- { name: 'last_name' , wrapper_class: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: '50%' , fixed_placeholder: false },
88
- { name: 'company' , wrapper_class: 'company' , nice_name: 'Company' , type: 'text' , value: sa.company , width: '100%' , fixed_placeholder: false },
89
- { name: 'address1' , wrapper_class: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: '100%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
90
- { name: 'address2' , wrapper_class: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: '100%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
91
- { name: 'city' , wrapper_class: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: '25%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
92
- { name: 'zip' , wrapper_class: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: '25%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
93
- { name: 'state' , wrapper_class: 'state' , nice_name: 'State' , type: 'select' , value: sa.state , width: '25%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }, options_url: '/checkout/state-options', show_empty_option: true, empty_text: '-- State --' }
86
+ { name: 'first_name' , wrapper_class: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: '50%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.first_name = this.value; that.cc.print_ready_message(); }},
87
+ { name: 'last_name' , wrapper_class: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: '50%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.last_name = this.value; that.cc.print_ready_message(); }},
88
+ { name: 'company' , wrapper_class: 'company' , nice_name: 'Company' , type: 'text' , value: sa.company , width: '100%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.company = this.value; that.cc.print_ready_message(); }},
89
+ { name: 'address1' , wrapper_class: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: '100%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.address1 = this.value; if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
90
+ { name: 'address2' , wrapper_class: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: '100%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.address2 = this.value; if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
91
+ { name: 'city' , wrapper_class: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: '25%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.city = this.value; if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
92
+ { name: 'zip' , wrapper_class: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: '25%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.zip = this.value; if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }},
93
+ { name: 'state' , wrapper_class: 'state' , nice_name: 'State' , type: 'select' , value: sa.state , width: '25%' , fixed_placeholder: false , before_update: function() { this.value_old = this.value_clean; }, after_update: function() { that.cc.invoice.shipping_address.state = this.value; if (this.value != this.value_old) that.cc.refresh_cart(function() { that.cc.print_ready_message(); }); }, options_url: '/checkout/state-options', show_empty_option: true, empty_text: '-- State --' }
94
94
  ]
95
95
  });
96
96
  },
97
97
 
98
- ready: function()
98
+ ready_error: function()
99
99
  {
100
100
  var that = this;
101
- if (that.cc.allow_instore_pickup && that.cc.invoice.instore_pickup) return true;
102
- if (that.cc.all_downloadable()) return true;
103
- if (that.cc.is_empty_address(that.cc.invoice.shipping_address)) return false;
101
+ if (that.cc.allow_instore_pickup && that.cc.invoice.instore_pickup) return null;
102
+ if (that.cc.all_downloadable()) return null;
103
+ if (that.cc.is_empty_address(that.cc.invoice.shipping_address))
104
+ return "Please enter your shipping address";
104
105
 
105
106
  var sa = that.cc.invoice.shipping_address;
106
- if (!sa.first_name || sa.first_name.length == 0) return false;
107
- if (!sa.last_name || sa.last_name.length == 0) return false;
108
- if (!sa.address1 || sa.address1.length == 0) return false;
109
- if (!sa.city || sa.city.length == 0) return false;
110
- if (!sa.state || sa.state.length == 0) return false;
111
- if (!sa.zip || sa.zip.length == 0) return false;
107
+ if (!sa.first_name || sa.first_name.length == 0) return "Please enter your shipping address first name";
108
+ if (!sa.last_name || sa.last_name.length == 0) return "Please enter your shipping address last name";
109
+ if (!sa.address1 || sa.address1.length == 0) return "Please enter your shipping address";
110
+ if (!sa.city || sa.city.length == 0) return "Please enter your shipping address city";
111
+ if (!sa.state || sa.state.length == 0) return "Please enter your shipping address state";
112
+ if (!sa.zip || sa.zip.length == 0) return "Please enter your shipping address zip";
112
113
 
113
- return true;
114
+ return null;
114
115
  }
115
116
  };
@@ -5,12 +5,15 @@ ShippingMethodController.prototype = {
5
5
 
6
6
  cc: false, // CheckoutController
7
7
  invoice_package_id: false,
8
+ invoice_package: false,
9
+ package_number: false,
8
10
 
9
11
  init: function(params)
10
12
  {
11
13
  var that = this;
12
14
  for (var i in params)
13
15
  that[i] = params[i];
16
+ that.invoice_package = that.cc.invoice_package_for_id(that.invoice_package_id);
14
17
  },
15
18
 
16
19
  print: function()
@@ -19,7 +22,7 @@ ShippingMethodController.prototype = {
19
22
  var div = $('<div/>');
20
23
 
21
24
  var sa = that.cc.invoice.shipping_address;
22
- var op = that.cc.invoice_package_for_id(that.invoice_package_id);
25
+ var op = that.invoice_package;
23
26
  var sm = op && op.shipping_method ? op.shipping_method : false;
24
27
 
25
28
  if (!op)
@@ -53,7 +56,7 @@ ShippingMethodController.prototype = {
53
56
  {
54
57
  var that = this;
55
58
  var div = $('<div/>').append($('<p/>').addClass('loading').html("Getting rates..."));
56
- var op = that.cc.invoice_package_for_id(that.invoice_package_id);
59
+ var op = that.invoice_package;
57
60
 
58
61
  $('#invoice_package_' + that.invoice_package_id + '_shipping_method').empty().append(div);
59
62
 
@@ -91,7 +94,7 @@ ShippingMethodController.prototype = {
91
94
  });
92
95
  select.change(function(e) {
93
96
  var opt = $(this).find('option').filter(':selected');
94
- that.update(opt.val(), opt.data('total'));
97
+ that.update(opt.val(), opt.data('total'));
95
98
  });
96
99
  }
97
100
  div = $('<div/>')
@@ -103,9 +106,7 @@ ShippingMethodController.prototype = {
103
106
  },
104
107
 
105
108
  update: function(shipping_method_id, total)
106
- {
107
- //console.log('shipping_method_id = ' + shipping_method_id);
108
- //console.log('total = ' + total);
109
+ {
109
110
  var that = this;
110
111
  $.ajax({
111
112
  url: '/checkout/shipping',
@@ -115,10 +116,29 @@ ShippingMethodController.prototype = {
115
116
  shipping_method_id: shipping_method_id,
116
117
  total: total
117
118
  },
118
- success: function(resp) {
119
+ success: function(resp) {
119
120
  if (resp.error) $('#invoice_package_' + that.invoice_package_id + '_message').html("<p class='note error'>" + resp.error + "</p>");
120
- if (resp.success) that.cc.refresh_totals();
121
+ if (resp.success)
122
+ {
123
+ that.invoice_package.shipping_method_id = shipping_method_id;
124
+ that.invoice_package.total = total;
125
+ that.cc.refresh_totals();
126
+ }
127
+ that.cc.print_ready_message();
121
128
  }
122
129
  });
123
- }
130
+ },
131
+
132
+ ready_error: function()
133
+ {
134
+ var that = this;
135
+ if (that.cc.allow_instore_pickup && that.cc.invoice.instore_pickup) return null;
136
+ if (that.cc.all_downloadable()) return null;
137
+
138
+ var op = that.invoice_package;
139
+ if (!op) return "Please select a shipping method for package " + (that.package_number + 1);
140
+ if (!op.shipping_method_id) return "Please select a shipping method for package " + (that.package_number + 1);
141
+
142
+ return null;
143
+ }
124
144
  };
@@ -212,13 +212,13 @@ StripePaymentMethodController.prototype = {
212
212
  });
213
213
  },
214
214
 
215
- ready: function()
215
+ ready_error: function()
216
216
  {
217
217
  var that = this;
218
- if (that.cc.invoice.total <= 0.00) return true;
219
- if (!that.customer_id ) return false;
220
- if (!that.card_brand ) return false;
221
- if (!that.card_last4 ) return false;
222
- return true;
218
+ if (that.cc.invoice.total <= 0.00) return null;
219
+ if (!that.customer_id ) return "Please enter your credit card information.";
220
+ if (!that.card_brand ) return "Please enter your credit card information.";
221
+ if (!that.card_last4 ) return "Please enter your credit card information.";
222
+ return null;
223
223
  }
224
224
  };
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.9.29'
2
+ VERSION = '0.9.30'
3
3
  end
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.9.29
4
+ version: 0.9.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg