solidus_backend 2.7.4 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -8
  3. data/app/assets/images/favicon.ico +0 -0
  4. data/app/assets/javascripts/spree/backend.js +0 -2
  5. data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
  6. data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
  7. data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
  8. data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
  9. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
  10. data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
  11. data/app/assets/javascripts/spree/backend/shipments.js +7 -1
  12. data/app/assets/javascripts/spree/backend/stock_management.js +18 -0
  13. data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
  14. data/app/assets/javascripts/spree/backend/taxons.js +1 -1
  15. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
  16. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
  17. data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
  18. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
  19. data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
  20. data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
  21. data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
  22. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +46 -10
  23. data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
  24. data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
  25. data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
  26. data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
  27. data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
  28. data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
  29. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
  30. data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
  31. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
  32. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
  33. data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
  34. data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
  35. data/app/assets/stylesheets/spree/backend/globals/_functions.scss +2 -0
  36. data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
  37. data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
  38. data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
  39. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
  40. data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
  41. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +25 -6
  42. data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
  43. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
  44. data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
  45. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
  46. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
  47. data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
  48. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
  49. data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
  50. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
  51. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
  52. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
  53. data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
  54. data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
  55. data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
  56. data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
  57. data/app/controllers/spree/admin/locale_controller.rb +1 -1
  58. data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
  59. data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
  60. data/app/controllers/spree/admin/orders_controller.rb +1 -12
  61. data/app/controllers/spree/admin/products_controller.rb +10 -6
  62. data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
  63. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  64. data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
  65. data/app/controllers/spree/admin/resource_controller.rb +1 -0
  66. data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
  67. data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
  68. data/app/controllers/spree/admin/users_controller.rb +4 -2
  69. data/app/helpers/spree/admin/base_helper.rb +9 -3
  70. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  71. data/app/helpers/spree/admin/promotions_helper.rb +15 -0
  72. data/app/models/spree/backend_configuration.rb +38 -21
  73. data/app/views/spree/admin/cancellations/index.html.erb +3 -1
  74. data/app/views/spree/admin/images/_image_row.html.erb +1 -1
  75. data/app/views/spree/admin/images/edit.html.erb +3 -3
  76. data/app/views/spree/admin/images/index.html.erb +3 -3
  77. data/app/views/spree/admin/log_entries/index.html.erb +1 -19
  78. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  79. data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
  80. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
  81. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
  82. data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
  83. data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
  84. data/app/views/spree/admin/orders/index.html.erb +1 -1
  85. data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
  86. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  87. data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
  88. data/app/views/spree/admin/payments/show.html.erb +13 -6
  89. data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  90. data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  91. data/app/views/spree/admin/prices/_form.html.erb +1 -1
  92. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  93. data/app/views/spree/admin/products/_form.html.erb +23 -12
  94. data/app/views/spree/admin/products/edit.html.erb +5 -0
  95. data/app/views/spree/admin/products/index.html.erb +3 -1
  96. data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
  97. data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
  98. data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
  99. data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
  100. data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
  101. data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
  102. data/app/views/spree/admin/promotions/_form.html.erb +6 -5
  103. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  104. data/app/views/spree/admin/promotions/edit.html.erb +3 -1
  105. data/app/views/spree/admin/promotions/index.html.erb +4 -4
  106. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  107. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  108. data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
  109. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
  110. data/app/views/spree/admin/shared/_head.html.erb +1 -3
  111. data/app/views/spree/admin/shared/_image.html.erb +2 -2
  112. data/app/views/spree/admin/shared/_modal.html.erb +1 -1
  113. data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
  114. data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
  115. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
  116. data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
  117. data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
  118. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
  119. data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
  120. data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
  121. data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
  122. data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
  123. data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
  124. data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
  125. data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
  126. data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
  127. data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
  128. data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -2
  129. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  130. data/app/views/spree/admin/store_credits/show.html.erb +3 -3
  131. data/app/views/spree/admin/stores/_form.html.erb +1 -0
  132. data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
  133. data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
  134. data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
  135. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  136. data/app/views/spree/admin/taxons/edit.html.erb +2 -2
  137. data/app/views/spree/admin/users/edit.html.erb +2 -2
  138. data/app/views/spree/admin/users/index.html.erb +2 -2
  139. data/app/views/spree/admin/users/items.html.erb +3 -1
  140. data/app/views/spree/admin/users/orders.html.erb +1 -1
  141. data/app/views/spree/admin/variants/_form.html.erb +1 -1
  142. data/app/views/spree/admin/variants/index.html.erb +1 -1
  143. data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
  144. data/config/routes.rb +2 -8
  145. data/lib/spree/backend.rb +1 -1
  146. data/solidus_backend.gemspec +3 -4
  147. data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
  148. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
  149. data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
  150. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
  151. data/spec/controllers/spree/admin/orders_controller_spec.rb +25 -13
  152. data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
  153. data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
  154. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
  155. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
  156. data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
  157. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
  158. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
  159. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
  160. data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
  161. data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
  162. data/spec/features/admin/homepage_spec.rb +1 -6
  163. data/spec/features/admin/locale_spec.rb +1 -2
  164. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  165. data/spec/features/admin/orders/customer_details_spec.rb +5 -7
  166. data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
  167. data/spec/features/admin/orders/listing_spec.rb +2 -7
  168. data/spec/features/admin/orders/log_entries_spec.rb +2 -2
  169. data/spec/features/admin/orders/new_order_spec.rb +117 -0
  170. data/spec/features/admin/orders/new_refund_spec.rb +35 -0
  171. data/spec/features/admin/orders/order_details_spec.rb +10 -5
  172. data/spec/features/admin/orders/payments_spec.rb +82 -41
  173. data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
  174. data/spec/features/admin/orders/shipments_spec.rb +28 -0
  175. data/spec/features/admin/products/edit/products_spec.rb +25 -0
  176. data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
  177. data/spec/features/admin/products/pricing_spec.rb +24 -6
  178. data/spec/features/admin/products/products_spec.rb +5 -5
  179. data/spec/features/admin/products/stock_management_spec.rb +27 -13
  180. data/spec/features/admin/products/variant_spec.rb +1 -1
  181. data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
  182. data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
  183. data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
  184. data/spec/features/admin/promotions/promotion_spec.rb +52 -0
  185. data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
  186. data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
  187. data/spec/features/admin/reimbursements_spec.rb +1 -1
  188. data/spec/features/admin/store_credits_spec.rb +51 -2
  189. data/spec/features/admin/taxons_spec.rb +35 -0
  190. data/spec/features/admin/users_spec.rb +44 -11
  191. data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
  192. data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
  193. data/spec/javascripts/spec_helper.js +2 -0
  194. data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
  195. data/spec/models/spree/backend_configuration_spec.rb +22 -0
  196. data/spec/spec_helper.rb +2 -2
  197. data/spec/support/appear_before_matcher.rb +1 -1
  198. data/spec/support/feature/order_feature_helper.rb +1 -1
  199. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
  200. data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
  201. data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
  202. data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
  203. data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
  204. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
  205. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
  206. metadata +38 -36
  207. data/.eslintrc +0 -21
  208. data/app/controllers/spree/admin/reports_controller.rb +0 -82
  209. data/app/views/spree/admin/reports/index.html.erb +0 -19
  210. data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
  211. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
  212. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
  213. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
  214. data/spec/features/admin/reports_spec.rb +0 -63
@@ -8,6 +8,7 @@ module Spree
8
8
  before_action :load_data, except: [:index]
9
9
  update.before :update_before
10
10
  helper_method :clone_object_url
11
+ before_action :split_params, only: [:create, :update]
11
12
 
12
13
  def show
13
14
  redirect_to action: :edit
@@ -19,12 +20,6 @@ module Spree
19
20
  end
20
21
 
21
22
  def update
22
- if params[:product][:taxon_ids].present?
23
- params[:product][:taxon_ids] = params[:product][:taxon_ids].split(',')
24
- end
25
- if params[:product][:option_type_ids].present?
26
- params[:product][:option_type_ids] = params[:product][:option_type_ids].split(',')
27
- end
28
23
  if updating_variant_property_rules?
29
24
  params[:product][:variant_property_rules_attributes].each do |_index, param_attrs|
30
25
  param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(',')
@@ -73,6 +68,15 @@ module Spree
73
68
 
74
69
  private
75
70
 
71
+ def split_params
72
+ if params[:product][:taxon_ids].present?
73
+ params[:product][:taxon_ids] = params[:product][:taxon_ids].split(',')
74
+ end
75
+ if params[:product][:option_type_ids].present?
76
+ params[:product][:option_type_ids] = params[:product][:option_type_ids].split(',')
77
+ end
78
+ end
79
+
76
80
  def find_resource
77
81
  Spree::Product.with_deleted.friendly.find(params[:id])
78
82
  end
@@ -7,7 +7,7 @@ module Spree
7
7
  class PromotionCodesController < Spree::Admin::ResourceController
8
8
  def index
9
9
  @promotion = Spree::Promotion.accessible_by(current_ability, :read).find(params[:promotion_id])
10
- @promotion_codes = @promotion.promotion_codes
10
+ @promotion_codes = @promotion.promotion_codes.order(:value)
11
11
 
12
12
  respond_to do |format|
13
13
  format.html do
@@ -20,6 +20,24 @@ module Spree
20
20
  end
21
21
  end
22
22
  end
23
+
24
+ def new
25
+ @promotion = Spree::Promotion.accessible_by(current_ability, :read).find(params[:promotion_id])
26
+ @promotion_code = @promotion.promotion_codes.build
27
+ end
28
+
29
+ def create
30
+ @promotion = Spree::Promotion.accessible_by(current_ability, :read).find(params[:promotion_id])
31
+ @promotion_code = @promotion.promotion_codes.build(value: params[:promotion_code][:value])
32
+
33
+ if @promotion_code.save
34
+ flash[:success] = flash_message_for(@promotion_code, :successfully_created)
35
+ redirect_to admin_promotion_promotion_codes_url(@promotion)
36
+ else
37
+ flash.now[:error] = @promotion_code.errors.full_messages.to_sentence
38
+ render_after_create_error
39
+ end
40
+ end
23
41
  end
24
42
  end
25
43
  end
@@ -24,7 +24,7 @@ module Spree
24
24
  flash[:success] = t('spree.promotion_successfully_created')
25
25
  redirect_to location_after_save
26
26
  else
27
- flash[:error] = @promotion.errors.full_messages.join(", ")
27
+ flash[:error] = @promotion.errors.full_messages.to_sentence
28
28
  render action: 'new'
29
29
  end
30
30
  end
@@ -9,16 +9,21 @@ module Spree
9
9
 
10
10
  before_action :load_stock_locations, only: :edit
11
11
  before_action :load_simulated_refunds, only: :edit
12
+ create.after :recalculate_order
12
13
 
13
14
  rescue_from Spree::Core::GatewayError, with: :spree_core_gateway_error
14
15
 
15
16
  def perform
16
- @reimbursement.perform!
17
+ @reimbursement.perform!(created_by: try_spree_current_user)
17
18
  redirect_to location_after_save
18
19
  end
19
20
 
20
21
  private
21
22
 
23
+ def recalculate_order
24
+ @reimbursement.order.recalculate
25
+ end
26
+
22
27
  def build_resource
23
28
  if params[:build_from_customer_return_id].present?
24
29
  customer_return = Spree::CustomerReturn.find(params[:build_from_customer_return_id])
@@ -57,7 +62,7 @@ module Spree
57
62
  end
58
63
 
59
64
  def load_simulated_refunds
60
- @reimbursement_objects = @reimbursement.simulate
65
+ @reimbursement_objects = @reimbursement.simulate(created_by: try_spree_current_user)
61
66
  end
62
67
 
63
68
  def spree_core_gateway_error(error)
@@ -108,6 +108,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
108
108
  invoke_callbacks(:destroy, :fails)
109
109
  respond_with(@object) do |format|
110
110
  format.html { redirect_to location_after_destroy }
111
+ format.js { render status: :unprocessable_entity, plain: @object.errors.full_messages.join(', ') }
111
112
  end
112
113
  end
113
114
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Admin
5
+ class StoreCreditReasonsController < ResourceController
6
+ end
7
+ end
8
+ end
@@ -5,8 +5,8 @@ module Spree
5
5
  class StoreCreditsController < ResourceController
6
6
  belongs_to 'spree/user', model_class: Spree.user_class
7
7
  before_action :load_categories, only: [:new]
8
- before_action :load_update_reasons, only: [:edit_amount, :edit_validity]
9
- before_action :ensure_update_reason, only: [:update_amount, :invalidate]
8
+ before_action :load_reasons, only: [:edit_amount, :edit_validity]
9
+ before_action :ensure_store_credit_reason, only: [:update_amount, :invalidate]
10
10
 
11
11
  helper Spree::Admin::StoreCreditEventsHelper
12
12
 
@@ -50,7 +50,7 @@ module Spree
50
50
  def update_amount
51
51
  @store_credit = @user.store_credits.find(params[:id])
52
52
  amount = params.require(:store_credit).require(:amount)
53
- if @store_credit.update_amount(amount, @update_reason, try_spree_current_user)
53
+ if @store_credit.update_amount(amount, @store_credit_reason, try_spree_current_user)
54
54
  flash[:success] = flash_message_for(@store_credit, :successfully_updated)
55
55
  redirect_to admin_user_store_credit_path(@user, @store_credit)
56
56
  else
@@ -60,7 +60,7 @@ module Spree
60
60
 
61
61
  def invalidate
62
62
  @store_credit = @user.store_credits.find(params[:id])
63
- if @store_credit.invalidate(@update_reason, try_spree_current_user)
63
+ if @store_credit.invalidate(@store_credit_reason, try_spree_current_user)
64
64
  redirect_to admin_user_store_credit_path(@user, @store_credit)
65
65
  else
66
66
  render_edit_page
@@ -78,18 +78,18 @@ module Spree
78
78
  @collection = super.reverse_order
79
79
  end
80
80
 
81
- def load_update_reasons
82
- @update_reasons = Spree::StoreCreditUpdateReason.all.order(:name)
81
+ def load_reasons
82
+ @store_credit_reasons = Spree::StoreCreditReason.active.order(:name)
83
83
  end
84
84
 
85
85
  def load_categories
86
86
  @credit_categories = Spree::StoreCreditCategory.all.order(:name)
87
87
  end
88
88
 
89
- def ensure_update_reason
90
- @update_reason = Spree::StoreCreditUpdateReason.find_by(id: params[:update_reason_id])
91
- unless @update_reason
92
- @store_credit.errors.add(:base, t('spree.admin.store_credits.errors.update_reason_required'))
89
+ def ensure_store_credit_reason
90
+ @store_credit_reason = Spree::StoreCreditReason.find_by(id: params[:store_credit_reason_id])
91
+ unless @store_credit_reason
92
+ @store_credit.errors.add(:base, t('spree.admin.store_credits.errors.store_credit_reason_required'))
93
93
  render_edit_page
94
94
  end
95
95
  end
@@ -103,7 +103,7 @@ module Spree
103
103
  translation_key = 'invalidate'
104
104
  end
105
105
 
106
- load_update_reasons
106
+ load_reasons
107
107
  flash[:error] = "#{t("spree.admin.store_credits.unable_to_#{translation_key}")}: #{@store_credit.errors.full_messages.join(', ')}"
108
108
  render(template) && return
109
109
  end
@@ -71,24 +71,26 @@ module Spree
71
71
 
72
72
  def items
73
73
  params[:q] ||= {}
74
+
74
75
  @search = Spree::Order.includes(
75
76
  line_items: {
76
77
  variant: [:product, { option_values: :option_type }]
77
78
  }
78
79
  ).ransack(params[:q].merge(user_id_eq: @user.id))
80
+
79
81
  @orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
80
82
  end
81
83
 
82
84
  def generate_api_key
83
85
  if @user.generate_spree_api_key!
84
- flash[:success] = t('spree.api.key_generated')
86
+ flash[:success] = t('spree.admin.api.key_generated')
85
87
  end
86
88
  redirect_to edit_admin_user_path(@user)
87
89
  end
88
90
 
89
91
  def clear_api_key
90
92
  if @user.clear_spree_api_key!
91
- flash[:success] = t('spree.api.key_cleared')
93
+ flash[:success] = t('spree.admin.api.key_cleared')
92
94
  end
93
95
  redirect_to edit_admin_user_path(@user)
94
96
  end
@@ -30,10 +30,16 @@ module Spree
30
30
  end
31
31
  end
32
32
 
33
- def datepicker_field_value(date)
34
- unless date.blank?
35
- l(date, format: t('spree.date_picker.format', default: '%Y/%m/%d'))
33
+ def datepicker_field_value(date, with_time: false)
34
+ return if date.blank?
35
+
36
+ format = if with_time
37
+ t('spree.date_picker.format_with_time', default: '%Y/%m/%d %H:%M')
38
+ else
39
+ t('spree.date_picker.format', default: '%Y/%m/%d')
36
40
  end
41
+
42
+ l(date, format: format)
37
43
  end
38
44
 
39
45
  # @deprecated Render `spree/admin/shared/preference_fields/\#{preference_type}' instead
@@ -39,7 +39,7 @@ module Spree
39
39
  end
40
40
  end
41
41
 
42
- # Make an admin tab that coveres one or more resources supplied by symbols
42
+ # Make an admin tab that covers one or more resources supplied by symbols
43
43
  # Option hash may follow. Valid options are
44
44
  # * :label to override link text, otherwise based on the first resource name (translated)
45
45
  # * :route to override automatically determining the default route
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Admin
5
+ module PromotionsHelper
6
+ def admin_promotion_status(promotion)
7
+ return :active if promotion.active?
8
+ return :not_started if promotion.not_started?
9
+ return :expired if promotion.expired?
10
+
11
+ :inactive
12
+ end
13
+ end
14
+ end
15
+ end
@@ -10,19 +10,21 @@ module Spree
10
10
  PRODUCT_TABS ||= [:products, :option_types, :properties,
11
11
  :variants, :product_properties, :taxonomies,
12
12
  :taxons]
13
- REPORT_TABS ||= [:reports]
14
13
  CONFIGURATION_TABS ||= [:stores, :tax_categories,
15
14
  :tax_rates, :zones,
16
15
  :payment_methods, :shipping_methods,
17
16
  :shipping_categories, :stock_locations,
18
- :refund_reasons, :reimbursement_types, :return_authorization_reasons]
17
+ :refund_reasons, :reimbursement_types,
18
+ :return_reasons, :adjustment_reasons]
19
19
  PROMOTION_TABS ||= [:promotions, :promotion_categories]
20
20
  STOCK_TABS ||= [:stock_items]
21
21
  USER_TABS ||= [:users, :store_credits]
22
22
 
23
23
  # An item which should be drawn in the admin menu
24
24
  class MenuItem
25
- attr_reader :icon, :label, :partial, :condition, :sections, :url
25
+ attr_reader :icon, :label, :partial, :condition, :sections, :url, :match_path
26
+
27
+ attr_accessor :position
26
28
 
27
29
  # @param sections [Array<Symbol>] The sections which are contained within
28
30
  # this admin menu section.
@@ -35,13 +37,19 @@ module Spree
35
37
  # @param partial [String] A partial to draw within this menu item for use
36
38
  # in declaring a submenu
37
39
  # @param url [String] A url where this link should send the user to
40
+ # @param position [Integer] The position in which the menu item should render
41
+ # nil will cause the item to render last
42
+ # @param match_path [String, Regexp] (nil) If the {url} to determine the active tab is ambigous
43
+ # you can pass a String or Regexp to identify this menu item
38
44
  def initialize(
39
45
  sections,
40
46
  icon,
41
47
  condition: nil,
42
48
  label: nil,
43
49
  partial: nil,
44
- url: nil
50
+ url: nil,
51
+ position: nil,
52
+ match_path: nil
45
53
  )
46
54
 
47
55
  @condition = condition || -> { true }
@@ -50,6 +58,8 @@ module Spree
50
58
  @label = label || sections.first
51
59
  @partial = partial
52
60
  @url = url
61
+ @position = position
62
+ @match_path = match_path
53
63
  end
54
64
  end
55
65
 
@@ -65,6 +75,11 @@ module Spree
65
75
  #
66
76
  # @!attribute menu_items
67
77
  # @return [Array<Spree::BackendConfiguration::MenuItem>]
78
+ #
79
+ # Positioning can be determined by setting the position attribute to
80
+ # an Integer or nil. Menu Items will be rendered with smaller lower values
81
+ # first and higher values last. A position value of nil will cause the menu
82
+ # item to be rendered at the end of the list.
68
83
  attr_writer :menu_items
69
84
 
70
85
  # Return the menu items which should be drawn in the menu
@@ -77,45 +92,47 @@ module Spree
77
92
  ORDER_TABS,
78
93
  'shopping-cart',
79
94
  condition: -> { can?(:admin, Spree::Order) },
95
+ position: 0
80
96
  ),
81
97
  MenuItem.new(
82
98
  PRODUCT_TABS,
83
99
  'th-large',
84
100
  condition: -> { can?(:admin, Spree::Product) },
85
- partial: 'spree/admin/shared/product_sub_menu'
86
- ),
87
- MenuItem.new(
88
- REPORT_TABS,
89
- 'file',
90
- condition: -> { can?(:admin, :reports) },
91
- ),
92
- MenuItem.new(
93
- CONFIGURATION_TABS,
94
- 'wrench',
95
- condition: -> { can?(:admin, Spree::Store) },
96
- label: :settings,
97
- partial: 'spree/admin/shared/settings_sub_menu',
98
- url: :admin_stores_path
101
+ partial: 'spree/admin/shared/product_sub_menu',
102
+ position: 1
99
103
  ),
100
104
  MenuItem.new(
101
105
  PROMOTION_TABS,
102
106
  'bullhorn',
103
107
  partial: 'spree/admin/shared/promotion_sub_menu',
104
108
  condition: -> { can?(:admin, Spree::Promotion) },
105
- url: :admin_promotions_path
109
+ url: :admin_promotions_path,
110
+ position: 2
106
111
  ),
107
112
  MenuItem.new(
108
113
  STOCK_TABS,
109
114
  'cubes',
110
115
  condition: -> { can?(:admin, Spree::StockItem) },
111
116
  label: :stock,
112
- url: :admin_stock_items_path
117
+ url: :admin_stock_items_path,
118
+ match_path: '/stock_items',
119
+ position: 3
113
120
  ),
114
121
  MenuItem.new(
115
122
  USER_TABS,
116
123
  'user',
117
124
  condition: -> { Spree.user_class && can?(:admin, Spree.user_class) },
118
- url: :admin_users_path
125
+ url: :admin_users_path,
126
+ position: 4
127
+ ),
128
+ MenuItem.new(
129
+ CONFIGURATION_TABS,
130
+ 'wrench',
131
+ condition: -> { can?(:admin, Spree::Store) },
132
+ label: :settings,
133
+ partial: 'spree/admin/shared/settings_sub_menu',
134
+ url: :admin_stores_path,
135
+ position: 5
119
136
  )
120
137
  ]
121
138
  end
@@ -25,7 +25,9 @@
25
25
  <% @inventory_units.each do |inventory_unit| %>
26
26
  <tr class="inventory-unit">
27
27
  <td class="inventory-unit-image">
28
- <%= render 'spree/admin/shared/image', image: inventory_unit.variant.display_image, size: :mini %>
28
+ <%= render 'spree/admin/shared/image',
29
+ image: (inventory_unit.variant.gallery.images.first || inventory_unit.variant.product.gallery.images.first),
30
+ size: :mini %>
29
31
  </td>
30
32
  <td class="inventory-unit-name">
31
33
  <%= inventory_unit.variant.product.name %><br><%= "(" + variant_options(inventory_unit.variant) + ")" unless inventory_unit.variant.option_values.empty? %>
@@ -16,7 +16,7 @@
16
16
  title: image.alt,
17
17
  content: %{
18
18
  <div class='align-center'>
19
- #{image_tag(image.attachment.url(:large))}
19
+ #{image_tag(image.url(:large))}
20
20
  </div>
21
21
  }.html_safe
22
22
  ) %>
@@ -3,7 +3,7 @@
3
3
  <%= render partial: 'spree/shared/error_messages', locals: { target: @image } %>
4
4
 
5
5
  <% admin_breadcrumb(link_to plural_resource_name(Spree::Image), admin_product_images_path(@product)) %>
6
- <% admin_breadcrumb(@image.attachment_file_name) %>
6
+ <% admin_breadcrumb(@image.filename) %>
7
7
 
8
8
 
9
9
  <% content_for :page_actions do %>
@@ -12,12 +12,12 @@
12
12
 
13
13
  <%= form_for [:admin, @product, @image], html: { multipart: true } do |f| %>
14
14
  <fieldset data-hook="edit_image">
15
- <legend align="center"><%= @image.attachment_file_name%></legend>
15
+ <legend align="center"><%= @image.filename %></legend>
16
16
 
17
17
  <div class="row">
18
18
  <div data-hook="thumbnail" class="field col-2 align-center">
19
19
  <%= f.label t('spree.thumbnail') %><br>
20
- <%= link_to image_tag(@image.attachment.url(:small)), @image.attachment.url(:product) %>
20
+ <%= link_to image_tag(@image.url(:small)), @image.url(:product) %>
21
21
  </div>
22
22
  <div class="col-10">
23
23
  <%= render partial: 'form', locals: { f: f } %>