spree_backend 4.2.5 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/config/spree_backend_manifest.js +129 -0
  4. data/app/assets/images/backend-arrows-fullscreen.svg +3 -0
  5. data/app/assets/images/backend-box.svg +3 -0
  6. data/app/assets/images/backend-circle-fill.svg +3 -0
  7. data/app/assets/images/backend-circle.svg +3 -0
  8. data/app/assets/images/backend-default-layout.svg +6 -0
  9. data/app/assets/images/backend-eye-slash-fill.svg +4 -0
  10. data/app/assets/images/backend-file-richtext.svg +4 -0
  11. data/app/assets/images/backend-fullscreen-exit.svg +3 -0
  12. data/app/assets/images/backend-fullscreen.svg +3 -0
  13. data/app/assets/images/backend-mobile.svg +5 -0
  14. data/app/assets/images/backend-pages.svg +10 -0
  15. data/app/assets/images/backend-phone.svg +4 -0
  16. data/app/assets/images/backend-reversed-layout.svg +6 -0
  17. data/app/assets/images/backend-spree-icon.svg +1 -0
  18. data/app/assets/images/backend-spree-logo.svg +6 -0
  19. data/app/assets/images/backend-store.svg +2 -13
  20. data/app/assets/images/backend-translate.svg +4 -0
  21. data/app/assets/images/backend-users.svg +2 -5
  22. data/app/assets/images/backend-window-sidebar.svg +4 -0
  23. data/app/assets/images/noimage/backend-missing-image.svg +4 -0
  24. data/app/assets/images/noimage/large.png +0 -0
  25. data/app/assets/images/noimage/mini.png +0 -0
  26. data/app/assets/images/noimage/product.png +0 -0
  27. data/app/assets/images/noimage/small.png +0 -0
  28. data/app/assets/javascripts/spree/backend/address_states.es6 +44 -0
  29. data/app/assets/javascripts/spree/backend/admin.js +45 -307
  30. data/app/assets/javascripts/spree/backend/checkouts/edit.js +22 -13
  31. data/app/assets/javascripts/spree/backend/cms/_index.es6 +4 -0
  32. data/app/assets/javascripts/spree/backend/cms/links.es6 +25 -0
  33. data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +34 -0
  34. data/app/assets/javascripts/spree/backend/cms/page.es6 +133 -0
  35. data/app/assets/javascripts/spree/backend/cms/section.es6 +43 -0
  36. data/app/assets/javascripts/spree/backend/global/_index.js +11 -0
  37. data/app/assets/javascripts/spree/backend/global/alerts.es6 +66 -0
  38. data/app/assets/javascripts/spree/backend/global/api_functions.es6 +5 -0
  39. data/app/assets/javascripts/spree/backend/global/bootstrap.es6 +15 -0
  40. data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +22 -0
  41. data/app/assets/javascripts/spree/backend/global/info_alert.es6 +38 -0
  42. data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +18 -0
  43. data/app/assets/javascripts/spree/backend/global/ransack.es6 +108 -0
  44. data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +56 -0
  45. data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +132 -0
  46. data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +87 -0
  47. data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +137 -0
  48. data/app/assets/javascripts/spree/backend/global/sortable.es6 +35 -0
  49. data/app/assets/javascripts/spree/backend/global/tinymce.es6 +11 -0
  50. data/app/assets/javascripts/spree/backend/menus/_index.es6 +2 -0
  51. data/app/assets/javascripts/spree/backend/menus/menu.es6 +57 -0
  52. data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +26 -0
  53. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +13 -17
  54. data/app/assets/javascripts/spree/backend/option_value_picker.js +10 -22
  55. data/app/assets/javascripts/spree/backend/payments/edit.js +1 -1
  56. data/app/assets/javascripts/spree/backend/payments/new.js +18 -5
  57. data/app/assets/javascripts/spree/backend/spree-select2.js +19 -1
  58. data/app/assets/javascripts/spree/backend/stock_location.js +1 -2
  59. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +7 -1
  60. data/app/assets/javascripts/spree/backend/taxons.js +74 -73
  61. data/app/assets/javascripts/spree/backend/user_picker.js +7 -10
  62. data/app/assets/javascripts/spree/backend.js +28 -1
  63. data/app/assets/javascripts/spree.js +78 -0
  64. data/app/assets/stylesheets/spree/backend/components/_filters.scss +1 -3
  65. data/app/assets/stylesheets/spree/backend/components/_main.scss +0 -1
  66. data/app/assets/stylesheets/spree/backend/components/_navbar.scss +35 -0
  67. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +13 -0
  68. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +0 -1
  69. data/app/assets/stylesheets/spree/backend/components/_tables.scss +4 -5
  70. data/app/assets/stylesheets/spree/backend/global/_mixins.scss +59 -0
  71. data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +95 -0
  72. data/app/assets/stylesheets/spree/backend/plugins/{select2_bootstrap4.scss → _select2_bootstrap4.scss} +0 -0
  73. data/app/assets/stylesheets/spree/backend/plugins/_sweetalert2_custom.scss +100 -0
  74. data/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scss +4 -0
  75. data/app/assets/stylesheets/spree/backend/shared/_base.scss +79 -25
  76. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +8 -0
  77. data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +5 -0
  78. data/app/assets/stylesheets/spree/backend/views/_cms_pages.scss +148 -0
  79. data/app/assets/stylesheets/spree/backend/views/_menus.scss +61 -0
  80. data/app/controllers/concerns/spree/admin/order_concern.rb +24 -0
  81. data/app/controllers/concerns/spree/admin/product_concern.rb +11 -0
  82. data/app/controllers/spree/admin/base_controller.rb +63 -3
  83. data/app/controllers/spree/admin/cms_pages_controller.rb +29 -0
  84. data/app/controllers/spree/admin/cms_sections_controller.rb +15 -0
  85. data/app/controllers/spree/admin/customer_returns_controller.rb +4 -5
  86. data/app/controllers/spree/admin/errors_controller.rb +11 -0
  87. data/app/controllers/spree/admin/general_settings_controller.rb +1 -1
  88. data/app/controllers/spree/admin/images_controller.rb +19 -16
  89. data/app/controllers/spree/admin/log_entries_controller.rb +4 -3
  90. data/app/controllers/spree/admin/menu_items_controller.rb +33 -0
  91. data/app/controllers/spree/admin/menus_controller.rb +32 -0
  92. data/app/controllers/spree/admin/option_types_controller.rb +1 -1
  93. data/app/controllers/spree/admin/orders/customer_details_controller.rb +6 -11
  94. data/app/controllers/spree/admin/orders_controller.rb +23 -31
  95. data/app/controllers/spree/admin/payment_methods_controller.rb +17 -4
  96. data/app/controllers/spree/admin/payments_controller.rb +5 -10
  97. data/app/controllers/spree/admin/prices_controller.rb +2 -2
  98. data/app/controllers/spree/admin/products_controller.rb +21 -10
  99. data/app/controllers/spree/admin/promotion_actions_controller.rb +1 -1
  100. data/app/controllers/spree/admin/promotion_rules_controller.rb +1 -1
  101. data/app/controllers/spree/admin/promotions_controller.rb +3 -3
  102. data/app/controllers/spree/admin/prototypes_controller.rb +1 -1
  103. data/app/controllers/spree/admin/reimbursements_controller.rb +1 -1
  104. data/app/controllers/spree/admin/reports_controller.rb +5 -1
  105. data/app/controllers/spree/admin/resource_controller.rb +32 -5
  106. data/app/controllers/spree/admin/return_index_controller.rb +1 -1
  107. data/app/controllers/spree/admin/state_changes_controller.rb +2 -7
  108. data/app/controllers/spree/admin/stock_items_controller.rb +2 -2
  109. data/app/controllers/spree/admin/stock_locations_controller.rb +2 -2
  110. data/app/controllers/spree/admin/stock_movements_controller.rb +1 -1
  111. data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
  112. data/app/controllers/spree/admin/store_credits_controller.rb +13 -8
  113. data/app/controllers/spree/admin/stores_controller.rb +14 -17
  114. data/app/controllers/spree/admin/taxons_controller.rb +9 -5
  115. data/app/controllers/spree/admin/users_controller.rb +9 -7
  116. data/app/controllers/spree/admin/variants_controller.rb +16 -15
  117. data/app/helpers/spree/admin/base_helper.rb +52 -14
  118. data/app/helpers/spree/admin/cms_helper.rb +15 -0
  119. data/app/helpers/spree/admin/menu_helper.rb +30 -0
  120. data/app/helpers/spree/admin/stores_helper.rb +21 -0
  121. data/app/models/spree/backend_configuration.rb +2 -0
  122. data/app/views/spree/admin/adjustments/_adjustment.html.erb +7 -5
  123. data/app/views/spree/admin/cms_pages/_form.html.erb +135 -0
  124. data/app/views/spree/admin/cms_pages/_live_preview_area.html.erb +61 -0
  125. data/app/views/spree/admin/cms_pages/_section_template.html.erb +16 -0
  126. data/app/views/spree/admin/cms_pages/edit.html.erb +21 -0
  127. data/app/views/spree/admin/cms_pages/index.html.erb +84 -0
  128. data/app/views/spree/admin/cms_pages/new.html.erb +8 -0
  129. data/app/views/spree/admin/cms_sections/_form.html.erb +69 -0
  130. data/app/views/spree/admin/cms_sections/edit.html.erb +19 -0
  131. data/app/views/spree/admin/cms_sections/new.html.erb +11 -0
  132. data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +50 -0
  133. data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +61 -0
  134. data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +174 -0
  135. data/app/views/spree/admin/cms_sections/types/_product_carousel.html.erb +5 -0
  136. data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +4 -0
  137. data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +121 -0
  138. data/app/views/spree/admin/countries/index.html.erb +5 -3
  139. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +6 -4
  140. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +9 -7
  141. data/app/views/spree/admin/customer_returns/index.html.erb +4 -2
  142. data/app/views/spree/admin/errors/forbidden.html.erb +0 -0
  143. data/app/views/spree/admin/images/index.html.erb +8 -4
  144. data/app/views/spree/admin/menu_items/_form.html.erb +115 -0
  145. data/app/views/spree/admin/menu_items/edit.html.erb +11 -0
  146. data/app/views/spree/admin/menu_items/new.html.erb +11 -0
  147. data/app/views/spree/admin/menus/_form.html.erb +19 -0
  148. data/app/views/spree/admin/menus/edit.html.erb +57 -0
  149. data/app/views/spree/admin/menus/index.html.erb +90 -0
  150. data/app/views/spree/admin/menus/nested_menu_items/_item_bar.html.erb +30 -0
  151. data/app/views/spree/admin/menus/new.html.erb +22 -0
  152. data/app/views/spree/admin/option_types/_form.html.erb +3 -0
  153. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +5 -1
  154. data/app/views/spree/admin/option_types/index.html.erb +5 -3
  155. data/app/views/spree/admin/orders/_channel_form.html.erb +2 -2
  156. data/app/views/spree/admin/orders/_line_items.html.erb +10 -8
  157. data/app/views/spree/admin/orders/_shipment.html.erb +26 -18
  158. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +11 -9
  159. data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +2 -2
  160. data/app/views/spree/admin/orders/index.html.erb +100 -101
  161. data/app/views/spree/admin/payment_methods/_form.html.erb +6 -4
  162. data/app/views/spree/admin/payment_methods/edit.html.erb +1 -1
  163. data/app/views/spree/admin/payment_methods/index.html.erb +22 -3
  164. data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
  165. data/app/views/spree/admin/payments/_list.html.erb +9 -7
  166. data/app/views/spree/admin/prices/_variant_prices.html.erb +7 -14
  167. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +9 -7
  168. data/app/views/spree/admin/products/_autocomplete.js.erb +10 -6
  169. data/app/views/spree/admin/products/_form.html.erb +35 -5
  170. data/app/views/spree/admin/products/index.html.erb +15 -14
  171. data/app/views/spree/admin/products/new.html.erb +6 -1
  172. data/app/views/spree/admin/products/stock.html.erb +71 -68
  173. data/app/views/spree/admin/promotion_categories/index.html.erb +5 -3
  174. data/app/views/spree/admin/promotions/_form.html.erb +7 -0
  175. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +1 -0
  176. data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +2 -1
  177. data/app/views/spree/admin/promotions/index.html.erb +33 -34
  178. data/app/views/spree/admin/properties/_form.html.erb +6 -0
  179. data/app/views/spree/admin/properties/index.html.erb +19 -3
  180. data/app/views/spree/admin/prototypes/_form.html.erb +1 -1
  181. data/app/views/spree/admin/prototypes/_prototypes.html.erb +8 -6
  182. data/app/views/spree/admin/prototypes/index.html.erb +5 -3
  183. data/app/views/spree/admin/reimbursement_types/index.html.erb +5 -3
  184. data/app/views/spree/admin/reports/index.html.erb +1 -1
  185. data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
  186. data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
  187. data/app/views/spree/admin/return_authorizations/index.html.erb +7 -5
  188. data/app/views/spree/admin/return_index/customer_returns.html.erb +4 -2
  189. data/app/views/spree/admin/return_index/return_authorizations.html.erb +5 -3
  190. data/app/views/spree/admin/roles/index.html.erb +5 -3
  191. data/app/views/spree/admin/shared/_account_nav.html.erb +5 -5
  192. data/app/views/spree/admin/shared/_address_form.html.erb +5 -4
  193. data/app/views/spree/admin/shared/_content_header.html.erb +20 -6
  194. data/app/views/spree/admin/shared/_head.html.erb +2 -1
  195. data/app/views/spree/admin/shared/_header.html.erb +7 -10
  196. data/app/views/spree/admin/shared/_link_fields.html.erb +22 -0
  197. data/app/views/spree/admin/shared/_main_menu.html.erb +19 -4
  198. data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -10
  199. data/app/views/spree/admin/shared/_paths.html.erb +8 -0
  200. data/app/views/spree/admin/shared/_refunds.html.erb +4 -2
  201. data/app/views/spree/admin/shared/_sidebar.html.erb +1 -1
  202. data/app/views/spree/admin/shared/_store_switcher.html.erb +23 -0
  203. data/app/views/spree/admin/shared/_table_filter.html.erb +6 -6
  204. data/app/views/spree/admin/shared/_translations.html.erb +2 -0
  205. data/app/views/spree/admin/shared/cms/_spree_product.html.erb +27 -0
  206. data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +27 -0
  207. data/app/views/spree/admin/shared/linkables/_home_page.html.erb +3 -0
  208. data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +23 -0
  209. data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +20 -0
  210. data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +22 -0
  211. data/app/views/spree/admin/shared/linkables/_url.html.erb +16 -0
  212. data/app/views/spree/admin/shared/named_types/_index.html.erb +7 -5
  213. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +1 -3
  214. data/app/views/spree/admin/shared/sub_menu/_content.html.erb +4 -0
  215. data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +4 -0
  216. data/app/views/spree/admin/shipping_categories/index.html.erb +5 -3
  217. data/app/views/spree/admin/shipping_methods/index.html.erb +5 -3
  218. data/app/views/spree/admin/states/_state_list.html.erb +5 -3
  219. data/app/views/spree/admin/stock_locations/index.html.erb +5 -3
  220. data/app/views/spree/admin/stock_transfers/index.html.erb +5 -4
  221. data/app/views/spree/admin/stock_transfers/new.html.erb +9 -7
  222. data/app/views/spree/admin/store_credit_categories/index.html.erb +5 -3
  223. data/app/views/spree/admin/store_credits/index.html.erb +7 -5
  224. data/app/views/spree/admin/stores/_form.html.erb +12 -2
  225. data/app/views/spree/admin/stores/index.html.erb +12 -10
  226. data/app/views/spree/admin/tax_categories/index.html.erb +5 -3
  227. data/app/views/spree/admin/tax_rates/index.html.erb +5 -3
  228. data/app/views/spree/admin/taxonomies/_list.html.erb +5 -3
  229. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  230. data/app/views/spree/admin/users/_addresses_form.html.erb +2 -4
  231. data/app/views/spree/admin/users/_lifetime_stats.html.erb +16 -4
  232. data/app/views/spree/admin/users/index.html.erb +5 -3
  233. data/app/views/spree/admin/users/items.html.erb +1 -1
  234. data/app/views/spree/admin/variants/_autocomplete.js.erb +6 -2
  235. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +18 -12
  236. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +12 -8
  237. data/app/views/spree/admin/variants/_split.js.erb +9 -7
  238. data/app/views/spree/admin/variants/index.html.erb +8 -5
  239. data/app/views/spree/admin/zones/index.html.erb +5 -3
  240. data/app/views/spree/layouts/admin.html.erb +16 -16
  241. data/config/initializers/assets.rb +5 -1
  242. data/config/routes.rb +14 -2
  243. data/lib/generators/spree/backend/install/install_generator.rb +22 -0
  244. data/lib/generators/spree/backend/install/templates/vendor/assets/javascripts/spree/backend/all.js +8 -0
  245. data/lib/generators/spree/backend/install/templates/vendor/assets/stylesheets/spree/backend/all.css +9 -0
  246. data/lib/spree/backend/engine.rb +4 -11
  247. data/lib/spree/backend.rb +7 -4
  248. data/lib/spree_backend.rb +0 -2
  249. data/spec/fixtures/files/favicon.ico +0 -0
  250. data/spec/fixtures/files/icon_512x512.png +0 -0
  251. data/spree_backend.gemspec +10 -5
  252. data/vendor/assets/javascripts/cleave.js +8 -0
  253. data/vendor/assets/javascripts/jsonapi-serializer.min.js +8 -0
  254. data/vendor/assets/javascripts/jsuri.js +458 -0
  255. data/vendor/assets/javascripts/sortable.js +2 -3709
  256. data/vendor/assets/javascripts/sweetalert2.js +2 -0
  257. metadata +193 -21
  258. data/app/assets/javascripts/spree/backend/address_states.js +0 -44
  259. data/app/assets/javascripts/spree/frontend/backend.js +0 -1
  260. data/app/assets/stylesheets/spree/frontend/backend.css +0 -1
  261. data/app/views/spree/admin/orders/_store_form.html.erb +0 -18
@@ -7,7 +7,7 @@ module Spree
7
7
  end
8
8
 
9
9
  def customer_returns
10
- collection(Spree::CustomerReturn)
10
+ collection(current_store.customer_returns)
11
11
  respond_with(@collection)
12
12
  end
13
13
 
@@ -1,18 +1,13 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class StateChangesController < Spree::Admin::BaseController
4
+ include Spree::Admin::OrderConcern
5
+
4
6
  before_action :load_order, only: [:index]
5
7
 
6
8
  def index
7
9
  @state_changes = @order.state_changes.includes(:user).order(created_at: :desc)
8
10
  end
9
-
10
- private
11
-
12
- def load_order
13
- @order = Order.find_by!(number: params[:order_id])
14
- authorize! action, @order
15
- end
16
11
  end
17
12
  end
18
13
  end
@@ -11,7 +11,7 @@ module Spree
11
11
  end
12
12
 
13
13
  def create
14
- variant = Variant.find(params[:variant_id])
14
+ variant = current_store.variants.find(params[:variant_id])
15
15
  stock_location = StockLocation.find(params[:stock_location_id])
16
16
  stock_movement = stock_location.stock_movements.build(stock_movement_params)
17
17
  stock_movement.stock_item = stock_location.set_up_stock_item(variant)
@@ -41,7 +41,7 @@ module Spree
41
41
  end
42
42
 
43
43
  def stock_item
44
- @stock_item ||= StockItem.find(params[:id])
44
+ @stock_item ||= current_store.stock_items.find(params[:id])
45
45
  end
46
46
 
47
47
  def determine_backorderable
@@ -6,10 +6,10 @@ module Spree
6
6
  private
7
7
 
8
8
  def set_country
9
- @stock_location.country = Spree::Country.default
9
+ @stock_location.country = current_store.default_country
10
10
  unless @stock_location.country
11
11
  flash[:error] = Spree.t(:stock_locations_need_a_default_country)
12
- redirect_to admin_stock_locations_path
12
+ redirect_to spree.admin_stock_locations_path
13
13
  end
14
14
  end
15
15
  end
@@ -18,7 +18,7 @@ module Spree
18
18
  @stock_movement = stock_location.stock_movements.build(stock_movement_params)
19
19
  if @stock_movement.save
20
20
  flash[:success] = flash_message_for(@stock_movement, :successfully_created)
21
- redirect_to admin_stock_location_stock_movements_path(stock_location)
21
+ redirect_to spree.admin_stock_location_stock_movements_path(stock_location)
22
22
  else
23
23
  render :new
24
24
  end
@@ -36,7 +36,7 @@ module Spree
36
36
  variants)
37
37
 
38
38
  flash[:success] = Spree.t(:stock_successfully_transferred)
39
- redirect_to admin_stock_transfer_path(stock_transfer)
39
+ redirect_to spree.admin_stock_transfer_path(stock_transfer)
40
40
  end
41
41
  end
42
42
 
@@ -9,20 +9,21 @@ module Spree
9
9
  before_action :ensure_unused_store_credit, only: [:update]
10
10
 
11
11
  def index
12
- @store_credits = @user.store_credits.includes(:credit_type, :category).reverse_order
12
+ @store_credits = @user.store_credits.for_store(current_store).includes(:category).reverse_order
13
13
  end
14
14
 
15
15
  def create
16
16
  @store_credit = @user.store_credits.build(
17
17
  permitted_store_credit_params.merge(
18
18
  created_by: try_spree_current_user,
19
- action_originator: try_spree_current_user
19
+ action_originator: try_spree_current_user,
20
+ store: current_store
20
21
  )
21
22
  )
22
23
 
23
24
  if @store_credit.save
24
25
  flash[:success] = flash_message_for(@store_credit, :successfully_created)
25
- redirect_to admin_user_store_credits_path(@user)
26
+ redirect_to spree.admin_user_store_credits_path(@user)
26
27
  else
27
28
  load_categories
28
29
  flash[:error] = Spree.t('store_credit.errors.unable_to_create')
@@ -36,7 +37,7 @@ module Spree
36
37
 
37
38
  if @store_credit.save
38
39
  flash[:success] = flash_message_for(@store_credit, :successfully_updated)
39
- redirect_to admin_user_store_credits_path(@user)
40
+ redirect_to spree.admin_user_store_credits_path(@user)
40
41
  else
41
42
  load_categories
42
43
  flash[:error] = Spree.t('store_credit.errors.unable_to_update')
@@ -45,13 +46,13 @@ module Spree
45
46
  end
46
47
 
47
48
  def destroy
48
- @store_credit = @user.store_credits.find(params[:id])
49
+ @store_credit = @user.store_credits.for_store(current_store).find(params[:id])
49
50
  ensure_unused_store_credit
50
51
 
51
52
  if @store_credit.destroy
52
53
  flash[:success] = flash_message_for(@store_credit, :successfully_removed)
53
54
  respond_with(@store_credit) do |format|
54
- format.html { redirect_to admin_user_store_credits_path(@user) }
55
+ format.html { redirect_to spree.admin_user_store_credits_path(@user) }
55
56
  format.js { render_js_for_destroy }
56
57
  end
57
58
  else
@@ -72,7 +73,7 @@ module Spree
72
73
 
73
74
  unless @user
74
75
  flash[:error] = Spree.t(:user_not_found)
75
- redirect_to admin_path
76
+ redirect_to spree.admin_path
76
77
  end
77
78
  end
78
79
 
@@ -81,7 +82,11 @@ module Spree
81
82
  end
82
83
 
83
84
  def load_store_credit
84
- @store_credit = Spree::StoreCredit.find_by(id: params[:id]) || Spree::StoreCredit.new
85
+ @store_credit = scope.find_by(id: params[:id]) || scope.new
86
+ end
87
+
88
+ def scope
89
+ current_store.store_credits
85
90
  end
86
91
 
87
92
  def ensure_unused_store_credit
@@ -8,15 +8,13 @@ module Spree
8
8
  before_action :normalize_supported_locales, only: [:create, :update]
9
9
  before_action :set_default_country_id, only: :new
10
10
  before_action :load_all_countries, only: [:new, :edit, :update, :create]
11
- before_action :load_all_zones, only: %i[new edit]
11
+ before_action :load_all_zones, only: [:new, :edit, :update, :create]
12
12
 
13
13
  def index
14
14
  if params[:ids]
15
15
  load_stores_by_ids
16
16
  elsif params[:q]
17
17
  load_stores_by_query
18
- else
19
- @stores = Spree::Store.all
20
18
  end
21
19
 
22
20
  respond_with(@stores) do |format|
@@ -25,25 +23,24 @@ module Spree
25
23
  end
26
24
 
27
25
  def load_stores_by_ids
28
- ids = params[:ids].split(',')
29
- @stores = Spree::Store.where(id: ids)
26
+ @stores = stores_scope.where(id: params[:ids].split(','))
30
27
  end
31
28
 
32
29
  def load_stores_by_query
33
30
  @stores = if defined?(SpreeGlobalize)
34
- Spree::Store.joins(:translations).where("LOWER(#{Store::Translation.table_name}.name) LIKE LOWER(:query)",
31
+ stores_scope.joins(:translations).where("LOWER(#{Store::Translation.table_name}.name) LIKE LOWER(:query)",
35
32
  query: "%#{params[:q]}%")
36
33
  else
37
- Spree::Store.where('LOWER(name) LIKE LOWER(:query)', query: "%#{params[:q]}%")
34
+ stores_scope.where('LOWER(name) LIKE LOWER(:query)', query: "%#{params[:q]}%")
38
35
  end
39
36
  end
40
37
 
41
38
  def create
42
- @store = Spree::Store.new(permitted_store_params)
39
+ @store = stores_scope.new(permitted_store_params)
43
40
 
44
41
  if @store.save
45
42
  flash[:success] = flash_message_for(@store, :successfully_created)
46
- redirect_to admin_stores_path
43
+ redirect_to @store.formatted_url + spree.admin_stores_path
47
44
  else
48
45
  flash[:error] = "#{Spree.t('store_errors.unable_to_create')}: #{@store.errors.full_messages.join(', ')}"
49
46
  render :new
@@ -55,20 +52,20 @@ module Spree
55
52
 
56
53
  if @store.save
57
54
  flash[:success] = flash_message_for(@store, :successfully_updated)
58
- redirect_to admin_stores_path
55
+ redirect_to spree.admin_stores_path
59
56
  else
60
57
  flash[:error] = "#{Spree.t('store_errors.unable_to_update')}: #{@store.errors.full_messages.join(', ')}"
61
- render :edit
58
+ redirect_to spree.edit_admin_store_path(@store)
62
59
  end
63
60
  end
64
61
 
65
62
  def destroy
66
- @store = Spree::Store.find(params[:id])
63
+ @store = stores_scope.find(params[:id])
67
64
 
68
65
  if @store.destroy
69
66
  flash[:success] = flash_message_for(@store, :successfully_removed)
70
67
  respond_with(@store) do |format|
71
- format.html { redirect_to admin_stores_path }
68
+ format.html { redirect_to spree.admin_stores_path }
72
69
  format.js { render_js_for_destroy }
73
70
  end
74
71
  else
@@ -77,8 +74,8 @@ module Spree
77
74
  end
78
75
 
79
76
  def set_default
80
- store = Spree::Store.find(params[:id])
81
- stores = Spree::Store.where.not(id: params[:id])
77
+ store = stores_scope.find(params[:id])
78
+ stores = stores_scope.where.not(id: params[:id])
82
79
 
83
80
  ApplicationRecord.transaction do
84
81
  store.update(default: true)
@@ -91,7 +88,7 @@ module Spree
91
88
  flash[:error] = "#{Spree.t(:store_not_set_as_default, store: store.name)} #{store.errors.full_messages.join(', ')}"
92
89
  end
93
90
 
94
- redirect_to admin_stores_path
91
+ redirect_to spree.admin_stores_path
95
92
  end
96
93
 
97
94
  protected
@@ -103,7 +100,7 @@ module Spree
103
100
  private
104
101
 
105
102
  def load_store
106
- @store = Spree::Store.find_by(id: params[:id]) || Spree::Store.new
103
+ @store = stores_scope.find_by(id: params[:id]) || stores_scope.new
107
104
  end
108
105
 
109
106
  def load_all_countries
@@ -51,7 +51,7 @@ module Spree
51
51
  rename_child_taxons if @update_children
52
52
 
53
53
  respond_with(@taxon) do |format|
54
- format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
54
+ format.html { redirect_to spree.edit_admin_taxonomy_url(@taxonomy) }
55
55
  format.json { render json: @taxon.to_json }
56
56
  end
57
57
  else
@@ -65,7 +65,7 @@ module Spree
65
65
  def remove_icon
66
66
  if @taxon.icon.destroy
67
67
  flash[:success] = Spree.t('notice_messages.icon_removed')
68
- redirect_to edit_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.id)
68
+ redirect_to spree.edit_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.id)
69
69
  else
70
70
  flash[:error] = Spree.t('errors.messages.cannot_remove_icon')
71
71
  render :edit
@@ -90,9 +90,9 @@ module Spree
90
90
 
91
91
  def load_taxonomy
92
92
  @taxonomy = if defined?(SpreeGlobalize)
93
- Taxonomy.includes(:translations, taxons: [:translations]).find(params[:taxonomy_id])
93
+ scope.includes(:translations, taxons: [:translations]).find(params[:taxonomy_id])
94
94
  else
95
- Taxonomy.find(params[:taxonomy_id])
95
+ scope.find(params[:taxonomy_id])
96
96
  end
97
97
  end
98
98
 
@@ -102,7 +102,7 @@ module Spree
102
102
  end
103
103
 
104
104
  def set_parent(parent_id)
105
- @taxon.parent = Taxon.find(parent_id.to_i) if parent_id
105
+ @taxon.parent = current_store.taxons.find(parent_id.to_i) if parent_id
106
106
  end
107
107
 
108
108
  def set_permalink_params
@@ -127,6 +127,10 @@ module Spree
127
127
  taxon.set_permalink
128
128
  taxon.save!
129
129
  end
130
+
131
+ def scope
132
+ current_store.taxonomies
133
+ end
130
134
  end
131
135
  end
132
136
  end
@@ -6,14 +6,14 @@ module Spree
6
6
  after_action :sign_in_if_change_own_password, only: :update
7
7
 
8
8
  def show
9
- redirect_to edit_admin_user_path(@user)
9
+ redirect_to spree.edit_admin_user_path(@user)
10
10
  end
11
11
 
12
12
  def create
13
13
  @user = Spree.user_class.new(user_params)
14
14
  if @user.save
15
15
  flash[:success] = flash_message_for(@user, :successfully_created)
16
- redirect_to edit_admin_user_path(@user)
16
+ redirect_to spree.edit_admin_user_path(@user)
17
17
  else
18
18
  render :new
19
19
  end
@@ -27,7 +27,7 @@ module Spree
27
27
 
28
28
  if @user.update(user_params)
29
29
  flash[:success] = Spree.t(:account_updated)
30
- redirect_to edit_admin_user_path(@user)
30
+ redirect_to spree.edit_admin_user_path(@user)
31
31
  else
32
32
  render :edit
33
33
  end
@@ -35,6 +35,8 @@ module Spree
35
35
 
36
36
  def addresses
37
37
  if request.put?
38
+ params[:user][:bill_address_attributes][:user_id] = @user.id if params[:user][:bill_address_attributes].present?
39
+ params[:user][:ship_address_attributes][:user_id] = @user.id if params[:user][:ship_address_attributes].present?
38
40
  if @user.update(user_params)
39
41
  flash.now[:success] = Spree.t(:account_updated)
40
42
  end
@@ -45,13 +47,13 @@ module Spree
45
47
 
46
48
  def orders
47
49
  params[:q] ||= {}
48
- @search = Spree::Order.reverse_chronological.ransack(params[:q].merge(user_id_eq: @user.id))
50
+ @search = current_store.orders.reverse_chronological.ransack(params[:q].merge(user_id_eq: @user.id))
49
51
  @orders = @search.result.page(params[:page])
50
52
  end
51
53
 
52
54
  def items
53
55
  params[:q] ||= {}
54
- @search = Spree::Order.includes(
56
+ @search = current_store.orders.includes(
55
57
  line_items: {
56
58
  variant: [:product, { option_values: :option_type }]
57
59
  }
@@ -63,14 +65,14 @@ module Spree
63
65
  if @user.generate_spree_api_key!
64
66
  flash[:success] = Spree.t('api.key_generated')
65
67
  end
66
- redirect_to edit_admin_user_path(@user)
68
+ redirect_to spree.edit_admin_user_path(@user)
67
69
  end
68
70
 
69
71
  def clear_api_key
70
72
  if @user.clear_spree_api_key!
71
73
  flash[:success] = Spree.t('api.key_cleared')
72
74
  end
73
- redirect_to edit_admin_user_path(@user)
75
+ redirect_to spree.edit_admin_user_path(@user)
74
76
  end
75
77
 
76
78
  def model_class
@@ -1,6 +1,8 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class VariantsController < ResourceController
4
+ include Spree::Admin::ProductConcern
5
+
4
6
  belongs_to 'spree/product', find_by: :slug
5
7
  new_action.before :new_before
6
8
  before_action :redirect_on_empty_option_values, only: [:new]
@@ -9,7 +11,7 @@ module Spree
9
11
  # override the destroy method to set deleted_at value
10
12
  # instead of actually deleting the product.
11
13
  def destroy
12
- @variant = Variant.find(params[:id])
14
+ @variant = parent.variants.find(params[:id])
13
15
  if @variant.destroy
14
16
  flash[:success] = Spree.t('notice_messages.variant_deleted')
15
17
  else
@@ -17,7 +19,7 @@ module Spree
17
19
  end
18
20
 
19
21
  respond_with(@variant) do |format|
20
- format.html { redirect_to admin_product_variants_url(params[:product_id]) }
22
+ format.html { redirect_to spree.admin_product_variants_url(params[:product_id]) }
21
23
  format.js { render_js_for_destroy }
22
24
  end
23
25
  end
@@ -34,20 +36,19 @@ module Spree
34
36
  @object.default_price = master.default_price.clone if master.default_price.present?
35
37
  end
36
38
 
37
- def parent
38
- @product = Product.with_deleted.friendly.find(params[:product_id])
39
- end
40
-
41
39
  def collection
42
- @deleted = params.key?(:deleted) && params[:deleted] == 'on' ? 'checked' : ''
40
+ return @collection if @collection.present?
41
+
42
+ params[:q] ||= {}
43
+ @deleted = params.dig(:q, :deleted_at_null) || '0'
43
44
 
44
- @collection ||=
45
- if @deleted.blank?
46
- super.includes(:default_price, option_values: :option_type)
47
- else
48
- Variant.only_deleted.where(product_id: parent.id)
49
- end
50
- @collection
45
+ @collection = super
46
+ @collection = @collection.deleted if @deleted == '1'
47
+ # @search needs to be defined as this is passed to search_link
48
+ @search = @collection.ransack(params[:q])
49
+ @collection = @search.result.
50
+ page(params[:page]).
51
+ per(params[:per_page] || Spree::Backend::Config[:variants_per_page])
51
52
  end
52
53
 
53
54
  private
@@ -57,7 +58,7 @@ module Spree
57
58
  end
58
59
 
59
60
  def redirect_on_empty_option_values
60
- redirect_to admin_product_variants_url(params[:product_id]) if @product.empty_option_values?
61
+ redirect_to spree.admin_product_variants_url(params[:product_id]) if @product.empty_option_values?
61
62
  end
62
63
  end
63
64
  end
@@ -15,13 +15,9 @@ module Spree
15
15
 
16
16
  def flash_alert(flash)
17
17
  if flash.present?
18
- message = flash[:error] || flash[:notice] || flash[:success]
19
- flash_class = 'danger' if flash[:error]
20
- flash_class = 'info' if flash[:notice]
21
- flash_class = 'success' if flash[:success]
22
- flash_div = content_tag(:div, message, class: "alert alert-#{flash_class} mx-2")
23
- content_tag(:div, flash_div,
24
- class: 'd-flex justify-content-center position-fixed flash-alert ')
18
+ type = flash.first[0]
19
+ message = flash.first[1]
20
+ content_tag(:span, message, class: 'd-none', data: { alert_type: type })
25
21
  end
26
22
  end
27
23
 
@@ -35,6 +31,46 @@ module Spree
35
31
  )
36
32
  end
37
33
 
34
+ # Returns Humanized Dropdown Values From a Constant In the Model
35
+ # Pass the model name as a string and then a hash containing the constant name
36
+ # and the option to paramatize the return value.
37
+ #
38
+ # Example:
39
+ #
40
+ # spree_humanize_dropdown_values('Spree::CmsPage', { const: 'TYPES' })
41
+ # spree_humanize_dropdown_values('Spree::Menu', { const: 'MENU_TYPES', paramterize_values: true })
42
+ #
43
+ def spree_humanize_dropdown_values(model_name, options = {})
44
+ formatted_option_values = []
45
+
46
+ const = options[:const] || nil
47
+ paramterize_values = options[:paramterize_values] || false
48
+
49
+ return unless const.present?
50
+
51
+ model_name.constantize.const_get(const).map do |type|
52
+ return_value = if paramterize_values
53
+ type.parameterize(separator: '_')
54
+ else
55
+ type
56
+ end
57
+
58
+ formatted_option_values << [spree_humanize_type(type), return_value]
59
+ end
60
+
61
+ formatted_option_values
62
+ end
63
+
64
+ def spree_humanize_type(obj)
65
+ last_word = obj.split('::', 10).last
66
+
67
+ if last_word.starts_with?('Cms')
68
+ last_word.slice(3, 100).gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
69
+ else
70
+ last_word.gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
71
+ end
72
+ end
73
+
38
74
  def error_message_on(object, method, _options = {})
39
75
  object = convert_to_model(object)
40
76
  obj = object.respond_to?(:errors) ? object : instance_variable_get("@#{object}")
@@ -63,6 +99,12 @@ module Spree
63
99
  end
64
100
 
65
101
  def preference_field_tag(name, value, options)
102
+ if options[:key] == :currency
103
+ return select_tag(name,
104
+ options_from_collection_for_select(supported_currencies_for_all_stores, :iso_code, :iso_code, value),
105
+ class: 'select2')
106
+ end
107
+
66
108
  case options[:type]
67
109
  when :integer
68
110
  text_field_tag(name, value, preference_field_options(options))
@@ -147,7 +189,7 @@ module Spree
147
189
  (form.select "preferred_#{key}", currency_options(object.preferences[key]), {}, { class: 'form-control select2' }),
148
190
  class: 'form-group', id: [object.class.to_s.parameterize, 'preference', key].join('-'))
149
191
  else
150
- if object.preference_type(key) == :boolean
192
+ if object.preference_type(key).to_sym == :boolean
151
193
  content_tag(:div, preference_field_for(form, "preferred_#{key}", type: object.preference_type(key)) +
152
194
  form.label("preferred_#{key}", Spree.t(key), class: 'form-check-label'),
153
195
  class: 'form-group form-check', id: [object.class.to_s.parameterize, 'preference', key].join('-'))
@@ -195,21 +237,17 @@ module Spree
195
237
  end
196
238
 
197
239
  def product_preview_link(product)
198
- return unless frontend_available?
199
-
200
240
  button_link_to(
201
241
  Spree.t(:preview_product),
202
- spree.product_url(product),
242
+ spree_storefront_resource_url(product),
203
243
  class: 'btn-outline-secondary', icon: 'view.svg', id: 'admin_preview_product', target: :blank
204
244
  )
205
245
  end
206
246
 
207
247
  def taxon_preview_link(taxon)
208
- return unless frontend_available?
209
-
210
248
  button_link_to(
211
249
  Spree.t(:preview_taxon),
212
- seo_url(taxon),
250
+ spree_storefront_resource_url(taxon),
213
251
  class: 'btn-outline-secondary', icon: 'view.svg', id: 'admin_preview_taxon', target: :blank
214
252
  )
215
253
  end