spree_backend 4.2.4 → 4.3.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/config/spree_backend_manifest.js +129 -0
- data/app/assets/images/backend-arrows-fullscreen.svg +3 -0
- data/app/assets/images/backend-box.svg +3 -0
- data/app/assets/images/backend-circle-fill.svg +3 -0
- data/app/assets/images/backend-circle.svg +3 -0
- data/app/assets/images/backend-default-layout.svg +6 -0
- data/app/assets/images/backend-eye-slash-fill.svg +4 -0
- data/app/assets/images/backend-file-richtext.svg +4 -0
- data/app/assets/images/backend-fullscreen-exit.svg +3 -0
- data/app/assets/images/backend-fullscreen.svg +3 -0
- data/app/assets/images/backend-mobile.svg +5 -0
- data/app/assets/images/backend-pages.svg +10 -0
- data/app/assets/images/backend-phone.svg +4 -0
- data/app/assets/images/backend-reversed-layout.svg +6 -0
- data/app/assets/images/backend-spree-icon.svg +1 -0
- data/app/assets/images/backend-spree-logo.svg +6 -0
- data/app/assets/images/backend-store.svg +2 -13
- data/app/assets/images/backend-translate.svg +4 -0
- data/app/assets/images/backend-users.svg +2 -5
- data/app/assets/images/backend-window-sidebar.svg +4 -0
- data/app/assets/images/noimage/backend-missing-image.svg +4 -0
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/images/noimage/mini.png +0 -0
- data/app/assets/images/noimage/product.png +0 -0
- data/app/assets/images/noimage/small.png +0 -0
- data/app/assets/javascripts/spree/backend/address_states.es6 +44 -0
- data/app/assets/javascripts/spree/backend/admin.js +45 -307
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +22 -13
- data/app/assets/javascripts/spree/backend/cms/_index.es6 +4 -0
- data/app/assets/javascripts/spree/backend/cms/links.es6 +25 -0
- data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +34 -0
- data/app/assets/javascripts/spree/backend/cms/page.es6 +133 -0
- data/app/assets/javascripts/spree/backend/cms/section.es6 +43 -0
- data/app/assets/javascripts/spree/backend/global/_index.js +11 -0
- data/app/assets/javascripts/spree/backend/global/alerts.es6 +66 -0
- data/app/assets/javascripts/spree/backend/global/api_functions.es6 +5 -0
- data/app/assets/javascripts/spree/backend/global/bootstrap.es6 +15 -0
- data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +22 -0
- data/app/assets/javascripts/spree/backend/global/info_alert.es6 +38 -0
- data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +18 -0
- data/app/assets/javascripts/spree/backend/global/ransack.es6 +108 -0
- data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +56 -0
- data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +156 -0
- data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +61 -0
- data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +137 -0
- data/app/assets/javascripts/spree/backend/global/sortable.es6 +35 -0
- data/app/assets/javascripts/spree/backend/global/tinymce.es6 +11 -0
- data/app/assets/javascripts/spree/backend/menus/_index.es6 +2 -0
- data/app/assets/javascripts/spree/backend/menus/menu.es6 +57 -0
- data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +26 -0
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +13 -17
- data/app/assets/javascripts/spree/backend/option_value_picker.js +10 -22
- data/app/assets/javascripts/spree/backend/payments/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/payments/new.js +18 -5
- data/app/assets/javascripts/spree/backend/spree-select2.js +19 -1
- data/app/assets/javascripts/spree/backend/stock_location.js +1 -2
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +7 -1
- data/app/assets/javascripts/spree/backend/taxons.js +74 -73
- data/app/assets/javascripts/spree/backend/user_picker.js +7 -10
- data/app/assets/javascripts/spree/backend.js +28 -1
- data/app/assets/javascripts/spree.js +78 -0
- data/app/assets/stylesheets/spree/backend/components/_filters.scss +1 -3
- data/app/assets/stylesheets/spree/backend/components/_main.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_navbar.scss +35 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +13 -0
- data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_tables.scss +4 -5
- data/app/assets/stylesheets/spree/backend/global/_mixins.scss +59 -0
- data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +95 -0
- data/app/assets/stylesheets/spree/backend/plugins/{select2_bootstrap4.scss → _select2_bootstrap4.scss} +0 -0
- data/app/assets/stylesheets/spree/backend/plugins/_sweetalert2_custom.scss +100 -0
- data/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scss +4 -0
- data/app/assets/stylesheets/spree/backend/shared/_base.scss +75 -25
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +8 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +5 -0
- data/app/assets/stylesheets/spree/backend/views/_cms_pages.scss +148 -0
- data/app/assets/stylesheets/spree/backend/views/_menus.scss +61 -0
- data/app/controllers/concerns/spree/admin/order_concern.rb +24 -0
- data/app/controllers/concerns/spree/admin/product_concern.rb +11 -0
- data/app/controllers/spree/admin/base_controller.rb +63 -3
- data/app/controllers/spree/admin/cms_pages_controller.rb +29 -0
- data/app/controllers/spree/admin/cms_sections_controller.rb +15 -0
- data/app/controllers/spree/admin/customer_returns_controller.rb +4 -5
- data/app/controllers/spree/admin/errors_controller.rb +11 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -1
- data/app/controllers/spree/admin/images_controller.rb +8 -22
- data/app/controllers/spree/admin/log_entries_controller.rb +4 -3
- data/app/controllers/spree/admin/menu_items_controller.rb +33 -0
- data/app/controllers/spree/admin/menus_controller.rb +32 -0
- data/app/controllers/spree/admin/option_types_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +6 -11
- data/app/controllers/spree/admin/orders_controller.rb +23 -31
- data/app/controllers/spree/admin/payment_methods_controller.rb +17 -4
- data/app/controllers/spree/admin/payments_controller.rb +5 -10
- data/app/controllers/spree/admin/prices_controller.rb +2 -2
- data/app/controllers/spree/admin/products_controller.rb +21 -10
- data/app/controllers/spree/admin/promotion_actions_controller.rb +1 -1
- data/app/controllers/spree/admin/promotion_rules_controller.rb +1 -1
- data/app/controllers/spree/admin/promotions_controller.rb +3 -3
- data/app/controllers/spree/admin/prototypes_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +1 -1
- data/app/controllers/spree/admin/reports_controller.rb +5 -1
- data/app/controllers/spree/admin/resource_controller.rb +32 -5
- data/app/controllers/spree/admin/return_index_controller.rb +1 -1
- data/app/controllers/spree/admin/state_changes_controller.rb +2 -7
- data/app/controllers/spree/admin/stock_items_controller.rb +2 -2
- data/app/controllers/spree/admin/stock_locations_controller.rb +2 -2
- data/app/controllers/spree/admin/stock_movements_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
- data/app/controllers/spree/admin/store_credits_controller.rb +13 -8
- data/app/controllers/spree/admin/stores_controller.rb +14 -17
- data/app/controllers/spree/admin/taxons_controller.rb +9 -5
- data/app/controllers/spree/admin/users_controller.rb +9 -7
- data/app/controllers/spree/admin/variants_controller.rb +16 -15
- data/app/helpers/spree/admin/base_helper.rb +52 -14
- data/app/helpers/spree/admin/cms_helper.rb +15 -0
- data/app/helpers/spree/admin/menu_helper.rb +30 -0
- data/app/helpers/spree/admin/stores_helper.rb +21 -0
- data/app/models/spree/backend_configuration.rb +2 -0
- data/app/views/spree/admin/adjustments/_adjustment.html.erb +7 -5
- data/app/views/spree/admin/cms_pages/_form.html.erb +135 -0
- data/app/views/spree/admin/cms_pages/_live_preview_area.html.erb +61 -0
- data/app/views/spree/admin/cms_pages/_section_template.html.erb +16 -0
- data/app/views/spree/admin/cms_pages/edit.html.erb +21 -0
- data/app/views/spree/admin/cms_pages/index.html.erb +84 -0
- data/app/views/spree/admin/cms_pages/new.html.erb +8 -0
- data/app/views/spree/admin/cms_sections/_form.html.erb +69 -0
- data/app/views/spree/admin/cms_sections/edit.html.erb +19 -0
- data/app/views/spree/admin/cms_sections/new.html.erb +11 -0
- data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +50 -0
- data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +62 -0
- data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +177 -0
- data/app/views/spree/admin/cms_sections/types/_product_carousel.html.erb +5 -0
- data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +4 -0
- data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +121 -0
- data/app/views/spree/admin/countries/index.html.erb +5 -3
- data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +6 -4
- data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +9 -7
- data/app/views/spree/admin/customer_returns/index.html.erb +4 -2
- data/app/views/spree/admin/errors/forbidden.html.erb +0 -0
- data/app/views/spree/admin/images/index.html.erb +8 -4
- data/app/views/spree/admin/menu_items/_form.html.erb +115 -0
- data/app/views/spree/admin/menu_items/edit.html.erb +11 -0
- data/app/views/spree/admin/menu_items/new.html.erb +11 -0
- data/app/views/spree/admin/menus/_form.html.erb +19 -0
- data/app/views/spree/admin/menus/edit.html.erb +57 -0
- data/app/views/spree/admin/menus/index.html.erb +90 -0
- data/app/views/spree/admin/menus/nested_menu_items/_item_bar.html.erb +30 -0
- data/app/views/spree/admin/menus/new.html.erb +22 -0
- data/app/views/spree/admin/option_types/_form.html.erb +3 -0
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +5 -1
- data/app/views/spree/admin/option_types/index.html.erb +5 -3
- data/app/views/spree/admin/orders/_channel_form.html.erb +2 -2
- data/app/views/spree/admin/orders/_line_items.html.erb +10 -8
- data/app/views/spree/admin/orders/_shipment.html.erb +26 -18
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +11 -9
- data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +2 -2
- data/app/views/spree/admin/orders/index.html.erb +100 -101
- data/app/views/spree/admin/payment_methods/_form.html.erb +6 -4
- data/app/views/spree/admin/payment_methods/edit.html.erb +1 -1
- data/app/views/spree/admin/payment_methods/index.html.erb +22 -3
- data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
- data/app/views/spree/admin/payments/_list.html.erb +9 -7
- data/app/views/spree/admin/prices/_variant_prices.html.erb +7 -14
- data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +9 -7
- data/app/views/spree/admin/products/_autocomplete.js.erb +10 -6
- data/app/views/spree/admin/products/_form.html.erb +35 -5
- data/app/views/spree/admin/products/index.html.erb +15 -14
- data/app/views/spree/admin/products/new.html.erb +6 -1
- data/app/views/spree/admin/products/stock.html.erb +71 -68
- data/app/views/spree/admin/promotion_categories/index.html.erb +5 -3
- data/app/views/spree/admin/promotions/_form.html.erb +7 -0
- data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +1 -0
- data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +2 -1
- data/app/views/spree/admin/promotions/index.html.erb +33 -34
- data/app/views/spree/admin/properties/_form.html.erb +6 -0
- data/app/views/spree/admin/properties/index.html.erb +19 -3
- data/app/views/spree/admin/prototypes/_form.html.erb +1 -1
- data/app/views/spree/admin/prototypes/_prototypes.html.erb +8 -6
- data/app/views/spree/admin/prototypes/index.html.erb +5 -3
- data/app/views/spree/admin/reimbursement_types/index.html.erb +5 -3
- data/app/views/spree/admin/reports/index.html.erb +1 -1
- data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
- data/app/views/spree/admin/return_authorizations/index.html.erb +7 -5
- data/app/views/spree/admin/return_index/customer_returns.html.erb +4 -2
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +5 -3
- data/app/views/spree/admin/roles/index.html.erb +5 -3
- data/app/views/spree/admin/shared/_account_nav.html.erb +5 -5
- data/app/views/spree/admin/shared/_address_form.html.erb +5 -4
- data/app/views/spree/admin/shared/_content_header.html.erb +20 -6
- data/app/views/spree/admin/shared/_head.html.erb +2 -1
- data/app/views/spree/admin/shared/_header.html.erb +7 -10
- data/app/views/spree/admin/shared/_link_fields.html.erb +22 -0
- data/app/views/spree/admin/shared/_main_menu.html.erb +19 -4
- data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -10
- data/app/views/spree/admin/shared/_paths.html.erb +8 -0
- data/app/views/spree/admin/shared/_refunds.html.erb +4 -2
- data/app/views/spree/admin/shared/_sidebar.html.erb +1 -1
- data/app/views/spree/admin/shared/_store_switcher.html.erb +23 -0
- data/app/views/spree/admin/shared/_table_filter.html.erb +6 -6
- data/app/views/spree/admin/shared/_translations.html.erb +2 -0
- data/app/views/spree/admin/shared/cms/_spree_product.html.erb +14 -0
- data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +14 -0
- data/app/views/spree/admin/shared/linkables/_home_page.html.erb +3 -0
- data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +28 -0
- data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +20 -0
- data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +22 -0
- data/app/views/spree/admin/shared/linkables/_url.html.erb +16 -0
- data/app/views/spree/admin/shared/named_types/_index.html.erb +7 -5
- data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +1 -3
- data/app/views/spree/admin/shared/sub_menu/_content.html.erb +4 -0
- data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +4 -0
- data/app/views/spree/admin/shipping_categories/index.html.erb +5 -3
- data/app/views/spree/admin/shipping_methods/index.html.erb +5 -3
- data/app/views/spree/admin/states/_state_list.html.erb +5 -3
- data/app/views/spree/admin/stock_locations/index.html.erb +5 -3
- data/app/views/spree/admin/stock_transfers/index.html.erb +5 -4
- data/app/views/spree/admin/stock_transfers/new.html.erb +9 -7
- data/app/views/spree/admin/store_credit_categories/index.html.erb +5 -3
- data/app/views/spree/admin/store_credits/index.html.erb +7 -5
- data/app/views/spree/admin/stores/_form.html.erb +12 -2
- data/app/views/spree/admin/stores/index.html.erb +12 -10
- data/app/views/spree/admin/tax_categories/index.html.erb +5 -3
- data/app/views/spree/admin/tax_rates/index.html.erb +5 -3
- data/app/views/spree/admin/taxonomies/_list.html.erb +5 -3
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +2 -4
- data/app/views/spree/admin/users/_lifetime_stats.html.erb +16 -4
- data/app/views/spree/admin/users/index.html.erb +5 -3
- data/app/views/spree/admin/users/items.html.erb +1 -1
- data/app/views/spree/admin/variants/_autocomplete.js.erb +6 -2
- data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +18 -12
- data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +12 -8
- data/app/views/spree/admin/variants/_split.js.erb +9 -7
- data/app/views/spree/admin/variants/index.html.erb +8 -5
- data/app/views/spree/admin/zones/index.html.erb +5 -3
- data/app/views/spree/layouts/admin.html.erb +16 -16
- data/config/initializers/assets.rb +5 -1
- data/config/routes.rb +14 -2
- data/lib/generators/spree/backend/install/install_generator.rb +22 -0
- data/lib/generators/spree/backend/install/templates/vendor/assets/javascripts/spree/backend/all.js +8 -0
- data/lib/generators/spree/backend/install/templates/vendor/assets/stylesheets/spree/backend/all.css +9 -0
- data/lib/spree/backend/engine.rb +4 -11
- data/lib/spree/backend.rb +7 -4
- data/lib/spree_backend.rb +0 -2
- data/spec/fixtures/files/favicon.ico +0 -0
- data/spec/fixtures/files/icon_512x512.png +0 -0
- data/spree_backend.gemspec +16 -11
- data/vendor/assets/javascripts/cleave.js +8 -0
- data/vendor/assets/javascripts/jsonapi-serializer.min.js +8 -0
- data/vendor/assets/javascripts/jsuri.js +458 -0
- data/vendor/assets/javascripts/sortable.js +2 -3709
- data/vendor/assets/javascripts/sweetalert2.js +2 -0
- metadata +208 -42
- data/app/assets/javascripts/spree/backend/address_states.js +0 -44
- data/app/assets/javascripts/spree/frontend/backend.js +0 -1
- data/app/assets/stylesheets/spree/frontend/backend.css +0 -1
- data/app/views/spree/admin/orders/_store_form.html.erb +0 -18
@@ -6,10 +6,10 @@ module Spree
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def set_country
|
9
|
-
@stock_location.country =
|
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
|
@@ -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(:
|
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 =
|
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:
|
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
|
-
|
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
|
-
|
31
|
+
stores_scope.joins(:translations).where("LOWER(#{Store::Translation.table_name}.name) LIKE LOWER(:query)",
|
35
32
|
query: "%#{params[:q]}%")
|
36
33
|
else
|
37
|
-
|
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 =
|
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
|
-
|
58
|
+
redirect_to spree.edit_admin_store_path(@store)
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
65
62
|
def destroy
|
66
|
-
@store =
|
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 =
|
81
|
-
stores =
|
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 =
|
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
|
-
|
93
|
+
scope.includes(:translations, taxons: [:translations]).find(params[:taxonomy_id])
|
94
94
|
else
|
95
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
-
@
|
40
|
+
return @collection if @collection.present?
|
41
|
+
|
42
|
+
params[:q] ||= {}
|
43
|
+
@deleted = params.dig(:q, :deleted_at_null) || '0'
|
43
44
|
|
44
|
-
@collection
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
-
|
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
|