spree_frontend 4.1.0 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +120 -0
  3. data/.codeclimate.yml +36 -0
  4. data/.deepsource.toml +19 -0
  5. data/.editorconfig +22 -0
  6. data/.eslintignore +7 -0
  7. data/.eslintrc +36 -0
  8. data/.gem_release.yml +7 -0
  9. data/.github/CONTRIBUTING.md +1 -0
  10. data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
  11. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  12. data/.github/ISSUE_TEMPLATE.md +39 -0
  13. data/.github/dependabot.yml +32 -0
  14. data/.gitignore +58 -0
  15. data/.rubocop.yml +197 -0
  16. data/.solargraph.yml +20 -0
  17. data/.stylelintignore +4 -0
  18. data/.stylelintrc +6 -0
  19. data/CODE_OF_CONDUCT.md +22 -0
  20. data/Gemfile +57 -3
  21. data/LICENSE +1 -1
  22. data/README.md +89 -0
  23. data/Rakefile +1 -1
  24. data/SECURITY.md +1 -0
  25. data/app/assets/config/spree_frontend_manifest.js +5 -0
  26. data/app/assets/images/arrow-down.svg +12 -0
  27. data/app/assets/images/arrow-right-circle-fill.svg +3 -0
  28. data/app/assets/images/card-image.svg +4 -0
  29. data/app/assets/images/edit.svg +1 -1
  30. data/app/assets/images/favicon.ico +0 -0
  31. data/app/assets/images/file-image.svg +4 -0
  32. data/app/assets/images/global.svg +1 -0
  33. data/app/assets/images/image.svg +4 -0
  34. data/app/assets/images/info.svg +7 -0
  35. data/app/assets/images/logo/spree_50.png +0 -0
  36. data/app/assets/images/logo-spree.png +0 -0
  37. data/app/assets/images/logo.png +0 -0
  38. data/app/assets/images/logo.svg +10 -1
  39. data/app/assets/images/logo@2x.png +0 -0
  40. data/app/assets/images/logo@3x.png +0 -0
  41. data/app/assets/images/noimage/large.png +0 -0
  42. data/app/assets/images/noimage/mini.png +0 -0
  43. data/app/assets/images/noimage/plp.png +0 -0
  44. data/app/assets/images/noimage/plp.svg +16 -0
  45. data/app/assets/images/noimage/product.png +0 -0
  46. data/app/assets/images/noimage/small.png +0 -0
  47. data/app/assets/images/pagination-arrow-right.svg +3 -10
  48. data/app/assets/images/pagination-double-arrow-right.svg +6 -13
  49. data/app/assets/images/plus.svg +1 -1
  50. data/app/assets/images/search.svg +1 -1
  51. data/app/assets/javascripts/spree/frontend/account.js +1 -1
  52. data/app/assets/javascripts/spree/frontend/api/main.js +36 -0
  53. data/app/assets/javascripts/spree/frontend/api/storefront/cart.js +49 -0
  54. data/app/assets/javascripts/spree/frontend/cart.js +24 -2
  55. data/app/assets/javascripts/spree/frontend/checkout/address.js +78 -52
  56. data/app/assets/javascripts/spree/frontend/checkout/address_book.js +38 -40
  57. data/app/assets/javascripts/spree/frontend/checkout/payment.js +63 -23
  58. data/app/assets/javascripts/spree/frontend/checkout/shipment.js +15 -2
  59. data/app/assets/javascripts/spree/frontend/checkout.js +17 -1
  60. data/app/assets/javascripts/spree/frontend/coupon_manager.js +1 -1
  61. data/app/assets/javascripts/spree/frontend/currency.js +44 -0
  62. data/app/assets/javascripts/spree/frontend/locale.es6 +12 -0
  63. data/app/assets/javascripts/spree/frontend/login.js +5 -0
  64. data/app/assets/javascripts/spree/frontend/main.js +78 -0
  65. data/app/assets/javascripts/spree/frontend/main_nav_bar.js +86 -0
  66. data/app/assets/javascripts/spree/frontend/{turbolinks_scroll_fix.js → turbo_scroll_fix.js} +3 -3
  67. data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +4 -4
  68. data/app/assets/javascripts/spree/frontend/views/spree/product/related.js +3 -3
  69. data/app/assets/javascripts/spree/frontend/views/spree/products/cart_form.js +67 -18
  70. data/app/assets/javascripts/spree/frontend/views/spree/products/description.js +1 -1
  71. data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +76 -15
  72. data/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6 +46 -0
  73. data/app/assets/javascripts/spree/frontend/views/spree/shared/mobile_navigation.js +9 -10
  74. data/app/assets/javascripts/spree/frontend/views/spree/shared/product_added_modal.js +7 -0
  75. data/app/assets/javascripts/spree/frontend/views/spree/shared/variant_select.js +93 -0
  76. data/app/assets/javascripts/spree/frontend.js +68 -11
  77. data/app/assets/stylesheets/spree/frontend/application.scss +5 -2
  78. data/app/assets/stylesheets/spree/frontend/components-bootstrap/button.scss +8 -0
  79. data/app/assets/stylesheets/spree/frontend/components-bootstrap/carousel.scss +4 -0
  80. data/app/assets/stylesheets/spree/frontend/components-custom/inputs.scss +80 -1
  81. data/app/assets/stylesheets/spree/frontend/flags/_flag-icon-base.scss +23 -0
  82. data/app/assets/stylesheets/spree/frontend/flags/_flag-icon-list.scss +265 -0
  83. data/app/assets/stylesheets/spree/frontend/flags/_variables.scss +2 -0
  84. data/app/assets/stylesheets/spree/frontend/flags/flag-icon.scss +3 -0
  85. data/app/assets/stylesheets/spree/frontend/functions.scss +1 -0
  86. data/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss +48 -0
  87. data/app/assets/stylesheets/spree/frontend/variables/bootstrap-overrides.scss +2 -2
  88. data/app/assets/stylesheets/spree/frontend/variables/helper-variables.scss +1 -0
  89. data/app/assets/stylesheets/spree/frontend/variables/variables.scss +54 -0
  90. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/confirm.scss +27 -26
  91. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/delivery.scss +6 -0
  92. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/edit.scss +24 -10
  93. data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss +1 -0
  94. data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss +20 -0
  95. data/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss +54 -67
  96. data/app/assets/stylesheets/spree/frontend/views/spree/orders/edit.scss +4 -3
  97. data/app/assets/stylesheets/spree/frontend/views/spree/orders/show.scss +3 -0
  98. data/app/assets/stylesheets/spree/frontend/views/spree/products/cart_form.scss +8 -0
  99. data/app/assets/stylesheets/spree/frontend/views/spree/products/gallery_modal.scss +7 -0
  100. data/app/assets/stylesheets/spree/frontend/views/spree/products/index.scss +55 -26
  101. data/app/assets/stylesheets/spree/frontend/views/spree/products/show.scss +7 -0
  102. data/app/assets/stylesheets/spree/frontend/views/spree/shared/_color_select.scss +10 -9
  103. data/app/assets/stylesheets/spree/frontend/views/spree/shared/carousel/single.scss +1 -1
  104. data/app/assets/stylesheets/spree/frontend/views/spree/shared/carousel/thumbnails.scss +1 -0
  105. data/app/assets/stylesheets/spree/frontend/views/spree/shared/cart.scss +9 -4
  106. data/app/assets/stylesheets/spree/frontend/views/spree/shared/category_nav_bar.scss +3 -3
  107. data/app/assets/stylesheets/spree/frontend/views/spree/shared/change_store.scss +7 -0
  108. data/app/assets/stylesheets/spree/frontend/views/spree/shared/footer.scss +4 -0
  109. data/app/assets/stylesheets/spree/frontend/views/spree/shared/main_nav_bar.scss +42 -26
  110. data/app/assets/stylesheets/spree/frontend/views/spree/shared/mobile_navigation.scss +34 -3
  111. data/app/assets/stylesheets/spree/frontend/views/spree/shared/nav_bar.scss +24 -7
  112. data/app/assets/stylesheets/spree/frontend/views/spree/shared/quantity_select.scss +9 -12
  113. data/app/assets/stylesheets/spree/frontend/views/spree/shared/search_form.scss +12 -0
  114. data/app/assets/stylesheets/spree/frontend/views/spree/users/show.scss +7 -13
  115. data/app/assets/stylesheets/spree/frontend.css +0 -1
  116. data/app/controllers/concerns/spree/checkout/address_book.rb +9 -7
  117. data/app/controllers/concerns/spree/locale_urls.rb +21 -0
  118. data/app/controllers/spree/addresses_controller.rb +16 -33
  119. data/app/controllers/spree/checkout_controller.rb +15 -13
  120. data/app/controllers/spree/cms_pages_controller.rb +29 -0
  121. data/app/controllers/spree/content_controller.rb +0 -2
  122. data/app/controllers/spree/currency_controller.rb +17 -0
  123. data/app/controllers/spree/errors_controller.rb +11 -0
  124. data/app/controllers/spree/home_controller.rb +38 -1
  125. data/app/controllers/spree/locale_controller.rb +35 -6
  126. data/app/controllers/spree/orders_controller.rb +12 -10
  127. data/app/controllers/spree/products_controller.rb +46 -28
  128. data/app/controllers/spree/store_controller.rb +77 -12
  129. data/app/controllers/spree/taxons_controller.rb +16 -8
  130. data/app/helpers/spree/addresses_helper.rb +64 -12
  131. data/app/helpers/spree/cache_helper.rb +7 -0
  132. data/app/helpers/spree/cms_pages_helper.rb +23 -0
  133. data/app/helpers/spree/frontend_helper.rb +170 -18
  134. data/app/helpers/spree/navigation_helper.rb +81 -4
  135. data/app/helpers/spree/products_filters_helper.rb +168 -0
  136. data/app/helpers/spree/store_helper.rb +41 -0
  137. data/app/helpers/spree/structured_data_helper.rb +6 -2
  138. data/app/helpers/spree/taxons_helper.rb +2 -2
  139. data/app/services/spree/build_localized_redirect_url.rb +141 -0
  140. data/app/views/kaminari/twitter-bootstrap-4/_first_page.html.erb +3 -3
  141. data/app/views/kaminari/twitter-bootstrap-4/_gap.html.erb +2 -2
  142. data/app/views/kaminari/twitter-bootstrap-4/_last_page.html.erb +3 -3
  143. data/app/views/kaminari/twitter-bootstrap-4/_next_page.html.erb +3 -3
  144. data/app/views/kaminari/twitter-bootstrap-4/_page.html.erb +2 -2
  145. data/app/views/kaminari/twitter-bootstrap-4/_paginator.html.erb +2 -2
  146. data/app/views/kaminari/twitter-bootstrap-4/_prev_page.html.erb +3 -3
  147. data/app/views/spree/address/_form.html.erb +26 -27
  148. data/app/views/spree/addresses/_form.html.erb +15 -6
  149. data/app/views/spree/addresses/edit.html.erb +13 -8
  150. data/app/views/spree/addresses/new.html.erb +8 -4
  151. data/app/views/spree/checkout/_address.html.erb +19 -23
  152. data/app/views/spree/checkout/_confirm.html.erb +1 -75
  153. data/app/views/spree/checkout/_credit_card.html.erb +3 -2
  154. data/app/views/spree/checkout/_delivery.html.erb +11 -4
  155. data/app/views/spree/checkout/_delivery_informations.html.erb +51 -0
  156. data/app/views/spree/checkout/_payment.html.erb +5 -24
  157. data/app/views/spree/checkout/_payment_sources.html.erb +17 -0
  158. data/app/views/spree/checkout/_summary.html.erb +22 -19
  159. data/app/views/spree/checkout/edit.html.erb +22 -2
  160. data/app/views/spree/checkout/payment/_gateway.html.erb +2 -2
  161. data/app/views/spree/checkout/registration.html.erb +3 -3
  162. data/app/views/spree/cms_pages/show.html.erb +16 -0
  163. data/app/views/spree/errors/not_found.html.erb +2 -2
  164. data/app/views/spree/home/index.html.erb +17 -123
  165. data/app/views/spree/layouts/checkout.html.erb +3 -1
  166. data/app/views/spree/layouts/spree_application.html.erb +3 -2
  167. data/app/views/spree/locale/index.html.erb +1 -0
  168. data/app/views/spree/orders/_coupon_code.html.erb +3 -4
  169. data/app/views/spree/orders/_line_item.html.erb +4 -4
  170. data/app/views/spree/orders/_line_item_data.html.erb +3 -3
  171. data/app/views/spree/orders/edit.html.erb +2 -3
  172. data/app/views/spree/orders/show.html.erb +2 -72
  173. data/app/views/spree/products/_cart_form.html.erb +5 -2
  174. data/app/views/spree/products/_color_option_type.html.erb +14 -14
  175. data/app/views/spree/products/_description.html.erb +19 -14
  176. data/app/views/spree/products/_filters_desktop.html.erb +80 -40
  177. data/app/views/spree/products/_filters_mobile.html.erb +47 -15
  178. data/app/views/spree/products/_gallery.html.erb +4 -6
  179. data/app/views/spree/products/_gallery_modal.html.erb +4 -6
  180. data/app/views/spree/products/_option_type.html.erb +1 -3
  181. data/app/views/spree/products/_product.html.erb +1 -1
  182. data/app/views/spree/products/_properties.html.erb +6 -4
  183. data/app/views/spree/products/_sort_desktop.html.erb +20 -14
  184. data/app/views/spree/products/_sort_mobile.html.erb +24 -8
  185. data/app/views/spree/products/_thumbnails.html.erb +2 -2
  186. data/app/views/spree/products/index.html.erb +7 -4
  187. data/app/views/spree/products/related.html.erb +11 -5
  188. data/app/views/spree/products/show.html.erb +2 -3
  189. data/app/views/spree/shared/_breadcrumbs.html.erb +2 -2
  190. data/app/views/spree/shared/_carousel_4_products.html.erb +14 -20
  191. data/app/views/spree/shared/_cart.html.erb +1 -1
  192. data/app/views/spree/shared/_checkout_header.html.erb +22 -21
  193. data/app/views/spree/shared/_color_select.html.erb +3 -3
  194. data/app/views/spree/shared/_copyright.html.erb +1 -10
  195. data/app/views/spree/shared/_currency_dropdown.html.erb +13 -0
  196. data/app/views/spree/shared/_delete_address_popup.html.erb +1 -2
  197. data/app/views/spree/shared/_error_messages.html.erb +2 -2
  198. data/app/views/spree/shared/_footer.html.erb +31 -21
  199. data/app/views/spree/shared/_get_started.html.erb +32 -0
  200. data/app/views/spree/shared/_head.html.erb +8 -5
  201. data/app/views/spree/shared/_header.html.erb +4 -4
  202. data/app/views/spree/shared/_internationalization_options.html.erb +31 -0
  203. data/app/views/spree/shared/_line_item.html.erb +3 -3
  204. data/app/views/spree/shared/_link_to_account.html.erb +7 -4
  205. data/app/views/spree/shared/_link_to_cart.html.erb +1 -2
  206. data/app/views/spree/shared/_locale_and_currency.html.erb +6 -0
  207. data/app/views/spree/shared/_locale_dropdown.html.erb +13 -0
  208. data/app/views/spree/shared/_login.html.erb +5 -5
  209. data/app/views/spree/shared/_main_nav_bar.html.erb +69 -45
  210. data/app/views/spree/shared/_mobile_internationalization_options.html.erb +37 -0
  211. data/app/views/spree/shared/_mobile_navigation.html.erb +48 -63
  212. data/app/views/spree/shared/_nav_bar.html.erb +9 -19
  213. data/app/views/spree/shared/_no_product_available.html.erb +1 -1
  214. data/app/views/spree/shared/_option_values.html.erb +2 -21
  215. data/app/views/spree/shared/_order_details.html.erb +117 -174
  216. data/app/views/spree/shared/_paths.html.erb +8 -0
  217. data/app/views/spree/shared/_payment.html.erb +2 -2
  218. data/app/views/spree/shared/_payment_sources.html.erb +2 -2
  219. data/app/views/spree/shared/_product_added_modal.html.erb +3 -3
  220. data/app/views/spree/shared/_properties.html.erb +4 -0
  221. data/app/views/spree/shared/_quantity_select.html.erb +2 -2
  222. data/app/views/spree/shared/_search.html.erb +9 -13
  223. data/app/views/spree/shared/_translations.html.erb +8 -7
  224. data/app/views/spree/shared/carousel/_single.html.erb +9 -14
  225. data/app/views/spree/shared/carousel/_thumbnails.html.erb +35 -39
  226. data/app/views/spree/shared/cms/pages/_edit_mode.html.erb +13 -0
  227. data/app/views/spree/shared/cms/sections/_featured_article.html.erb +27 -0
  228. data/app/views/spree/shared/cms/sections/_hero_image.html.erb +60 -0
  229. data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +171 -0
  230. data/app/views/spree/shared/cms/sections/_product_carousel.html.erb +5 -0
  231. data/app/views/spree/shared/cms/sections/_rich_text_content.html.erb +3 -0
  232. data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +118 -0
  233. data/app/views/spree/taxons/_header.html.erb +7 -2
  234. data/app/views/spree/users/_address.html.erb +16 -24
  235. data/app/views/spree/users/_address_controls.html.erb +10 -0
  236. data/app/views/spree/users/show.html.erb +21 -16
  237. data/config/initializers/admin_actions.rb +18 -0
  238. data/config/initializers/assets.rb +4 -13
  239. data/config/initializers/canonical_rails.rb +1 -1
  240. data/config/routes.rb +30 -26
  241. data/lib/generators/spree/frontend/copy_storefront/copy_storefront_generator.rb +1 -7
  242. data/lib/generators/spree/frontend/install/install_generator.rb +34 -0
  243. data/lib/generators/spree/frontend/install/templates/app/assets/config/manifest.js +2 -0
  244. data/lib/generators/spree/frontend/install/templates/vendor/assets/javascripts/spree/frontend/all.js +8 -0
  245. data/lib/generators/spree/frontend/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +9 -0
  246. data/lib/spree/frontend/configuration.rb +18 -0
  247. data/lib/spree/frontend/engine.rb +3 -1
  248. data/lib/spree/frontend/version.rb +9 -0
  249. data/lib/spree/frontend.rb +8 -4
  250. data/license.md +13 -0
  251. data/spec/fixtures/files/store_favicon.ico +0 -0
  252. data/spree_frontend.gemspec +26 -14
  253. data/vendor/assets/javascripts/cleave.js +8 -0
  254. data/vendor/assets/javascripts/fetch.umd.js +531 -0
  255. data/vendor/assets/javascripts/jquery.payment.js +652 -0
  256. data/vendor/assets/javascripts/jsuri.js +458 -0
  257. data/vendor/assets/javascripts/polyfill.min.js +1 -0
  258. metadata +224 -86
  259. data/app/assets/images/homepage/big_category_banner.jpg +0 -0
  260. data/app/assets/images/homepage/big_category_banner_mobile.jpg +0 -0
  261. data/app/assets/images/homepage/big_category_banner_tablet_landscape.jpg +0 -0
  262. data/app/assets/images/homepage/big_category_banner_tablet_portrait.jpg +0 -0
  263. data/app/assets/images/homepage/category_banner_lower.jpg +0 -0
  264. data/app/assets/images/homepage/category_banner_lower_mobile.jpg +0 -0
  265. data/app/assets/images/homepage/category_banner_lower_tablet_landscape.jpg +0 -0
  266. data/app/assets/images/homepage/category_banner_lower_tablet_portrait.jpg +0 -0
  267. data/app/assets/images/homepage/category_banner_upper.jpg +0 -0
  268. data/app/assets/images/homepage/category_banner_upper_mobile.jpg +0 -0
  269. data/app/assets/images/homepage/category_banner_upper_tablet_landscape.jpg +0 -0
  270. data/app/assets/images/homepage/category_banner_upper_tablet_portrait.jpg +0 -0
  271. data/app/assets/images/homepage/main_banner.jpg +0 -0
  272. data/app/assets/images/homepage/main_banner_mobile.jpg +0 -0
  273. data/app/assets/images/homepage/main_banner_tablet_landscape.jpg +0 -0
  274. data/app/assets/images/homepage/main_banner_tablet_portrait.jpg +0 -0
  275. data/app/assets/images/homepage/promo_banner_left.jpg +0 -0
  276. data/app/assets/images/homepage/promo_banner_left_mobile.jpg +0 -0
  277. data/app/assets/images/homepage/promo_banner_left_tablet_landscape.jpg +0 -0
  278. data/app/assets/images/homepage/promo_banner_left_tablet_portrait.jpg +0 -0
  279. data/app/assets/images/homepage/promo_banner_right.jpg +0 -0
  280. data/app/assets/images/homepage/promo_banner_right_mobile.jpg +0 -0
  281. data/app/assets/images/homepage/promo_banner_right_tablet_landscape.jpg +0 -0
  282. data/app/assets/images/homepage/promo_banner_right_tablet_portrait.jpg +0 -0
  283. data/app/assets/images/meganav/promo_banner_left-first-category.jpg +0 -0
  284. data/app/assets/images/meganav/promo_banner_left-second-category.jpg +0 -0
  285. data/app/assets/images/meganav/promo_banner_left-third-category.jpg +0 -0
  286. data/app/assets/images/meganav/promo_banner_right-first-category.jpg +0 -0
  287. data/app/assets/images/meganav/promo_banner_right-second-category.jpg +0 -0
  288. data/app/assets/images/meganav/promo_banner_right-third-category.jpg +0 -0
  289. data/app/assets/images/noimage/big_category_banner.jpg +0 -0
  290. data/app/assets/images/noimage/big_category_banner_mobile.jpg +0 -0
  291. data/app/assets/images/noimage/big_category_banner_tablet_landscape.jpg +0 -0
  292. data/app/assets/images/noimage/big_category_banner_tablet_portrait.jpg +0 -0
  293. data/app/assets/images/noimage/category_banner.jpg +0 -0
  294. data/app/assets/images/noimage/category_banner_mobile.jpg +0 -0
  295. data/app/assets/images/noimage/category_banner_plp.jpg +0 -0
  296. data/app/assets/images/noimage/category_banner_tablet_landscape.jpg +0 -0
  297. data/app/assets/images/noimage/category_banner_tablet_portrait.jpg +0 -0
  298. data/app/assets/images/noimage/main_banner.jpg +0 -0
  299. data/app/assets/images/noimage/main_banner_mobile.jpg +0 -0
  300. data/app/assets/images/noimage/main_banner_tablet_landscape.jpg +0 -0
  301. data/app/assets/images/noimage/main_banner_tablet_portrait.jpg +0 -0
  302. data/app/assets/images/noimage/product_photo.jpg +0 -0
  303. data/app/assets/images/noimage/promo_banner.jpg +0 -0
  304. data/app/assets/images/noimage/promo_banner_megamenu.jpg +0 -0
  305. data/app/assets/images/noimage/promo_banner_mobile.jpg +0 -0
  306. data/app/assets/images/noimage/promo_banner_tablet_landscape.jpg +0 -0
  307. data/app/assets/images/noimage/promo_banner_tablet_portrait.jpg +0 -0
  308. data/app/assets/images/spark-logo@3x.png +0 -0
  309. data/app/assets/stylesheets/spree/frontend/_glyphicons_urls_fix.scss +0 -10
  310. data/app/assets/stylesheets/spree/frontend/address_book.scss +0 -8
  311. data/app/models/spree/frontend_configuration.rb +0 -7
  312. data/app/views/spree/shared/_taxonomies.html.erb +0 -16
  313. /data/app/views/spree/{shared → errors}/forbidden.html.erb +0 -0
  314. /data/app/views/spree/{shared → errors}/unauthorized.html.erb +0 -0
@@ -16,7 +16,7 @@
16
16
  .account-page {
17
17
  font-weight: 500;
18
18
  h3 {
19
- color: theme-color('dark-text');
19
+ color: $font-color;
20
20
  margin: 33px 0;
21
21
  font-size: font-px-to-rem(32px);
22
22
 
@@ -36,11 +36,11 @@
36
36
  }
37
37
 
38
38
  thead {
39
- border-bottom: 1px solid theme-color('borders');
39
+ border-bottom: 1px solid $global-border-style;
40
40
  }
41
41
 
42
42
  th {
43
- color: theme-color('secondary');
43
+ color: theme-color("secondary");
44
44
  padding: 7.5px 0;
45
45
  }
46
46
 
@@ -50,7 +50,7 @@
50
50
  }
51
51
 
52
52
  &-user-info {
53
- border-bottom: 1px solid theme-color('borders');
53
+ border-bottom: 1px solid $global-border-style;
54
54
 
55
55
  &-item {
56
56
  address {
@@ -62,12 +62,6 @@
62
62
  font-size: font-px-to-rem(18px);
63
63
  }
64
64
  }
65
-
66
- .delete-address-img {
67
- @include svg-sizes;
68
- color: $primary-color;
69
- }
70
-
71
65
  margin-top: 20px;
72
66
 
73
67
  @include media-breakpoint-up(lg) {
@@ -77,7 +71,7 @@
77
71
  }
78
72
  &-title {
79
73
  @include item-title-font-size;
80
- color: theme-color('dark-text');
74
+ color: $font-color;
81
75
  margin-top: 25px;
82
76
  font-weight: 500;
83
77
 
@@ -220,7 +214,7 @@
220
214
  order: 3;
221
215
  font-size: font-px-to-rem(16px);
222
216
  a {
223
- color: theme-color('dark-text');
217
+ color: $font-color;
224
218
  }
225
219
  @include media-breakpoint-up(md) {
226
220
  font-size: font-px-to-rem(29px);
@@ -312,7 +306,7 @@
312
306
  }
313
307
 
314
308
  &-text-primary {
315
- color: theme-color('primary');
309
+ color: theme-color("primary");
316
310
  }
317
311
 
318
312
  &-lead {
@@ -1,6 +1,5 @@
1
1
  /*
2
2
  * This is a manifest file that includes stylesheets for spree_frontend
3
- *= require spree/frontend/address_book
4
3
  *= require spree/frontend/application
5
4
  *= require_self
6
5
  */
@@ -32,21 +32,23 @@ module Spree
32
32
  end
33
33
 
34
34
  def normalize_addresses
35
- return unless params[:state] == 'address' && @order.bill_address_id && @order.ship_address_id
35
+ return unless params[:state] == 'address' && @order.bill_address_id
36
36
 
37
- # ensure that there is no validation errors and addresses were saved
38
- return unless @order.bill_address && @order.ship_address
37
+ if @order.checkout_steps.include?('delivery')
38
+ return unless @order.ship_address_id
39
+ end
39
40
 
40
41
  bill_address = @order.bill_address
41
42
  ship_address = @order.ship_address
43
+
44
+ if params[:save_user_address].present? && try_spree_current_user.present?
45
+ [bill_address, ship_address].each { |address| address&.update_attribute(:user_id, try_spree_current_user&.id) }
46
+ end
47
+
42
48
  if @order.bill_address_id != @order.ship_address_id && bill_address == ship_address
43
49
  @order.update_column(:bill_address_id, ship_address.id)
44
50
  bill_address.destroy
45
- elsif params[:save_user_address]
46
- bill_address.update_attribute(:user_id, try_spree_current_user&.id)
47
51
  end
48
-
49
- ship_address.update_attribute(:user_id, try_spree_current_user&.id) if params[:save_user_address]
50
52
  end
51
53
  end
52
54
  end
@@ -0,0 +1,21 @@
1
+ module Spree
2
+ module LocaleUrls
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :redirect_to_default_locale
7
+ end
8
+
9
+ private
10
+
11
+ def default_url_options
12
+ super.merge(locale: locale_param, currency: currency_param)
13
+ end
14
+
15
+ def redirect_to_default_locale
16
+ return if params[:locale].blank? || supported_locale?(params[:locale])
17
+
18
+ redirect_to url_for(request.parameters.merge(locale: nil))
19
+ end
20
+ end
21
+ end
@@ -4,17 +4,13 @@ module Spree
4
4
  helper Spree::AddressesHelper
5
5
  load_and_authorize_resource class: Spree::Address
6
6
 
7
- def index
8
- @addresses = try_spree_current_user.addresses
9
- end
10
-
11
7
  def create
12
8
  @address = try_spree_current_user.addresses.build(address_params)
13
- if @address.save
9
+ if create_service.call(user: try_spree_current_user, address_params: @address.attributes).success?
14
10
  flash[:notice] = I18n.t(:successfully_created, scope: :address_book)
15
11
  redirect_to spree.account_path
16
12
  else
17
- render action: 'new'
13
+ render action: 'new', status: :unprocessable_entity
18
14
  end
19
15
  end
20
16
 
@@ -23,27 +19,15 @@ module Spree
23
19
  end
24
20
 
25
21
  def new
26
- @address = Spree::Address.default
22
+ @address = Spree::Address.new(country: current_store.default_country, user: try_spree_current_user)
27
23
  end
28
24
 
29
25
  def update
30
- if @address.editable?
31
- if @address.update(address_params)
32
- flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
33
- redirect_back_or_default(addresses_path)
34
- else
35
- render :edit
36
- end
26
+ if update_service.call(address: @address, address_params: address_params).success?
27
+ flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
28
+ redirect_back_or_default(addresses_path)
37
29
  else
38
- new_address = @address.clone
39
- new_address.attributes = address_params
40
- @address.update_attribute(:deleted_at, Time.current)
41
- if new_address.save
42
- flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
43
- redirect_back_or_default(addresses_path)
44
- else
45
- render :edit
46
- end
30
+ render :edit, status: :unprocessable_entity
47
31
  end
48
32
  end
49
33
 
@@ -57,16 +41,15 @@ module Spree
57
41
  private
58
42
 
59
43
  def address_params
60
- params[:address].permit(:address,
61
- :firstname,
62
- :lastname,
63
- :address1,
64
- :address2,
65
- :city,
66
- :state_id,
67
- :zipcode,
68
- :country_id,
69
- :phone)
44
+ params.require(:address).permit(permitted_address_attributes)
45
+ end
46
+
47
+ def create_service
48
+ Spree::Dependencies.address_create_service.constantize
49
+ end
50
+
51
+ def update_service
52
+ Spree::Dependencies.address_update_service.constantize
70
53
  end
71
54
  end
72
55
  end
@@ -35,7 +35,7 @@ module Spree
35
35
  @order.temporary_address = !params[:save_user_address]
36
36
  unless @order.next
37
37
  flash[:error] = @order.errors.full_messages.join("\n")
38
- redirect_to(checkout_state_path(@order.state)) && return
38
+ redirect_to(spree.checkout_state_path(@order.state)) && return
39
39
  end
40
40
 
41
41
  if @order.completed?
@@ -43,10 +43,10 @@ module Spree
43
43
  flash['order_completed'] = true
44
44
  redirect_to completion_route
45
45
  else
46
- redirect_to checkout_state_path(@order.state)
46
+ redirect_to spree.checkout_state_path(@order.state)
47
47
  end
48
48
  else
49
- render :edit
49
+ render :edit, status: :unprocessable_entity
50
50
  end
51
51
  end
52
52
 
@@ -77,7 +77,7 @@ module Spree
77
77
  if @order.state != correct_state && !skip_state_validation?
78
78
  flash.keep
79
79
  @order.update_column(:state, correct_state)
80
- redirect_to checkout_state_path(@order.state)
80
+ redirect_to spree.checkout_state_path(@order.state)
81
81
  end
82
82
  end
83
83
 
@@ -108,7 +108,7 @@ module Spree
108
108
 
109
109
  def set_state_if_present
110
110
  if params[:state]
111
- redirect_to checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
111
+ redirect_to spree.checkout_state_path(@order.state) if @order.can_go_to_state?(params[:state]) && !skip_state_validation?
112
112
  @order.state = params[:state]
113
113
  end
114
114
  end
@@ -129,8 +129,8 @@ module Spree
129
129
  end
130
130
 
131
131
  # Provides a route to redirect after order completion
132
- def completion_route(custom_params = nil)
133
- spree.order_path(@order, custom_params)
132
+ def completion_route(custom_params = {})
133
+ spree.order_path(@order, custom_params.merge(locale: locale_param))
134
134
  end
135
135
 
136
136
  def setup_for_current_state
@@ -141,8 +141,8 @@ module Spree
141
141
  def before_address
142
142
  # if the user has a default address, a callback takes care of setting
143
143
  # that; but if he doesn't, we need to build an empty one here
144
- @order.bill_address ||= Address.build_default
145
- @order.ship_address ||= Address.build_default if @order.checkout_steps.include?('delivery')
144
+ @order.bill_address ||= Address.new(country: current_store.default_country, user: try_spree_current_user)
145
+ @order.ship_address ||= Address.new(country: current_store.default_country, user: try_spree_current_user) if @order.checkout_steps.include?('delivery')
146
146
  end
147
147
 
148
148
  def before_delivery
@@ -161,7 +161,9 @@ module Spree
161
161
  end
162
162
  end
163
163
 
164
- @payment_sources = try_spree_current_user.payment_sources if try_spree_current_user&.respond_to?(:payment_sources)
164
+ return unless try_spree_current_user.respond_to?(:payment_sources)
165
+
166
+ @payment_sources = try_spree_current_user.payment_sources.where(payment_method: @order.available_payment_methods)
165
167
  end
166
168
 
167
169
  def add_store_credit_payments
@@ -174,21 +176,21 @@ module Spree
174
176
  params.delete(:payment_source)
175
177
 
176
178
  # Return to the Payments page if additional payment is needed.
177
- redirect_to checkout_state_path(@order.state) and return if @order.payments.valid.sum(:amount) < @order.total
179
+ redirect_to spree.checkout_state_path(@order.state) and return if @order.payments.valid.sum(:amount) < @order.total
178
180
  end
179
181
  end
180
182
 
181
183
  def remove_store_credit_payments
182
184
  if params.key?(:remove_store_credit)
183
185
  remove_store_credit_service.call(order: @order)
184
- redirect_to checkout_state_path(@order.state) and return
186
+ redirect_to spree.checkout_state_path(@order.state) and return
185
187
  end
186
188
  end
187
189
 
188
190
  def rescue_from_spree_gateway_error(exception)
189
191
  flash.now[:error] = Spree.t(:spree_gateway_error_flash_for_checkout)
190
192
  @order.errors.add(:base, exception.message)
191
- render :edit
193
+ render :edit, status: :unprocessable_entity
192
194
  end
193
195
 
194
196
  def check_authorization
@@ -0,0 +1,29 @@
1
+ module Spree
2
+ class CmsPagesController < Spree::StoreController
3
+ before_action :load_cms_page, only: [:show]
4
+
5
+ include Spree::FrontendHelper
6
+ include Spree::CacheHelper
7
+
8
+ def show
9
+ if @page&.visible?
10
+ @cms_page = @page
11
+ elsif @page&.draft_mode? && try_spree_current_user&.admin?
12
+ @cms_page = @page
13
+ @edit_mode = true
14
+ else
15
+ raise ActiveRecord::RecordNotFound
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def accurate_title
22
+ @page&.seo_title || super
23
+ end
24
+
25
+ def load_cms_page
26
+ @page = Spree::CmsPage.for_store(current_store).by_locale(I18n.locale).find_by(slug: params[:slug])
27
+ end
28
+ end
29
+ end
@@ -3,8 +3,6 @@ module Spree
3
3
  # Don't serve local files or static assets
4
4
  after_action :fire_visited_path, except: :cvv
5
5
 
6
- respond_to :html
7
-
8
6
  def test; end
9
7
 
10
8
  def cvv
@@ -0,0 +1,17 @@
1
+ module Spree
2
+ class CurrencyController < StoreController
3
+ def set
4
+ new_currency = params[:switch_to_currency]&.upcase
5
+
6
+ if new_currency.present? && supported_currency?(new_currency)
7
+ current_order&.update(currency: new_currency)
8
+ session[:currency] = new_currency
9
+ end
10
+
11
+ respond_to do |format|
12
+ format.html { redirect_back fallback_location: spree.root_path(currency: new_currency) }
13
+ format.json { head :ok }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class ErrorsController < StoreController
3
+ def forbidden
4
+ render status: 403
5
+ end
6
+
7
+ def unauthorized
8
+ render status: 401
9
+ end
10
+ end
11
+ end
@@ -1,9 +1,46 @@
1
1
  module Spree
2
2
  class HomeController < Spree::StoreController
3
+ include Spree::CacheHelper
4
+
5
+ before_action :load_homepage, only: [:index]
6
+
3
7
  respond_to :html
4
8
 
5
9
  def index
6
- fresh_when etag: store_etag, last_modified: store_last_modified, public: true
10
+ if @cms_home_page&.visible?
11
+ @homepage = @cms_home_page
12
+ elsif try_spree_current_user&.admin?
13
+ @homepage = @cms_home_page
14
+ @edit_mode = true
15
+ end
16
+
17
+ if http_cache_enabled?
18
+ fresh_when etag: store_etag, last_modified: last_modified_index, public: true
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def etag_index
25
+ [
26
+ store_etag,
27
+ last_modified_index,
28
+ ]
29
+ end
30
+
31
+ def last_modified_index
32
+ page_last_modified = @cms_home_page&.maximum(:updated_at)&.utc if @cms_home_page.respond_to?(:maximum)
33
+ current_store_last_modified = current_store.updated_at.utc
34
+
35
+ [page_last_modified, current_store_last_modified].compact.max
36
+ end
37
+
38
+ def accurate_title
39
+ @cms_home_page&.seo_title || super
40
+ end
41
+
42
+ def load_homepage
43
+ @cms_home_page = current_store.homepage(I18n.locale)
7
44
  end
8
45
  end
9
46
  end
@@ -1,14 +1,43 @@
1
1
  module Spree
2
2
  class LocaleController < Spree::StoreController
3
+ REDIRECT_TO_ROOT = /\/(pages)\//.freeze
4
+
5
+ def index
6
+ render :index, layout: false
7
+ end
8
+
3
9
  def set
4
- session['user_return_to'] = request.referer if request.referer&.starts_with?('http://' + request.host)
5
- if params[:locale] && I18n.available_locales.map(&:to_s).include?(params[:locale])
6
- session[:locale] = I18n.locale = params[:locale]
7
- flash.notice = Spree.t(:locale_changed)
10
+ new_locale = (params[:switch_to_locale] || params[:locale]).to_s
11
+
12
+ if new_locale.present? && supported_locale?(new_locale)
13
+
14
+ if try_spree_current_user && try_spree_current_user.selected_locale != new_locale
15
+ try_spree_current_user.update!(selected_locale: new_locale)
16
+ end
17
+
18
+ if should_build_new_url?
19
+ redirect_to BuildLocalizedRedirectUrl.call(
20
+ url: request.env['HTTP_REFERER'],
21
+ locale: new_locale,
22
+ default_locale: current_store.default_locale
23
+ ).value
24
+ else
25
+ redirect_to root_path(locale: new_locale)
26
+ end
27
+ else
28
+ redirect_to root_path
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def should_build_new_url?
35
+ return false if request.env['HTTP_REFERER'].blank?
36
+ if request.env['HTTP_REFERER'].match(REDIRECT_TO_ROOT)
37
+ false
8
38
  else
9
- flash[:error] = Spree.t(:locale_not_changed)
39
+ request.env['HTTP_REFERER'] != request.env['REQUEST_URI']
10
40
  end
11
- redirect_back_or_default(spree.root_path)
12
41
  end
13
42
  end
14
43
  end
@@ -5,42 +5,40 @@ module Spree
5
5
 
6
6
  helper 'spree/products', 'spree/orders'
7
7
 
8
- respond_to :html
9
-
10
8
  before_action :assign_order_with_lock, only: :update
11
9
 
12
10
  def show
13
- @order = Order.includes(line_items: [variant: [:option_values, :images, :product]], bill_address: :state, ship_address: :state).find_by!(number: params[:id])
11
+ @order = current_store.orders.includes(line_items: [variant: [:option_values, :images, :product]], bill_address: :state, ship_address: :state).find_by!(number: params[:id])
14
12
  end
15
13
 
16
14
  def update
17
- @variant = Spree::Variant.find(params[:variant_id]) if params[:variant_id]
15
+ @variant = curret_store.variants.find(params[:variant_id]) if params[:variant_id]
18
16
  if Cart::Update.call(order: @order, params: order_params).success?
19
17
  respond_with(@order) do |format|
20
18
  format.html do
21
19
  if params.key?(:checkout)
22
20
  @order.next if @order.cart?
23
- redirect_to checkout_state_path(@order.checkout_steps.first)
21
+ redirect_to spree.checkout_state_path(@order.checkout_steps.first)
24
22
  else
25
- redirect_to cart_path
23
+ redirect_to spree.cart_path
26
24
  end
27
25
  end
28
26
  end
29
27
  else
30
- respond_with(@order)
28
+ respond_with(@order, status: :unprocessable_entity)
31
29
  end
32
30
  end
33
31
 
34
32
  # Shows the current incomplete order from the session
35
33
  def edit
36
- @order = current_order || Order.incomplete.
34
+ @order = current_order || current_store.orders.incomplete.
37
35
  includes(line_items: [variant: [:images, :product, option_values: :option_type]]).
38
36
  find_or_initialize_by(token: cookies.signed[:token])
39
37
  associate_user
40
38
  end
41
39
 
42
40
  def empty
43
- current_order.try(:empty!)
41
+ cart_empty_service.call(order: current_order)
44
42
 
45
43
  redirect_to spree.cart_path
46
44
  end
@@ -56,7 +54,7 @@ module Spree
56
54
  end
57
55
 
58
56
  def check_authorization
59
- order = Spree::Order.find_by(number: params[:id]) if params[:id].present?
57
+ order = current_store.orders.find_by(number: params[:id]) if params[:id].present?
60
58
  order ||= current_order
61
59
 
62
60
  if order && action_name.to_sym == :show
@@ -87,5 +85,9 @@ module Spree
87
85
  def cart_add_item_service
88
86
  Spree::Dependencies.cart_add_item_service.constantize
89
87
  end
88
+
89
+ def cart_empty_service
90
+ Spree::Dependencies.cart_empty_service.constantize
91
+ end
90
92
  end
91
93
  end
@@ -2,34 +2,29 @@ module Spree
2
2
  class ProductsController < Spree::StoreController
3
3
  include Spree::ProductsHelper
4
4
  include Spree::FrontendHelper
5
+ include Spree::CacheHelper
5
6
 
6
7
  before_action :load_product, only: [:show, :related]
7
8
  before_action :load_taxon, only: :index
8
9
 
9
- respond_to :html
10
+ before_action :can_show_product?, only: :show
10
11
 
11
12
  def index
12
- @searcher = build_searcher(params.merge(include_images: true))
13
+ @searcher = build_searcher(params.merge(include_images: true, current_store: current_store))
13
14
  @products = @searcher.retrieve_products
14
15
 
15
- last_modified = @products.maximum(:updated_at)&.utc if @products.respond_to?(:maximum)
16
-
17
- etag = [
18
- store_etag,
19
- last_modified&.to_i,
20
- available_option_types_cache_key,
21
- filtering_params_cache_key
22
- ]
23
-
24
- fresh_when etag: etag, last_modified: last_modified, public: true
16
+ if http_cache_enabled?
17
+ fresh_when etag: etag_index, last_modified: last_modified_index, public: true
18
+ end
25
19
  end
26
20
 
27
21
  def show
28
22
  redirect_if_legacy_path
29
23
 
30
- @taxon = params[:taxon_id].present? ? Spree::Taxon.find(params[:taxon_id]) : @product.taxons.first
24
+ @taxon = params[:taxon_id].present? ? taxons_scope.find_by(id: params[:taxon_id]) : nil
25
+ @taxon = @product.taxons.first unless @taxon.present?
31
26
 
32
- if stale?(etag: product_etag, last_modified: @product.updated_at.utc, public: true)
27
+ if !http_cache_enabled? || stale?(etag: etag_show, last_modified: last_modified_show, public: true)
33
28
  @product_summary = Spree::ProductSummaryPresenter.new(@product).call
34
29
  @product_properties = @product.product_properties.includes(:property)
35
30
  @product_price = @product.price_in(current_currency).amount
@@ -39,9 +34,7 @@ module Spree
39
34
  end
40
35
 
41
36
  def related
42
- @related_products = related_products
43
-
44
- if @related_products.any?
37
+ if product_relation_types.any?
45
38
  render template: 'spree/products/related', layout: false
46
39
  else
47
40
  head :no_content
@@ -59,19 +52,15 @@ module Spree
59
52
  end
60
53
 
61
54
  def load_product
62
- @products = if try_spree_current_user.try(:has_spree_role?, 'admin')
63
- Product.with_deleted
64
- else
65
- Product.active(current_currency)
66
- end
67
-
68
- @product = @products.includes(:master).
69
- friendly.
70
- find(params[:id])
55
+ @product = find_with_fallback_default_locale { current_store.products.for_user(try_spree_current_user).friendly.find(params[:id]) }
71
56
  end
72
57
 
73
58
  def load_taxon
74
- @taxon = Spree::Taxon.find(params[:taxon]) if params[:taxon].present?
59
+ @taxon = taxons_scope.find(params[:taxon]) if params[:taxon].present?
60
+ end
61
+
62
+ def can_show_product?
63
+ raise ActiveRecord::RecordNotFound if @product.stores.exclude?(current_store)
75
64
  end
76
65
 
77
66
  def load_variants
@@ -96,7 +85,16 @@ module Spree
96
85
  end
97
86
  end
98
87
 
99
- def product_etag
88
+ def etag_index
89
+ [
90
+ store_etag,
91
+ last_modified_index,
92
+ available_option_types_cache_key,
93
+ filtering_params_cache_key
94
+ ]
95
+ end
96
+
97
+ def etag_show
100
98
  [
101
99
  store_etag,
102
100
  @product,
@@ -105,5 +103,25 @@ module Spree
105
103
  @product.possible_promotions.maximum(:updated_at),
106
104
  ]
107
105
  end
106
+
107
+ alias product_etag etag_show
108
+
109
+ def last_modified_index
110
+ products_last_modified = @products.maximum(:updated_at)&.utc if @products.respond_to?(:maximum)
111
+ current_store_last_modified = current_store.updated_at.utc
112
+
113
+ [products_last_modified, current_store_last_modified].compact.max
114
+ end
115
+
116
+ def last_modified_show
117
+ product_last_modified = @product.updated_at.utc
118
+ current_store_last_modified = current_store.updated_at.utc
119
+
120
+ [product_last_modified, current_store_last_modified].compact.max
121
+ end
122
+
123
+ def taxons_scope
124
+ current_store.taxons
125
+ end
108
126
  end
109
127
  end