spree_core 1.1.6 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/app/assets/images/{creditcards → credit_cards}/amex_cid.gif +0 -0
  2. data/app/assets/images/{creditcards/creditcard.gif → credit_cards/credit_card.gif} +0 -0
  3. data/app/assets/images/{creditcards → credit_cards}/discover_cid.gif +0 -0
  4. data/app/assets/images/{creditcards → credit_cards}/icons/american_express.png +0 -0
  5. data/app/assets/images/{creditcards → credit_cards}/icons/cirrus.png +0 -0
  6. data/app/assets/images/{creditcards → credit_cards}/icons/delta.png +0 -0
  7. data/app/assets/images/{creditcards → credit_cards}/icons/dinersclub.png +0 -0
  8. data/app/assets/images/{creditcards → credit_cards}/icons/directdebit.png +0 -0
  9. data/app/assets/images/{creditcards → credit_cards}/icons/discover.png +0 -0
  10. data/app/assets/images/{creditcards → credit_cards}/icons/egold.png +0 -0
  11. data/app/assets/images/{creditcards → credit_cards}/icons/maestro.png +0 -0
  12. data/app/assets/images/{creditcards → credit_cards}/icons/master.png +0 -0
  13. data/app/assets/images/{creditcards → credit_cards}/icons/paypal.png +0 -0
  14. data/app/assets/images/{creditcards → credit_cards}/icons/solo.png +0 -0
  15. data/app/assets/images/{creditcards → credit_cards}/icons/switch.png +0 -0
  16. data/app/assets/images/{creditcards → credit_cards}/icons/visa.png +0 -0
  17. data/app/assets/images/{creditcards → credit_cards}/icons/visaelectron.png +0 -0
  18. data/app/assets/images/{creditcards → credit_cards}/icons/westernunion.png +0 -0
  19. data/app/assets/images/{creditcards → credit_cards}/icons/wirecard.png +0 -0
  20. data/app/assets/images/{creditcards → credit_cards}/icons/worldpay.png +0 -0
  21. data/app/assets/images/{creditcards → credit_cards}/master_cid.jpg +0 -0
  22. data/app/assets/images/{creditcards → credit_cards}/visa_cid.gif +0 -0
  23. data/app/assets/javascripts/admin/admin.js.erb +12 -136
  24. data/app/assets/javascripts/admin/checkouts/edit.js +18 -35
  25. data/app/assets/javascripts/admin/gateway.js +2 -2
  26. data/app/assets/javascripts/admin/images/index.js.coffee +12 -0
  27. data/app/assets/javascripts/admin/images/new.js.coffee +4 -0
  28. data/app/assets/javascripts/admin/orders/edit.js +1 -1
  29. data/app/assets/javascripts/admin/orders/edit_form.js +0 -2
  30. data/app/assets/javascripts/admin/product_autocomplete.js.erb +116 -0
  31. data/app/assets/javascripts/store/cart.js.coffee +7 -0
  32. data/app/assets/javascripts/store/checkout.js.coffee +57 -0
  33. data/app/assets/javascripts/store/product.js.coffee +36 -0
  34. data/app/assets/stylesheets/admin/admin.css.erb +5 -0
  35. data/app/assets/stylesheets/admin/spree_core.css +1 -0
  36. data/app/assets/stylesheets/store/screen.css.scss +15 -1
  37. data/app/assets/stylesheets/store/variables.css.scss +29 -29
  38. data/app/controllers/spree/admin/banners_controller.rb +14 -0
  39. data/app/controllers/spree/admin/base_controller.rb +11 -0
  40. data/app/controllers/spree/admin/images_controller.rb +13 -5
  41. data/app/controllers/spree/admin/line_items_controller.rb +16 -25
  42. data/app/controllers/spree/admin/mail_methods_controller.rb +1 -8
  43. data/app/controllers/spree/admin/option_types_controller.rb +0 -25
  44. data/app/controllers/spree/admin/orders/customer_details_controller.rb +3 -3
  45. data/app/controllers/spree/admin/orders_controller.rb +23 -14
  46. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -7
  47. data/app/controllers/spree/admin/payments_controller.rb +5 -5
  48. data/app/controllers/spree/admin/products_controller.rb +15 -5
  49. data/app/controllers/spree/admin/prototypes_controller.rb +2 -2
  50. data/app/controllers/spree/admin/reports_controller.rb +1 -7
  51. data/app/controllers/spree/admin/resource_controller.rb +130 -130
  52. data/app/controllers/spree/admin/search_controller.rb +47 -0
  53. data/app/controllers/spree/admin/taxons_controller.rb +0 -43
  54. data/app/controllers/spree/base_controller.rb +2 -1
  55. data/app/controllers/spree/checkout_controller.rb +29 -10
  56. data/app/controllers/spree/orders_controller.rb +7 -11
  57. data/app/controllers/spree/products_controller.rb +5 -1
  58. data/app/helpers/spree/account_helper.rb +4 -0
  59. data/app/helpers/spree/admin/base_helper.rb +2 -44
  60. data/app/helpers/spree/admin/navigation_helper.rb +1 -3
  61. data/app/helpers/spree/admin/orders_helper.rb +3 -2
  62. data/app/helpers/spree/admin/products_helper.rb +21 -0
  63. data/app/helpers/spree/base_helper.rb +14 -11
  64. data/app/helpers/spree/checkout_helper.rb +5 -1
  65. data/app/helpers/spree/orders_helper.rb +5 -0
  66. data/app/helpers/spree/products_helper.rb +4 -0
  67. data/app/helpers/spree/trackers_helper.rb +4 -0
  68. data/app/models/spree/ability.rb +70 -0
  69. data/app/models/spree/address.rb +4 -12
  70. data/app/models/spree/adjustment.rb +30 -8
  71. data/app/models/spree/app_configuration.rb +1 -1
  72. data/app/models/spree/calculator/price_sack.rb +3 -5
  73. data/app/models/spree/country.rb +1 -4
  74. data/app/models/spree/{creditcard.rb → credit_card.rb} +4 -4
  75. data/app/models/spree/gateway.rb +2 -2
  76. data/app/models/spree/gateway/bogus.rb +10 -10
  77. data/app/models/spree/gateway/bogus_simple.rb +4 -4
  78. data/app/models/spree/image.rb +3 -12
  79. data/app/models/spree/inventory_unit.rb +4 -6
  80. data/app/models/spree/{user.rb → legacy_user.rb} +7 -6
  81. data/app/models/spree/line_item.rb +4 -5
  82. data/app/models/spree/option_type.rb +4 -6
  83. data/app/models/spree/option_value.rb +1 -1
  84. data/app/models/spree/order.rb +90 -132
  85. data/app/models/spree/order/checkout.rb +124 -0
  86. data/app/models/spree/payment.rb +6 -6
  87. data/app/models/spree/payment/processing.rb +34 -38
  88. data/app/models/spree/payment_method.rb +2 -2
  89. data/app/models/spree/preference.rb +2 -0
  90. data/app/models/spree/preferences/preferable_class_methods.rb +0 -2
  91. data/app/models/spree/preferences/store.rb +3 -21
  92. data/app/models/spree/product.rb +41 -43
  93. data/app/models/spree/product/scopes.rb +9 -25
  94. data/app/models/spree/product_option_type.rb +2 -2
  95. data/app/models/spree/product_property.rb +9 -4
  96. data/app/models/spree/property.rb +1 -1
  97. data/app/models/spree/prototype.rb +2 -2
  98. data/app/models/spree/return_authorization.rb +2 -2
  99. data/app/models/spree/role.rb +1 -1
  100. data/app/models/spree/shipment.rb +6 -5
  101. data/app/models/spree/shipping_method.rb +19 -13
  102. data/app/models/spree/state.rb +2 -5
  103. data/app/models/spree/state_change.rb +1 -1
  104. data/app/models/spree/tax_rate.rb +8 -1
  105. data/app/models/spree/taxon.rb +5 -1
  106. data/app/models/spree/taxonomy.rb +1 -1
  107. data/app/models/spree/tokenized_permission.rb +6 -0
  108. data/app/models/spree/tracker.rb +1 -1
  109. data/app/models/spree/variant.rb +13 -40
  110. data/app/models/spree/zone.rb +15 -14
  111. data/app/models/spree/zone_member.rb +1 -1
  112. data/app/views/spree/admin/image_settings/edit.html.erb +2 -2
  113. data/app/views/spree/admin/images/_form.html.erb +8 -4
  114. data/app/views/spree/admin/images/index.html.erb +1 -1
  115. data/app/views/spree/admin/line_items/create.js.erb +1 -1
  116. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
  117. data/app/views/spree/admin/option_types/index.html.erb +1 -1
  118. data/app/views/spree/admin/orders/_add_product.html.erb +1 -1
  119. data/app/views/spree/admin/orders/customer_details/edit.html.erb +1 -1
  120. data/app/views/spree/admin/orders/index.html.erb +4 -4
  121. data/app/views/spree/admin/orders/show.html.erb +1 -1
  122. data/app/views/spree/admin/payments/_form.html.erb +1 -1
  123. data/app/views/spree/admin/payments/new.html.erb +0 -4
  124. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +1 -1
  125. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +2 -2
  126. data/app/views/spree/admin/products/_form.html.erb +21 -5
  127. data/app/views/spree/admin/products/index.html.erb +2 -2
  128. data/app/views/spree/admin/properties/_form.html.erb +1 -1
  129. data/app/views/spree/admin/properties/index.html.erb +1 -1
  130. data/app/views/spree/admin/return_authorizations/_form.html.erb +33 -17
  131. data/app/views/spree/admin/return_authorizations/edit.html.erb +2 -2
  132. data/app/views/spree/admin/shared/_address_form.html.erb +1 -1
  133. data/app/views/spree/admin/shared/_head.html.erb +12 -2
  134. data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -4
  135. data/app/views/spree/admin/shared/_product_tabs.html.erb +0 -6
  136. data/app/views/spree/admin/shared/_show_resource_links.html.erb +3 -3
  137. data/app/views/spree/admin/shared/_tabs.html.erb +1 -2
  138. data/app/views/spree/admin/shipments/edit.html.erb +2 -2
  139. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  140. data/app/views/spree/admin/states/_state_list.html.erb +1 -1
  141. data/app/views/spree/admin/tax_rates/index.html.erb +1 -1
  142. data/app/views/spree/admin/taxonomies/_form.html.erb +1 -1
  143. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  144. data/app/views/spree/admin/taxons/_taxon_table.html.erb +2 -2
  145. data/app/views/spree/admin/variants/_form.html.erb +13 -13
  146. data/app/views/spree/admin/variants/index.html.erb +1 -7
  147. data/app/views/spree/checkout/_address.html.erb +10 -4
  148. data/app/views/spree/checkout/edit.html.erb +0 -1
  149. data/app/views/spree/checkout/payment/_gateway.html.erb +5 -5
  150. data/app/views/spree/checkout/registration.html.erb +2 -2
  151. data/app/views/spree/content/cvv.html.erb +6 -6
  152. data/app/views/spree/layouts/spree_application.html.erb +4 -48
  153. data/app/views/spree/order_mailer/cancel_email.text.erb +5 -5
  154. data/app/views/spree/order_mailer/confirm_email.text.erb +6 -7
  155. data/app/views/spree/orders/_adjustments.html.erb +14 -0
  156. data/app/views/spree/orders/_form.html.erb +1 -0
  157. data/app/views/spree/orders/show.html.erb +3 -3
  158. data/app/views/spree/products/_thumbnails.html.erb +1 -1
  159. data/app/views/spree/products/index.html.erb +1 -1
  160. data/app/views/spree/shared/_footer.html.erb +6 -0
  161. data/app/views/spree/shared/_google_analytics.html.erb +15 -16
  162. data/app/views/spree/shared/_head.html.erb +3 -9
  163. data/app/views/spree/shared/_header.html.erb +5 -0
  164. data/app/views/spree/shared/_main_nav_bar.html.erb +6 -0
  165. data/app/views/spree/shared/_nav_bar.html.erb +7 -3
  166. data/app/views/spree/shared/_order_details.html.erb +14 -11
  167. data/app/views/spree/shared/_sidebar.html.erb +3 -0
  168. data/app/views/spree/shared/unauthorized.html.erb +0 -0
  169. data/app/views/spree/shipment_mailer/shipped_email.text.erb +7 -7
  170. data/app/views/spree/taxons/show.html.erb +1 -1
  171. data/config/initializers/check_for_orphaned_preferences.rb +1 -1
  172. data/config/initializers/spree.rb +0 -12
  173. data/config/initializers/user_class_extensions.rb +25 -0
  174. data/config/initializers/workarounds_for_ruby19.rb +72 -0
  175. data/config/locales/en.yml +11 -24
  176. data/config/routes.rb +7 -37
  177. data/db/migrate/20090823005402_spree_zero_nine_zero.rb +14 -12
  178. data/db/migrate/20091015153048_add_openid_field_to_users.rb +9 -7
  179. data/db/migrate/20100209144531_polymorphic_payments.rb +5 -5
  180. data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +4 -4
  181. data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +3 -1
  182. data/db/migrate/20100811163637_add_guest_flag.rb +3 -1
  183. data/db/migrate/20100901171814_change_guest_flag_to_anonymous.rb +3 -1
  184. data/db/migrate/20101026184959_generate_anonymous_users.rb +3 -3
  185. data/db/migrate/20101103212716_drop_anonymous_field_for_user.rb +3 -1
  186. data/db/migrate/20111007143030_namespace_top_level_models.rb +18 -1
  187. data/db/migrate/20120315064358_migrate_images_from_products_to_variants.rb +6 -4
  188. data/db/migrate/20120509055454_create_tokenized_permissions_table.rb +16 -0
  189. data/db/migrate/20120530012000_rename_creditcards_to_credit_cards.rb +11 -0
  190. data/db/migrate/20120604203654_remove_credit_total_from_orders.rb +5 -0
  191. data/lib/generators/spree/custom_user/custom_user_generator.rb +53 -0
  192. data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +28 -0
  193. data/lib/generators/spree/custom_user/templates/initializer.rb.tt +1 -0
  194. data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -0
  195. data/lib/generators/spree/dummy/dummy_generator.rb +3 -0
  196. data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +1 -0
  197. data/lib/generators/spree/install/templates/app/assets/javascripts/admin/all.js +0 -1
  198. data/lib/generators/spree/install/templates/app/assets/javascripts/store/all.js +0 -1
  199. data/lib/generators/spree/install/templates/app/assets/stylesheets/admin/all.css +0 -1
  200. data/lib/generators/spree/install/templates/app/assets/stylesheets/store/all.css +0 -1
  201. data/lib/generators/spree/install/templates/config/initializers/spree.rb +2 -0
  202. data/lib/spree/core.rb +15 -2
  203. data/lib/spree/core/controller_helpers.rb +123 -62
  204. data/lib/spree/core/current_order.rb +5 -0
  205. data/lib/spree/core/engine.rb +1 -1
  206. data/lib/spree/core/mail_settings.rb +1 -2
  207. data/lib/spree/core/permalinks.rb +1 -5
  208. data/lib/spree/core/preference_rescue.rb +8 -4
  209. data/lib/spree/core/relation_serialization.rb +9 -0
  210. data/lib/spree/core/respond_with.rb +1 -1
  211. data/lib/spree/core/s3_support.rb +25 -0
  212. data/lib/spree/core/search/base.rb +2 -5
  213. data/lib/spree/core/ssl_requirement.rb +2 -2
  214. data/lib/spree/core/store_helpers.rb +1 -2
  215. data/lib/spree/core/testing_support/controller_requests.rb +1 -0
  216. data/lib/spree/core/testing_support/env.rb +2 -0
  217. data/lib/spree/core/testing_support/factories/{creditcard_factory.rb → credit_card_factory.rb} +3 -3
  218. data/lib/spree/core/testing_support/factories/payment_factory.rb +1 -1
  219. data/lib/spree/core/testing_support/factories/product_factory.rb +4 -4
  220. data/lib/spree/core/testing_support/factories/user_factory.rb +3 -3
  221. data/lib/spree/core/testing_support/factories/zone_factory.rb +2 -3
  222. data/lib/spree/core/token_resource.rb +27 -0
  223. data/lib/spree/core/version.rb +1 -1
  224. data/lib/spree/product_filters.rb +12 -13
  225. data/lib/tasks/core.rake +1 -1
  226. metadata +146 -154
  227. data/app/assets/images/noimage/large.png +0 -0
  228. data/app/assets/javascripts/admin/images/index.js +0 -10
  229. data/app/assets/javascripts/admin/images/new.js +0 -5
  230. data/app/assets/javascripts/admin/products.js +0 -2
  231. data/app/assets/javascripts/store/cart.js +0 -11
  232. data/app/assets/javascripts/store/checkout.js +0 -78
  233. data/app/assets/javascripts/store/product.js +0 -49
  234. data/app/controllers/spree/admin/users_controller.rb +0 -68
  235. data/app/views/spree/admin/option_types/_available.html.erb +0 -28
  236. data/app/views/spree/admin/option_types/_selected.html.erb +0 -26
  237. data/app/views/spree/admin/option_types/available.js.erb +0 -2
  238. data/app/views/spree/admin/option_types/select.js.erb +0 -3
  239. data/app/views/spree/admin/option_types/selected.html.erb +0 -6
  240. data/app/views/spree/admin/orders/history.html.erb +0 -29
  241. data/app/views/spree/admin/products/_option_types.html.erb +0 -40
  242. data/app/views/spree/admin/shared/_additional_field.html.erb +0 -5
  243. data/app/views/spree/admin/shared/_routes.html.erb +0 -8
  244. data/app/views/spree/admin/shared/_translations.html.erb +0 -17
  245. data/app/views/spree/admin/taxons/available.js.erb +0 -26
  246. data/app/views/spree/admin/taxons/remove.html.erb +0 -1
  247. data/app/views/spree/admin/taxons/select.js.erb +0 -2
  248. data/app/views/spree/admin/taxons/selected.html.erb +0 -42
  249. data/app/views/spree/admin/users/_form.html.erb +0 -19
  250. data/app/views/spree/admin/users/edit.html.erb +0 -14
  251. data/app/views/spree/admin/users/index.html.erb +0 -48
  252. data/app/views/spree/admin/users/new.html.erb +0 -14
  253. data/app/views/spree/admin/users/show.html.erb +0 -21
  254. data/app/views/spree/shared/_store_menu.html.erb +0 -2
  255. data/config/initializers/rails_5868.rb +0 -8
  256. data/db/migrate/20120605211305_make_users_email_index_unique.rb +0 -10
  257. data/db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb +0 -11
  258. data/db/sample/users.rb +0 -61
  259. data/lib/generators/spree/sandbox/sandbox_generator.rb +0 -36
  260. data/lib/generators/spree/sandbox/templates/rails/routes.rb +0 -7
  261. data/lib/spree/core/ext/array.rb +0 -14
  262. data/lib/spree/core/ext/hash.rb +0 -75
  263. data/lib/spree/core/ext/string.rb +0 -10
  264. data/lib/tasks/install.rake +0 -18
@@ -1,5 +1,6 @@
1
- //<%#encoding: UTF-8%>
2
1
  //= require_self
2
+ //= require admin/product_autocomplete
3
+ //= require select2
3
4
 
4
5
  /**
5
6
  This is a collection of javascript functions and whatnot
@@ -44,129 +45,13 @@ $.fn.radioControlsVisibilityOfElement = function(dependentElementSelector){
44
45
  });
45
46
  }
46
47
 
47
- // Product autocompletion
48
- image_html = function(item){
49
- return "<img src='" + item['images'][0]["mini_url"] + "'/>";
50
- }
51
-
52
- format_product_autocomplete = function(item){
53
- var html = "";
54
-
55
- var product = item.data['product'];
56
-
57
- if(item.data['variant']==undefined){
58
- if(product['images'].length!=0){
59
- html = image_html(product);
60
- }
61
-
62
- html += "<div><h4>" + product['name'] + "</h4>";
63
- if (product['master']) {
64
- html += "<span><strong>" + Spree.translations.sku + ":</strong>" + product['master']['sku'] + "</span>";
65
- }
66
- html += "<span><strong>" + Spree.translations.on_hand + ":</strong>" + product['count_on_hand'] + "</span></div>";
67
- }else{
68
- // variant
69
- var variant = item.data['variant'];
70
- var name = item.data.product['name'];
71
-
72
- if(variant['images'].length!=0){
73
- html = image_html(variant);
74
- }else{
75
- if(product['images'].length!=0){
76
- html = image_html(product);
77
- }
78
- }
79
-
80
- name += " - " + $.map(variant['option_values'], function(option_value){
81
- return option_value["option_type"]["presentation"] + ": " + option_value['presentation'];
82
- }).join(", ")
83
-
84
- html += "<div><h4>" + name + "</h4>";
85
- html += "<span><strong>" + Spree.translations.sku + ":</strong>" + variant['sku'] + "</span>";
86
- html += "<span><strong>" + Spree.translations.on_hand + ":</strong>" + variant['count_on_hand'] + "</span></div>";
87
- }
88
-
89
- return html
90
- }
91
-
92
- prep_product_autocomplete_data = function(data){
93
- return $.map(eval(data), function(row) {
94
-
95
- var product = row['product'];
96
-
97
- if(product['variants'].length>0 && ['expand_variants']){
98
- //variants
99
- return $.map(product['variants'], function(variant){
100
-
101
- var name = product['name'];
102
- name += " - " + $.map(variant['option_values'], function(option_value){
103
- return option_value["option_type"]["presentation"] + ": " + option_value['presentation'];
104
- }).join(", ");
105
-
106
- return {
107
- data: {product: product, variant: variant},
108
- value: name,
109
- result: name
110
- }
111
- });
112
- }else{
113
- return {
114
- data: {product: product},
115
- value: product['name'],
116
- result: product['name']
117
- }
118
- }
119
- });
120
- }
121
-
122
- $.fn.product_autocomplete = function(){
123
- return this.each(function() {
124
- $(this).autocomplete({
125
- source: function(request, response) {
126
- $.get(Spree.routes.product_search + '?' + jQuery.param({ q: $('#add_product_name').val(), authenticity_token: encodeURIComponent($('meta[name=csrf-token]').attr("content"))}), function(data) {
127
- result = prep_product_autocomplete_data(data)
128
- response(result);
129
- });
130
- },
131
- minLength: 4,
132
- focus: function(event, ui) {
133
- $('#add_product_name').val(ui.item.label);
134
- return false;
135
- },
136
- select: function(event, ui) {
137
- $('#add_product_name').val(ui.item.label);
138
- product = ui.item.data;
139
- if (product['variant'] == undefined) {
140
- // product
141
- $('#add_variant_id').val(product['product']['master']['id']);
142
- } else {
143
- // variant
144
- $('#add_variant_id').val(product['variant']['id']);
145
- }
146
- return false;
147
- }
148
- }).data("autocomplete")._renderItem = function(ul, item) {
149
- $(ul).addClass('ac_results');
150
- html = format_product_autocomplete(item);
151
- return $("<li></li>")
152
- .data("item.autocomplete", item)
153
- .append("<a>" + html + "</a>")
154
- .appendTo(ul);
155
- }
156
-
157
- $(this).data("autocomplete")._resizeMenu = function() {
158
- var ul = this.menu.element;
159
- ul.outerWidth(this.element.outerWidth());
160
- }
161
- });
162
- }
163
48
 
164
49
  $.fn.objectPicker = function(url){
165
50
  $(this).tokenInput(url + "&authenticity_token=" + escape(AUTH_TOKEN), {
166
51
  searchDelay : 600,
167
- hintText : Spree.translations.type_to_search,
168
- noResultsText : Spree.translations.no_results,
169
- searchingText : Spree.translations.searching,
52
+ hintText : strings.type_to_search,
53
+ noResultsText : strings.no_results,
54
+ searchingText : strings.searching,
170
55
  prePopulateFromInput : true
171
56
  });
172
57
  };
@@ -175,18 +60,14 @@ $.fn.productPicker = function(){
175
60
  $(this).objectPicker(Spree.routes.product_search_basic);
176
61
  }
177
62
 
178
- $.fn.userPicker = function(){
179
- $(this).objectPicker(Spree.routes.user_search);
180
- }
181
-
182
63
  handle_date_picker_fields = function(){
183
64
  $('.datepicker').datepicker({
184
- dateFormat: Spree.translations.date_picker,
185
- dayNames: Spree.translations.abbr_day_names,
186
- dayNamesMin: Spree.translations.abbr_day_names,
187
- monthNames: Spree.translations.month_names,
188
- prevText: Spree.translations.previous,
189
- nextText: Spree.translations.next,
65
+ dateFormat: "<%= ::I18n.t(:format, :scope => 'spree.date_picker', :default => 'yy/mm/dd') %>",
66
+ dayNames: <%= ::I18n.t(:day_names, :scope => :date).to_json %>,
67
+ dayNamesMin: <%= ::I18n.t(:abbr_day_names, :scope => :date).to_json %>,
68
+ monthNames: <%= (::I18n.t(:month_names, :scope => :date).delete_if(&:blank?)).to_json %>,
69
+ prevText: '<%= ::I18n.t(:previous) %>',
70
+ nextText: '<%= ::I18n.t(:next) %>',
190
71
  showOn: "button",
191
72
  buttonImage: "<%= asset_path 'datepicker/cal.gif' %>",
192
73
  buttonImageOnly: true
@@ -194,6 +75,7 @@ handle_date_picker_fields = function(){
194
75
  }
195
76
 
196
77
  $(document).ready(function(){
78
+ handle_date_picker_fields();
197
79
  $(".observe_field").on('change', function() {
198
80
  target = $(this).attr("data-update");
199
81
  ajax_indicator = $(this).attr("data-ajax-indicator") || '#busy_indicator';
@@ -252,9 +134,6 @@ $(document).ready(function(){
252
134
  });
253
135
 
254
136
  $('.tokeninput.products').productPicker();
255
- $('.tokeninput.users').userPicker();
256
-
257
- handle_date_picker_fields();
258
137
 
259
138
  $('body').on('click', '.select_properties_from_prototype', function(){
260
139
  $("#busy_indicator").show();
@@ -294,9 +173,6 @@ $(document).ready(function(){
294
173
  });
295
174
  });
296
175
 
297
- });
298
-
299
- jQuery(document).ready(function() {
300
176
  $('a.dismiss').click(function() {
301
177
  $(this).parent().fadeOut();
302
178
  });
@@ -1,4 +1,5 @@
1
1
  $(document).ready(function(){
2
+
2
3
  add_address = function(addr){
3
4
  var html = "";
4
5
  if(addr!=undefined){
@@ -80,7 +81,7 @@ $(document).ready(function(){
80
81
  $('#user_id').val(ui.item.data['id']);
81
82
  $('#guest_checkout_true').prop("checked", false);
82
83
  $('#guest_checkout_false').prop("checked", true);
83
- $('#guest_checkout_false').prop("disabled", false);
84
+ $('#guest_checkout_false').prob("disabled", false);
84
85
  return true;
85
86
  }
86
87
  }).data("autocomplete")._renderItem = function(ul, item) {
@@ -100,40 +101,6 @@ $(document).ready(function(){
100
101
 
101
102
  }
102
103
 
103
-
104
-
105
- $('input#order_use_billing').click(function() {
106
- show_billing(!$(this).is(':checked'));
107
- });
108
-
109
- $('#guest_checkout_true').change(function() {
110
- $('#customer_search').val("");
111
- $('#user_id').val("");
112
- $('#checkout_email').val("");
113
-
114
- $('#order_bill_address_attributes_firstname').val("");
115
- $('#order_bill_address_attributes_lastname').val("");
116
- $('#order_bill_address_attributes_company').val("");
117
- $('#order_bill_address_attributes_address1').val("");
118
- $('#order_bill_address_attributes_address2').val("");
119
- $('#order_bill_address_attributes_city').val("");
120
- $('#order_bill_address_attributes_zipcode').val("");
121
- $('#order_bill_address_attributes_state_id').val("");
122
- $('#order_bill_address_attributes_country_id').val("");
123
- $('#order_bill_address_attributes_phone').val("");
124
-
125
- $('#order_ship_address_attributes_firstname').val("");
126
- $('#order_ship_address_attributes_lastname').val("");
127
- $('#order_bill_address_attributes_company').val("");
128
- $('#order_ship_address_attributes_address1').val("");
129
- $('#order_ship_address_attributes_address2').val("");
130
- $('#order_ship_address_attributes_city').val("");
131
- $('#order_ship_address_attributes_zipcode').val("");
132
- $('#order_ship_address_attributes_state_id').val("");
133
- $('#order_ship_address_attributes_country_id').val("");
134
- $('#order_ship_address_attributes_phone').val("");
135
- });
136
-
137
104
  var show_billing = function(show) {
138
105
  if(show) {
139
106
  $('#shipping').show();
@@ -146,6 +113,22 @@ $(document).ready(function(){
146
113
  }
147
114
  }
148
115
 
116
+ $('input#order_use_billing').click(function() {
117
+ show_billing(!$(this).is(':checked'));
118
+ });
119
+
120
+ $('#guest_checkout_true').change(function() {
121
+ $('#customer_search').val("");
122
+ $('#user_id').val("");
123
+ $('#checkout_email').val("");
124
+
125
+ var fields = ["firstname", "lastname", "company", "address1", "address2",
126
+ "city", "zipcode", "state_id", "country_id", "phone"]
127
+ $.each(fields, function(i, field) {
128
+ $('#order_bill_address_attributes' + field).val("");
129
+ $('#order_ship_address_attributes' + field).val("");
130
+ })
131
+ });
149
132
  });
150
133
 
151
134
 
@@ -1,4 +1,4 @@
1
- $(function() {
1
+ $(function() {
2
2
  var original_gtwy_type = $('#gtwy-type').attr('value');
3
3
  $('div#gateway-settings-warning').hide();
4
4
  $('#gtwy-type').change(function() {
@@ -10,4 +10,4 @@ $(function() {
10
10
  $('div#gateway-settings-warning').show();
11
11
  }
12
12
  });
13
- })
13
+ })
@@ -0,0 +1,12 @@
1
+ $ ->
2
+ ($ '#new_image_link').click (event) ->
3
+ event.preventDefault()
4
+ ($ this).hide()
5
+ $.ajax
6
+ type: 'GET'
7
+ url: @href
8
+ data: (
9
+ authenticity_token: AUTH_TOKEN
10
+ )
11
+ success: (r) ->
12
+ ($ '#images').html r
@@ -0,0 +1,4 @@
1
+ ($ '#cancel_link').click (event) ->
2
+ event.preventDefault()
3
+ ($ '#new_image_link').show()
4
+ ($ '#images').html('')
@@ -10,6 +10,6 @@ $(document).ready(function(){
10
10
  return false;
11
11
  });
12
12
 
13
- $("#add_product_name").product_autocomplete();
13
+ $(".product_autocomplete").product_autocomplete();
14
14
 
15
15
  });
@@ -4,8 +4,6 @@ $(document).ready(function() {
4
4
  $(input).on('change', function() {
5
5
 
6
6
  var id = "#" + $(this).attr('id').replace("_quantity", "_id");
7
- console.log($(this))
8
- console.log($(id))
9
7
 
10
8
  jQuery.post("/admin/orders/" + $('input#order_number').val() + "/line_items/" + $(id).val(),
11
9
  { _method: "put", "line_item[quantity]": $(this).val()},
@@ -0,0 +1,116 @@
1
+ // Product autocompletion
2
+ image_html = function(item){
3
+ return "<img src='" + item['images'][0]["mini_url"] + "'/>";
4
+ }
5
+
6
+ format_product_autocomplete = function(item){
7
+ var html = "";
8
+
9
+ var product = item.data['product'];
10
+
11
+ if(item.data['variant']==undefined){
12
+ if(product['images'].length!=0){
13
+ html = image_html(product);
14
+ }
15
+
16
+ html += "<div><h4>" + product['name'] + "</h4>";
17
+ if (product['master']) {
18
+ html += "<span><strong><%= ::I18n.t(:sku) %>: </strong>" + product['master']['sku'] + "</span>";
19
+ }
20
+ html += "<span><strong><%= ::I18n.t(:on_hand) %>: </strong>" + product['count_on_hand'] + "</span></div>";
21
+ }else{
22
+ // variant
23
+ var variant = item.data['variant'];
24
+ var name = item.data.product['name'];
25
+
26
+ if(variant['images'].length!=0){
27
+ html = image_html(variant);
28
+ }else{
29
+ if(product['images'].length!=0){
30
+ html = image_html(product);
31
+ }
32
+ }
33
+
34
+ name += " - " + $.map(variant['option_values'], function(option_value){
35
+ return option_value["option_type"]["presentation"] + ": " + option_value['presentation'];
36
+ }).join(", ")
37
+
38
+ html += "<div><h4>" + name + "</h4>";
39
+ html += "<span><strong><%= ::I18n.t(:sku) %>: </strong>" + variant['sku'] + "</span>";
40
+ html += "<span><strong><%= ::I18n.t(:on_hand) %>: </strong>" + variant['count_on_hand'] + "</span></div>";
41
+ }
42
+
43
+ return html
44
+ }
45
+
46
+ prep_product_autocomplete_data = function(data){
47
+ return $.map(eval(data), function(row) {
48
+
49
+ var product = row['product'];
50
+
51
+ if(product['variants'].length>0 && ['expand_variants']){
52
+ //variants
53
+ return $.map(product['variants'], function(variant){
54
+
55
+ var name = product['name'];
56
+ name += " - " + $.map(variant['option_values'], function(option_value){
57
+ return option_value["option_type"]["presentation"] + ": " + option_value['presentation'];
58
+ }).join(", ");
59
+
60
+ return {
61
+ data: {product: product, variant: variant},
62
+ value: name,
63
+ result: name
64
+ }
65
+ });
66
+ }else{
67
+ return {
68
+ data: {product: product},
69
+ value: product['name'],
70
+ result: product['name']
71
+ }
72
+ }
73
+ });
74
+ }
75
+
76
+ $.fn.product_autocomplete = function(){
77
+ return this.each(function() {
78
+ $(this).autocomplete({
79
+ source: function(request, response) {
80
+ $.get(Spree.routes.product_search + '?' + jQuery.param({ q: $('.product_autocomplete').val(), authenticity_token: encodeURIComponent($('meta[name=csrf-token]').attr("content"))}), function(data) {
81
+ result = prep_product_autocomplete_data(data)
82
+ response(result);
83
+ });
84
+ },
85
+ minLength: 4,
86
+ focus: function(event, ui) {
87
+ $('.product_autocomplete').val(ui.item.label);
88
+ return false;
89
+ },
90
+ select: function(event, ui) {
91
+ $('.product_autocomplete').val(ui.item.label);
92
+ product = ui.item.data;
93
+ if (product['variant'] == undefined) {
94
+ // product
95
+ $('#add_variant_id').val(product['product']['master']['id']);
96
+ } else {
97
+ // variant
98
+ $('#add_variant_id').val(product['variant']['id']);
99
+ }
100
+ return false;
101
+ }
102
+ }).data("autocomplete")._renderItem = function(ul, item) {
103
+ $(ul).addClass('ac_results');
104
+ html = format_product_autocomplete(item);
105
+ return $("<li></li>")
106
+ .data("item.autocomplete", item)
107
+ .append("<a>" + html + "</a>")
108
+ .appendTo(ul);
109
+ }
110
+
111
+ $(this).data("autocomplete")._resizeMenu = function() {
112
+ var ul = this.menu.element;
113
+ ul.outerWidth(this.element.outerWidth());
114
+ }
115
+ });
116
+ }