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.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/spree/backend.js +0 -2
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
- data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
- data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +7 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +18 -0
- data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
- data/app/assets/javascripts/spree/backend/taxons.js +1 -1
- data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
- data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +46 -10
- data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
- data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
- data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
- data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
- data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
- data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
- data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
- data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
- data/app/assets/stylesheets/spree/backend/globals/_functions.scss +2 -0
- data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
- data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
- data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
- data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
- data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +25 -6
- data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
- data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
- data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
- data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
- data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
- data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
- data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
- data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
- data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
- data/app/controllers/spree/admin/locale_controller.rb +1 -1
- data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
- data/app/controllers/spree/admin/orders_controller.rb +1 -12
- data/app/controllers/spree/admin/products_controller.rb +10 -6
- data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
- data/app/controllers/spree/admin/resource_controller.rb +1 -0
- data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
- data/app/controllers/spree/admin/users_controller.rb +4 -2
- data/app/helpers/spree/admin/base_helper.rb +9 -3
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/helpers/spree/admin/promotions_helper.rb +15 -0
- data/app/models/spree/backend_configuration.rb +38 -21
- data/app/views/spree/admin/cancellations/index.html.erb +3 -1
- data/app/views/spree/admin/images/_image_row.html.erb +1 -1
- data/app/views/spree/admin/images/edit.html.erb +3 -3
- data/app/views/spree/admin/images/index.html.erb +3 -3
- data/app/views/spree/admin/log_entries/index.html.erb +1 -19
- data/app/views/spree/admin/option_types/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
- data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +1 -1
- data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
- data/app/views/spree/admin/payments/show.html.erb +13 -6
- data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
- data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
- data/app/views/spree/admin/prices/_form.html.erb +1 -1
- data/app/views/spree/admin/product_properties/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +23 -12
- data/app/views/spree/admin/products/edit.html.erb +5 -0
- data/app/views/spree/admin/products/index.html.erb +3 -1
- data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +6 -5
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +3 -1
- data/app/views/spree/admin/promotions/index.html.erb +4 -4
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
- data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
- data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +1 -3
- data/app/views/spree/admin/shared/_image.html.erb +2 -2
- data/app/views/spree/admin/shared/_modal.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
- data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
- data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
- data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
- data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
- data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
- data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
- data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
- data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -2
- data/app/views/spree/admin/store_credits/index.html.erb +1 -1
- data/app/views/spree/admin/store_credits/show.html.erb +3 -3
- data/app/views/spree/admin/stores/_form.html.erb +1 -0
- data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
- data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/edit.html.erb +2 -2
- data/app/views/spree/admin/users/edit.html.erb +2 -2
- data/app/views/spree/admin/users/index.html.erb +2 -2
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/users/orders.html.erb +1 -1
- data/app/views/spree/admin/variants/_form.html.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +1 -1
- data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
- data/config/routes.rb +2 -8
- data/lib/spree/backend.rb +1 -1
- data/solidus_backend.gemspec +3 -4
- data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
- data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
- data/spec/controllers/spree/admin/orders_controller_spec.rb +25 -13
- data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
- data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
- data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
- data/spec/features/admin/homepage_spec.rb +1 -6
- data/spec/features/admin/locale_spec.rb +1 -2
- data/spec/features/admin/orders/adjustments_spec.rb +1 -1
- data/spec/features/admin/orders/customer_details_spec.rb +5 -7
- data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
- data/spec/features/admin/orders/listing_spec.rb +2 -7
- data/spec/features/admin/orders/log_entries_spec.rb +2 -2
- data/spec/features/admin/orders/new_order_spec.rb +117 -0
- data/spec/features/admin/orders/new_refund_spec.rb +35 -0
- data/spec/features/admin/orders/order_details_spec.rb +10 -5
- data/spec/features/admin/orders/payments_spec.rb +82 -41
- data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
- data/spec/features/admin/orders/shipments_spec.rb +28 -0
- data/spec/features/admin/products/edit/products_spec.rb +25 -0
- data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
- data/spec/features/admin/products/pricing_spec.rb +24 -6
- data/spec/features/admin/products/products_spec.rb +5 -5
- data/spec/features/admin/products/stock_management_spec.rb +27 -13
- data/spec/features/admin/products/variant_spec.rb +1 -1
- data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
- data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
- data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
- data/spec/features/admin/promotions/promotion_spec.rb +52 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
- data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
- data/spec/features/admin/reimbursements_spec.rb +1 -1
- data/spec/features/admin/store_credits_spec.rb +51 -2
- data/spec/features/admin/taxons_spec.rb +35 -0
- data/spec/features/admin/users_spec.rb +44 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
- data/spec/javascripts/spec_helper.js +2 -0
- data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
- data/spec/models/spree/backend_configuration_spec.rb +22 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/appear_before_matcher.rb +1 -1
- data/spec/support/feature/order_feature_helper.rb +1 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
- data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
- data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
- data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
- data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
- data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
- data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
- metadata +38 -36
- data/.eslintrc +0 -21
- data/app/controllers/spree/admin/reports_controller.rb +0 -82
- data/app/views/spree/admin/reports/index.html.erb +0 -19
- data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
- data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
- 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.
|
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
|
@@ -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 :
|
9
|
-
before_action :
|
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, @
|
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(@
|
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
|
82
|
-
@
|
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
|
90
|
-
@
|
91
|
-
unless @
|
92
|
-
@store_credit.errors.add(:base, t('spree.admin.store_credits.errors.
|
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
|
-
|
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
|
-
|
35
|
-
|
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
|
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,
|
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',
|
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? %>
|
@@ -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.
|
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.
|
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.
|
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 } %>
|