spree_backend 4.3.3 → 4.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +222 -0
- data/.codeclimate.yml +36 -0
- data/.editorconfig +22 -0
- data/.eslintignore +7 -0
- data/.eslintrc.cjs +29 -0
- data/.gem_release.yml +4 -0
- data/.github/CONTRIBUTING.md +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/ISSUE_TEMPLATE.md +39 -0
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/spelling_lint.yml +34 -0
- data/.gitignore +63 -0
- data/.rubocop.yml +197 -0
- data/.solargraph.yml +20 -0
- data/.stylelintignore +4 -0
- data/.stylelintrc +6 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +59 -3
- data/README.md +123 -0
- data/SECURITY.md +1 -0
- data/app/assets/config/spree_backend_manifest.js +1 -1
- data/app/assets/images/backend-cloud-arrow-up.svg +4 -0
- data/app/assets/images/backend-eye-open.svg +1 -1
- data/app/assets/images/backend-file-earmark-font.svg +4 -0
- data/app/assets/images/backend-file-earmark-image.svg +4 -0
- data/app/assets/images/backend-file-earmark-music.svg +4 -0
- data/app/assets/images/backend-file-earmark-pdf.svg +4 -0
- data/app/assets/images/backend-file-earmark-play.svg +4 -0
- data/app/assets/images/backend-file-earmark-spreadsheet.svg +3 -0
- data/app/assets/images/backend-file-earmark-zip.svg +4 -0
- data/app/assets/images/backend-file-earmark.svg +3 -0
- data/app/assets/images/backend-hdd.svg +4 -0
- data/app/assets/images/backend-link.svg +4 -0
- data/app/assets/images/backend-view.svg +1 -1
- data/app/assets/javascripts/spree/backend/adjustments.js +5 -5
- data/app/assets/javascripts/spree/backend/admin.js +4 -6
- data/app/assets/javascripts/spree/backend/calculator.js +1 -1
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/cms/links.es6 +1 -1
- data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +1 -1
- data/app/assets/javascripts/spree/backend/cms/page.es6 +22 -40
- data/app/assets/javascripts/spree/backend/cms/section.es6 +1 -1
- data/app/assets/javascripts/spree/backend/gateway.js +1 -1
- data/app/assets/javascripts/spree/backend/general_settings.js +1 -1
- data/app/assets/javascripts/spree/backend/global/_index.js +3 -1
- data/app/assets/javascripts/spree/backend/global/alerts.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/animate_css.es6 +19 -0
- data/app/assets/javascripts/spree/backend/global/fetch_request_utility.es6 +114 -0
- data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +2 -1
- data/app/assets/javascripts/spree/backend/global/info_alert.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/ransack.es6 +7 -5
- data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +4 -4
- data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +2 -2
- data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +2 -2
- data/app/assets/javascripts/spree/backend/global/sortable.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/tinymce.es6 +3 -2
- data/app/assets/javascripts/spree/backend/line_items.js +7 -9
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +23 -28
- data/app/assets/javascripts/spree/backend/menus/_index.es6 +0 -1
- data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +1 -1
- data/app/assets/javascripts/spree/backend/multi_currency.js +2 -2
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/orders/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/payments/edit.js +32 -22
- data/app/assets/javascripts/spree/backend/payments/new.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +16 -25
- data/app/assets/javascripts/spree/backend/progress.js +5 -3
- data/app/assets/javascripts/spree/backend/promotions.js +3 -1
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +1 -1
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +80 -79
- data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
- data/app/assets/javascripts/spree/backend/states.js +1 -1
- data/app/assets/javascripts/spree/backend/stock_location.js +1 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +1 -1
- data/app/assets/javascripts/spree/backend/stock_movement.js +58 -13
- data/app/assets/javascripts/spree/backend/stock_transfer.js +62 -32
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +9 -8
- data/app/assets/javascripts/spree/backend/taxons.js +17 -14
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/users/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +19 -11
- data/app/assets/javascripts/spree/backend/variant_management.js +1 -1
- data/app/assets/javascripts/spree/backend/zone.js +1 -1
- data/app/assets/javascripts/spree/backend.js +13 -33
- data/app/assets/javascripts/spree.js +2 -9
- data/app/assets/stylesheets/spree/backend/components/_main.scss +8 -0
- data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +1 -1
- data/app/assets/stylesheets/spree/backend/plugins/_select2_custom.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_sortable_tree.scss +62 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +3 -0
- data/app/assets/stylesheets/spree/backend/views/_digitals.scss +33 -0
- data/app/assets/stylesheets/spree/backend/views/_taxonomies.scss +3 -0
- data/app/controllers/spree/admin/base_controller.rb +4 -13
- data/app/controllers/spree/admin/digitals_controller.rb +33 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +0 -5
- data/app/controllers/spree/admin/images_controller.rb +1 -1
- data/app/controllers/spree/admin/oauth_applications_controller.rb +17 -0
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
- data/app/controllers/spree/admin/orders_controller.rb +10 -2
- data/app/controllers/spree/admin/payment_methods_controller.rb +2 -2
- data/app/controllers/spree/admin/payments_controller.rb +1 -1
- data/app/controllers/spree/admin/products_controller.rb +4 -2
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/properties_controller.rb +1 -1
- data/app/controllers/spree/admin/resource_controller.rb +9 -4
- data/app/controllers/spree/admin/return_index_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_transfers_controller.rb +2 -2
- data/app/controllers/spree/admin/store_credits_controller.rb +2 -2
- data/app/controllers/spree/admin/stores_controller.rb +2 -2
- data/app/controllers/spree/admin/taxons_controller.rb +23 -38
- data/app/controllers/spree/admin/users_controller.rb +6 -19
- data/app/controllers/spree/admin/variants_controller.rb +1 -2
- data/app/controllers/spree/admin/webhooks_subscribers_controller.rb +48 -0
- data/app/helpers/spree/admin/base_helper.rb +27 -9
- data/app/helpers/spree/admin/digital_helper.rb +28 -0
- data/app/helpers/spree/admin/menu_helper.rb +0 -21
- data/app/helpers/spree/admin/navigation_helper.rb +19 -9
- data/app/helpers/spree/admin/sortable_tree_helper.rb +31 -0
- data/app/helpers/spree/admin/stores_helper.rb +1 -1
- data/app/helpers/spree/admin/webhooks_subscribers_helper.rb +31 -0
- data/app/javascript/spree/dashboard/controllers/clipboard_controller.js +12 -0
- data/app/javascript/spree/dashboard/controllers/password_toggle_controller.js +14 -0
- data/app/javascript/spree/dashboard/controllers/sortable_tree_controller.js +55 -0
- data/app/javascript/spree/dashboard/controllers/spree_controller.js +25 -0
- data/app/javascript/spree/dashboard/controllers/upload_button_controller.js +13 -0
- data/app/javascript/spree/dashboard/controllers/webhooks_subscriber_events_controller.js +19 -0
- data/app/javascript/spree/dashboard/index.js +49 -0
- data/app/{assets/javascripts/spree/backend/global/bootstrap.es6 → javascript/spree/dashboard/utilities/bootstrap.js} +6 -2
- data/app/javascript/spree/dashboard/utilities/request_utility.js +54 -0
- data/app/models/spree/backend_configuration.rb +11 -0
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
- data/app/views/spree/admin/adjustments/_form.html.erb +2 -2
- data/app/views/spree/admin/adjustments/index.html.erb +1 -0
- data/app/views/spree/admin/cms_pages/_form.html.erb +8 -8
- data/app/views/spree/admin/cms_pages/edit.html.erb +1 -6
- data/app/views/spree/admin/cms_sections/_form.html.erb +2 -2
- data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +6 -6
- data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +6 -6
- data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +12 -12
- data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +1 -1
- data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +12 -12
- data/app/views/spree/admin/countries/_form.html.erb +4 -4
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- data/app/views/spree/admin/digitals/_form.html.erb +35 -0
- data/app/views/spree/admin/digitals/index.html.erb +25 -0
- data/app/views/spree/admin/general_settings/edit.html.erb +1 -22
- data/app/views/spree/admin/menu_items/_form.html.erb +6 -6
- data/app/views/spree/admin/menus/_form.html.erb +3 -3
- data/app/views/spree/admin/menus/edit.html.erb +18 -18
- data/app/views/spree/admin/oauth_applications/_form.html.erb +22 -0
- data/app/views/spree/admin/oauth_applications/create.turbo_stream.erb +38 -0
- data/app/views/spree/admin/oauth_applications/edit.html.erb +13 -0
- data/app/views/spree/admin/oauth_applications/index.html.erb +51 -0
- data/app/views/spree/admin/oauth_applications/new.html.erb +15 -0
- data/app/views/spree/admin/option_types/_form.html.erb +3 -3
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +2 -2
- data/app/views/spree/admin/orders/_channel_form.html.erb +1 -1
- data/app/views/spree/admin/orders/_form.html.erb +1 -0
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
- data/app/views/spree/admin/orders/_order_actions.html.erb +6 -0
- data/app/views/spree/admin/orders/_search.html.erb +151 -0
- data/app/views/spree/admin/orders/index.html.erb +2 -151
- data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +19 -19
- data/app/views/spree/admin/products/index.html.erb +2 -0
- data/app/views/spree/admin/products/new.html.erb +6 -6
- data/app/views/spree/admin/promotion_actions/create.js.erb +1 -1
- data/app/views/spree/admin/promotion_categories/_form.html.erb +2 -2
- data/app/views/spree/admin/promotions/_form.html.erb +5 -5
- data/app/views/spree/admin/properties/_form.html.erb +3 -3
- data/app/views/spree/admin/prototypes/_form.html.erb +4 -4
- data/app/views/spree/admin/refunds/new.html.erb +2 -2
- data/app/views/spree/admin/reimbursement_types/_form.html.erb +2 -2
- data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -3
- data/app/views/spree/admin/roles/_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_account_nav.html.erb +1 -1
- data/app/views/spree/admin/shared/_address_form.html.erb +4 -4
- data/app/views/spree/admin/shared/_head.html.erb +4 -8
- data/app/views/spree/admin/shared/_main_menu.html.erb +12 -0
- data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_tabs.html.erb +8 -0
- data/app/views/spree/admin/shared/_version.html.erb +1 -1
- data/app/views/spree/admin/shared/cms/_spree_product.html.erb +2 -2
- data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_url.html.erb +1 -1
- data/app/views/spree/admin/shared/named_types/_form.html.erb +1 -1
- data/app/views/spree/admin/{menus/nested_menu_items/_item_bar.html.erb → shared/sortable_tree/_menu.html.erb} +10 -7
- data/app/views/spree/admin/shared/sortable_tree/_taxonomy.html.erb +34 -0
- data/app/views/spree/admin/shared/sub_menu/_apps.html.erb +3 -0
- data/app/views/spree/admin/shared/sub_menu/_integrations.html.erb +3 -0
- data/app/views/spree/admin/shipping_categories/_form.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +8 -8
- data/app/views/spree/admin/states/_form.html.erb +2 -2
- data/app/views/spree/admin/stock_locations/_form.html.erb +2 -2
- data/app/views/spree/admin/stock_movements/_form.html.erb +3 -3
- data/app/views/spree/admin/store_credit_categories/_form.html.erb +1 -1
- data/app/views/spree/admin/store_credits/_form.html.erb +4 -4
- data/app/views/spree/admin/stores/_form.html.erb +280 -227
- data/app/views/spree/admin/tax_categories/_form.html.erb +4 -4
- data/app/views/spree/admin/tax_rates/_form.html.erb +4 -3
- data/app/views/spree/admin/taxonomies/_form.html.erb +2 -2
- data/app/views/spree/admin/taxonomies/edit.html.erb +34 -29
- data/app/views/spree/admin/taxons/_form.html.erb +101 -57
- data/app/views/spree/admin/taxons/edit.html.erb +6 -3
- data/app/views/spree/admin/taxons/index.html.erb +1 -1
- data/app/views/spree/admin/taxons/new.html.erb +16 -0
- data/app/views/spree/admin/users/_form.html.erb +3 -3
- data/app/views/spree/admin/users/edit.html.erb +0 -40
- data/app/views/spree/admin/variants/_autocomplete.js.erb +5 -5
- data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +2 -2
- data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +6 -6
- data/app/views/spree/admin/variants/_split.js.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +4 -1
- data/app/views/spree/admin/webhooks_subscribers/_form.html.erb +101 -0
- data/app/views/spree/admin/webhooks_subscribers/edit.html.erb +13 -0
- data/app/views/spree/admin/webhooks_subscribers/index.html.erb +47 -0
- data/app/views/spree/admin/webhooks_subscribers/new.html.erb +13 -0
- data/app/views/spree/admin/webhooks_subscribers/show.html.erb +59 -0
- data/app/views/spree/admin/zones/_country_members.html.erb +1 -1
- data/app/views/spree/admin/zones/_form.html.erb +2 -2
- data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
- data/app/views/spree/layouts/admin.html.erb +1 -11
- data/codespell.txt +8 -0
- data/config/locales/en.yml +273 -0
- data/config/routes.rb +8 -4
- data/lib/generators/spree/backend/install/install_generator.rb +4 -2
- data/lib/generators/spree/backend/install/templates/app/javascript/spree-dashboard.js +7 -0
- data/lib/spree/backend/engine.rb +2 -1
- data/lib/spree/backend/testing_support/capybara_utils.rb +53 -0
- data/lib/spree/backend/testing_support/flash.rb +38 -0
- data/lib/spree/backend/testing_support/flatpickr_capybara.rb +126 -0
- data/lib/spree/backend/version.rb +9 -0
- data/lib/spree/backend.rb +2 -1
- data/lib/spree_backend.rb +17 -0
- data/license.md +13 -0
- data/package.json +46 -0
- data/rollup.config.js +41 -0
- data/spree_backend.gemspec +17 -16
- data/vendor/assets/javascripts/purify.js +1 -1
- data/vendor/assets/stylesheets/animate.css +2 -4
- data/yarn.lock +959 -0
- metadata +120 -38
- data/app/assets/javascripts/spree/backend/menus/menu.es6 +0 -57
- data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +0 -11
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +0 -35
- data/app/assets/javascripts/spree/backend/taxonomy.js +0 -178
- data/app/views/spree/admin/taxonomies/_js_head.html.erb +0 -7
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +0 -4564
- data/vendor/assets/javascripts/js.cookie.js +0 -163
- data/vendor/assets/javascripts/modernizr.js +0 -3
- data/vendor/assets/stylesheets/jquery.jstree/themes/spree/style.scss +0 -230
- data/vendor/assets/stylesheets/jquery.jstree/themes/spree/throbber.gif +0 -0
- /data/app/assets/stylesheets/spree/backend/views/{prototypes.scss → _prototypes.scss} +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class DigitalsController < ResourceController
|
4
|
+
belongs_to 'spree/product', find_by: :slug
|
5
|
+
|
6
|
+
def create
|
7
|
+
invoke_callbacks(:create, :before)
|
8
|
+
@object.attributes = permitted_resource_params
|
9
|
+
|
10
|
+
if @object.valid?
|
11
|
+
super
|
12
|
+
else
|
13
|
+
invoke_callbacks(:create, :fails)
|
14
|
+
flash[:error] = @object.errors.full_messages.join(', ')
|
15
|
+
respond_with(@object) do |format|
|
16
|
+
format.html { render action: :index, status: :unprocessable_entity }
|
17
|
+
format.js { render layout: false, status: :unprocessable_entity }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def permitted_resource_params
|
25
|
+
params.require(:digital).permit(permitted_digital_attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def permitted_digital_attributes
|
29
|
+
%i[variant_id attachment attachment_file_name attachment_content_type]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class OauthApplicationsController < ResourceController
|
4
|
+
before_action :set_default_scopes, only: [:new, :edit]
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def turbo_enabled?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_default_scopes
|
13
|
+
@object.scopes = 'admin' if @object.scopes.blank?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -28,10 +28,10 @@ module Spree
|
|
28
28
|
flash[:success] = Spree.t('customer_details_updated')
|
29
29
|
redirect_to spree.edit_admin_order_url(@order)
|
30
30
|
else
|
31
|
-
render action: :edit
|
31
|
+
render action: :edit, status: :unprocessable_entity
|
32
32
|
end
|
33
33
|
else
|
34
|
-
render action: :edit
|
34
|
+
render action: :edit, status: :unprocessable_entity
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -13,7 +13,7 @@ module Spree
|
|
13
13
|
|
14
14
|
def index
|
15
15
|
params[:q] ||= {}
|
16
|
-
params[:q][:completed_at_not_null] ||= '1' if Spree::Config[:show_only_complete_orders_by_default]
|
16
|
+
params[:q][:completed_at_not_null] ||= '1' if Spree::Backend::Config[:show_only_complete_orders_by_default]
|
17
17
|
@show_only_completed = params[:q][:completed_at_not_null] == '1'
|
18
18
|
params[:q][:s] ||= @show_only_completed ? 'completed_at desc' : 'created_at desc'
|
19
19
|
params[:q][:completed_at_not_null] = '' unless @show_only_completed
|
@@ -54,7 +54,7 @@ module Spree
|
|
54
54
|
# see https://github.com/spree/spree/pull/3919
|
55
55
|
@orders = @search.result(distinct: true).
|
56
56
|
page(params[:page]).
|
57
|
-
per(params[:per_page] || Spree::Config[:admin_orders_per_page])
|
57
|
+
per(params[:per_page] || Spree::Backend::Config[:admin_orders_per_page])
|
58
58
|
|
59
59
|
# Restore dates
|
60
60
|
params[:q][:created_at_gt] = created_at_gt
|
@@ -119,6 +119,14 @@ module Spree
|
|
119
119
|
redirect_back fallback_location: spree.edit_admin_order_url(@order)
|
120
120
|
end
|
121
121
|
|
122
|
+
def reset_digitals
|
123
|
+
load_order
|
124
|
+
@order.digital_links.each(&:reset!)
|
125
|
+
flash[:notice] = Spree.t('admin.digitals.downloads_reset')
|
126
|
+
|
127
|
+
redirect_back fallback_location: spree.edit_admin_order_url(@order)
|
128
|
+
end
|
129
|
+
|
122
130
|
def open_adjustments
|
123
131
|
adjustments = @order.all_adjustments.finalized
|
124
132
|
adjustments.update_all(state: 'open')
|
@@ -18,7 +18,7 @@ module Spree
|
|
18
18
|
redirect_to spree.edit_admin_payment_method_path(@payment_method)
|
19
19
|
else
|
20
20
|
invoke_callbacks(:create, :fails)
|
21
|
-
respond_with(@payment_method)
|
21
|
+
respond_with(@payment_method, status: :unprocessable_entity)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -45,7 +45,7 @@ module Spree
|
|
45
45
|
redirect_to spree.edit_admin_payment_method_path(@payment_method)
|
46
46
|
else
|
47
47
|
invoke_callbacks(:update, :fails)
|
48
|
-
respond_with(@payment_method)
|
48
|
+
respond_with(@payment_method, status: :unprocessable_entity)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ module Spree
|
|
54
54
|
@payment ||= @order.payments.build(object_params)
|
55
55
|
invoke_callbacks(:create, :fails)
|
56
56
|
flash[:error] = Spree.t(:payment_could_not_be_created)
|
57
|
-
render :new
|
57
|
+
render :new, status: :unprocessable_entity
|
58
58
|
end
|
59
59
|
rescue Spree::Core::GatewayError => e
|
60
60
|
invoke_callbacks(:create, :fails)
|
@@ -42,7 +42,9 @@ module Spree
|
|
42
42
|
# update the product again
|
43
43
|
@product.slug = @product.slug_was if @product.slug.blank?
|
44
44
|
invoke_callbacks(:update, :fails)
|
45
|
-
respond_with(@object)
|
45
|
+
respond_with(@object) do |format|
|
46
|
+
format.html { render :edit, status: :unprocessable_entity }
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -132,7 +134,7 @@ module Spree
|
|
132
134
|
@collection = @search.result.
|
133
135
|
includes(product_includes).
|
134
136
|
page(params[:page]).
|
135
|
-
per(params[:per_page] || Spree::Config[:admin_products_per_page])
|
137
|
+
per(params[:per_page] || Spree::Backend::Config[:admin_products_per_page])
|
136
138
|
@collection
|
137
139
|
end
|
138
140
|
|
@@ -42,7 +42,7 @@ module Spree
|
|
42
42
|
@collection = @search.result(distinct: true).
|
43
43
|
includes(promotion_includes).
|
44
44
|
page(params[:page]).
|
45
|
-
per(params[:per_page] || Spree::Config[:admin_promotions_per_page])
|
45
|
+
per(params[:per_page] || Spree::Backend::Config[:admin_promotions_per_page])
|
46
46
|
end
|
47
47
|
|
48
48
|
def promotion_includes
|
@@ -39,8 +39,8 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
39
39
|
else
|
40
40
|
invoke_callbacks(:update, :fails)
|
41
41
|
respond_with(@object) do |format|
|
42
|
-
format.html { render action: :edit }
|
43
|
-
format.js { render layout: false }
|
42
|
+
format.html { render action: :edit, status: :unprocessable_entity }
|
43
|
+
format.js { render layout: false, status: :unprocessable_entity }
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -53,13 +53,14 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
53
53
|
flash[:success] = flash_message_for(@object, :successfully_created)
|
54
54
|
respond_with(@object) do |format|
|
55
55
|
format.html { redirect_to location_after_save }
|
56
|
+
format.turbo_stream if turbo_enabled?
|
56
57
|
format.js { render layout: false }
|
57
58
|
end
|
58
59
|
else
|
59
60
|
invoke_callbacks(:create, :fails)
|
60
61
|
respond_with(@object) do |format|
|
61
|
-
format.html { render action: :new }
|
62
|
-
format.js { render layout: false }
|
62
|
+
format.html { render action: :new, status: :unprocessable_entity }
|
63
|
+
format.js { render layout: false, status: :unprocessable_entity }
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
@@ -278,4 +279,8 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
278
279
|
def new_actions
|
279
280
|
[:new, :create]
|
280
281
|
end
|
282
|
+
|
283
|
+
def turbo_enabled?
|
284
|
+
false
|
285
|
+
end
|
281
286
|
end
|
@@ -21,7 +21,7 @@ module Spree
|
|
21
21
|
@collection = resource.all
|
22
22
|
# @search needs to be defined as this is passed to search_form_for
|
23
23
|
@search = @collection.ransack(params[:q])
|
24
|
-
per_page = params[:per_page] || Spree::Config[:admin_customer_returns_per_page]
|
24
|
+
per_page = params[:per_page] || Spree::Backend::Config[:admin_customer_returns_per_page]
|
25
25
|
@collection = @search.result.order(created_at: :desc).page(params[:page]).per(per_page)
|
26
26
|
end
|
27
27
|
end
|
@@ -21,10 +21,10 @@ module Spree
|
|
21
21
|
def create
|
22
22
|
if params[:variant].nil?
|
23
23
|
flash.now[:error] = Spree.t('stock_transfer.errors.must_have_variant')
|
24
|
-
render :new
|
24
|
+
render :new, status: :unprocessable_entity
|
25
25
|
elsif any_missing_variants?(params[:variant])
|
26
26
|
flash.now[:error] = Spree.t('stock_transfer.errors.variants_unavailable', stock: source_location.name)
|
27
|
-
render :new
|
27
|
+
render :new, status: :unprocessable_entity
|
28
28
|
else
|
29
29
|
variants = Hash.new(0)
|
30
30
|
params[:variant].each_with_index do |variant_id, i|
|
@@ -27,7 +27,7 @@ module Spree
|
|
27
27
|
else
|
28
28
|
load_categories
|
29
29
|
flash[:error] = Spree.t('store_credit.errors.unable_to_create')
|
30
|
-
render :new
|
30
|
+
render :new, status: :unprocessable_entity
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -41,7 +41,7 @@ module Spree
|
|
41
41
|
else
|
42
42
|
load_categories
|
43
43
|
flash[:error] = Spree.t('store_credit.errors.unable_to_update')
|
44
|
-
render :edit
|
44
|
+
render :edit, status: :unprocessable_entity
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -43,7 +43,7 @@ module Spree
|
|
43
43
|
redirect_to @store.formatted_url + spree.admin_stores_path
|
44
44
|
else
|
45
45
|
flash[:error] = "#{Spree.t('store_errors.unable_to_create')}: #{@store.errors.full_messages.join(', ')}"
|
46
|
-
render :new
|
46
|
+
render :new, status: :unprocessable_entity
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -112,7 +112,7 @@ module Spree
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def set_default_currency
|
115
|
-
@store.default_currency = Spree::
|
115
|
+
@store.default_currency = Spree::Store.default.default_currency
|
116
116
|
end
|
117
117
|
|
118
118
|
def set_default_locale
|
@@ -1,30 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
|
-
class TaxonsController <
|
4
|
-
|
5
|
-
|
6
|
-
before_action :set_permalink_part, only: [:edit
|
3
|
+
class TaxonsController < ResourceController
|
4
|
+
belongs_to 'spree/taxonomy'
|
5
|
+
|
6
|
+
before_action :set_permalink_part, only: [:edit]
|
7
7
|
respond_to :html, :js
|
8
8
|
|
9
9
|
def index; end
|
10
10
|
|
11
|
-
def create
|
12
|
-
@taxon = @taxonomy.taxons.build(params[:taxon].except(:icon))
|
13
|
-
@taxon.build_icon(attachment: taxon_params[:icon])
|
14
|
-
if @taxon.save
|
15
|
-
respond_with(@taxon) do |format|
|
16
|
-
format.json { render json: @taxon.to_json }
|
17
|
-
end
|
18
|
-
else
|
19
|
-
flash[:error] = Spree.t('errors.messages.could_not_create_taxon')
|
20
|
-
respond_with(@taxon) do |format|
|
21
|
-
format.html { redirect_to @taxonomy ? edit_admin_taxonomy_url(@taxonomy) : admin_taxonomies_url }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def edit; end
|
27
|
-
|
28
11
|
def update
|
29
12
|
successful = @taxon.transaction do
|
30
13
|
parent_id = params[:taxon][:parent_id]
|
@@ -51,13 +34,13 @@ module Spree
|
|
51
34
|
rename_child_taxons if @update_children
|
52
35
|
|
53
36
|
respond_with(@taxon) do |format|
|
54
|
-
format.html { redirect_to spree.
|
37
|
+
format.html { redirect_to spree.edit_admin_taxonomy_taxon_path(@taxonomy.id, @taxon.id) }
|
55
38
|
format.json { render json: @taxon.to_json }
|
56
39
|
end
|
57
40
|
else
|
58
41
|
respond_with(@taxon) do |format|
|
59
|
-
format.html { render :edit }
|
60
|
-
format.json { render json: @taxon.errors.full_messages.to_sentence, status:
|
42
|
+
format.html { render :edit, status: :unprocessable_entity }
|
43
|
+
format.json { render json: @taxon.errors.full_messages.to_sentence, status: :unprocessable_entity }
|
61
44
|
end
|
62
45
|
end
|
63
46
|
end
|
@@ -68,12 +51,24 @@ module Spree
|
|
68
51
|
redirect_to spree.edit_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.id)
|
69
52
|
else
|
70
53
|
flash[:error] = Spree.t('errors.messages.cannot_remove_icon')
|
71
|
-
render :edit
|
54
|
+
render :edit, status: :unprocessable_entity
|
72
55
|
end
|
73
56
|
end
|
74
57
|
|
75
58
|
private
|
76
59
|
|
60
|
+
def location_after_save
|
61
|
+
spree.edit_admin_taxonomy_taxon_path(@taxonomy.id, @taxon.id)
|
62
|
+
end
|
63
|
+
|
64
|
+
def parent_data
|
65
|
+
if action_name == 'index'
|
66
|
+
nil
|
67
|
+
else
|
68
|
+
super
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
77
72
|
def set_permalink_part
|
78
73
|
@permalink_part = @taxon.permalink.split('/').last
|
79
74
|
@parent_permalink = @taxon.permalink.split('/')[0...-1].join('/')
|
@@ -84,28 +79,18 @@ module Spree
|
|
84
79
|
params.require(:taxon).permit(permitted_taxon_attributes)
|
85
80
|
end
|
86
81
|
|
87
|
-
def load_taxon
|
88
|
-
@taxon = @taxonomy.taxons.find(params[:id])
|
89
|
-
end
|
90
|
-
|
91
|
-
def load_taxonomy
|
92
|
-
@taxonomy = if defined?(SpreeGlobalize)
|
93
|
-
scope.includes(:translations, taxons: [:translations]).find(params[:taxonomy_id])
|
94
|
-
else
|
95
|
-
scope.find(params[:taxonomy_id])
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
82
|
def set_position
|
100
83
|
new_position = params[:taxon][:position]
|
101
84
|
@taxon.child_index = new_position.to_i if new_position
|
102
85
|
end
|
103
86
|
|
104
87
|
def set_parent(parent_id)
|
105
|
-
@taxon.parent = current_store.taxons.find(parent_id
|
88
|
+
@taxon.parent = current_store.taxons.find(parent_id) if parent_id
|
106
89
|
end
|
107
90
|
|
108
91
|
def set_permalink_params
|
92
|
+
set_permalink_part
|
93
|
+
|
109
94
|
if params.key? 'permalink_part'
|
110
95
|
params[:taxon][:permalink] = @parent_permalink + params[:permalink_part]
|
111
96
|
end
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
flash[:success] = flash_message_for(@user, :successfully_created)
|
16
16
|
redirect_to spree.edit_admin_user_path(@user)
|
17
17
|
else
|
18
|
-
render :new
|
18
|
+
render :new, status: :unprocessable_entity
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
flash[:success] = Spree.t(:account_updated)
|
30
30
|
redirect_to spree.edit_admin_user_path(@user)
|
31
31
|
else
|
32
|
-
render :edit
|
32
|
+
render :edit, status: :unprocessable_entity
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -39,9 +39,10 @@ module Spree
|
|
39
39
|
params[:user][:ship_address_attributes][:user_id] = @user.id if params[:user][:ship_address_attributes].present?
|
40
40
|
if @user.update(user_params)
|
41
41
|
flash.now[:success] = Spree.t(:account_updated)
|
42
|
+
redirect_to spree.addresses_admin_user_path(@user)
|
43
|
+
else
|
44
|
+
render :addresses, status: :unprocessable_entity
|
42
45
|
end
|
43
|
-
|
44
|
-
render :addresses
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -61,20 +62,6 @@ module Spree
|
|
61
62
|
@orders = @search.result.page(params[:page])
|
62
63
|
end
|
63
64
|
|
64
|
-
def generate_api_key
|
65
|
-
if @user.generate_spree_api_key!
|
66
|
-
flash[:success] = Spree.t('api.key_generated')
|
67
|
-
end
|
68
|
-
redirect_to spree.edit_admin_user_path(@user)
|
69
|
-
end
|
70
|
-
|
71
|
-
def clear_api_key
|
72
|
-
if @user.clear_spree_api_key!
|
73
|
-
flash[:success] = Spree.t('api.key_cleared')
|
74
|
-
end
|
75
|
-
redirect_to spree.edit_admin_user_path(@user)
|
76
|
-
end
|
77
|
-
|
78
65
|
def model_class
|
79
66
|
Spree.user_class
|
80
67
|
end
|
@@ -86,7 +73,7 @@ module Spree
|
|
86
73
|
|
87
74
|
@collection = super
|
88
75
|
@search = @collection.ransack(params[:q])
|
89
|
-
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_users_per_page])
|
76
|
+
@collection = @search.result.page(params[:page]).per(Spree::Backend::Config[:admin_users_per_page])
|
90
77
|
end
|
91
78
|
|
92
79
|
private
|
@@ -40,8 +40,7 @@ module Spree
|
|
40
40
|
return @collection if @collection.present?
|
41
41
|
|
42
42
|
params[:q] ||= {}
|
43
|
-
@deleted = params.
|
44
|
-
|
43
|
+
@deleted = params[:q].delete(:deleted_at_null) || '0'
|
45
44
|
@collection = super
|
46
45
|
@collection = @collection.deleted if @deleted == '1'
|
47
46
|
# @search needs to be defined as this is passed to search_link
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class WebhooksSubscribersController < ResourceController
|
4
|
+
create.before :process_subscriptions
|
5
|
+
update.before :process_subscriptions
|
6
|
+
|
7
|
+
def index
|
8
|
+
params[:q] ||= {}
|
9
|
+
params[:q][:s] ||= 'created_at desc'
|
10
|
+
|
11
|
+
search = Webhooks::Subscriber.ransack(params[:q])
|
12
|
+
@webhooks_subscribers = search.result.
|
13
|
+
includes(:events).
|
14
|
+
page(params[:page]).
|
15
|
+
per(params[:per_page])
|
16
|
+
end
|
17
|
+
|
18
|
+
def show
|
19
|
+
@webhooks_subscriber = Webhooks::Subscriber.find(params[:id])
|
20
|
+
@events = @webhooks_subscriber.events.order(created_at: :desc).page(params[:page]).per(params[:per_page])
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def resource
|
26
|
+
@resource ||= Spree::Admin::Resource.new 'spree/admin/webhooks/subscribers', 'subscribers', nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_subscriptions
|
30
|
+
params[:webhooks_subscriber][:subscriptions] = if params[:subscribe_to_all_events] == 'true'
|
31
|
+
['*']
|
32
|
+
else
|
33
|
+
selected_events
|
34
|
+
end
|
35
|
+
|
36
|
+
params[:webhooks_subscriber] = params[:webhooks_subscriber].except(*supported_events.keys)
|
37
|
+
end
|
38
|
+
|
39
|
+
def selected_events
|
40
|
+
supported_events.select { |resource, _events| params[:webhooks_subscriber][resource] == 'true' }.values.flatten
|
41
|
+
end
|
42
|
+
|
43
|
+
def supported_events
|
44
|
+
@supported_events ||= Spree::Webhooks::Subscriber.supported_events
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -23,7 +23,7 @@ module Spree
|
|
23
23
|
|
24
24
|
def field_container(model, method, options = {}, &block)
|
25
25
|
css_classes = options[:class].to_a
|
26
|
-
css_classes << '
|
26
|
+
css_classes << 'form-group'
|
27
27
|
css_classes << 'withError' if error_message_on(model, method).present?
|
28
28
|
content_tag(
|
29
29
|
:div, capture(&block),
|
@@ -237,18 +237,28 @@ module Spree
|
|
237
237
|
end
|
238
238
|
|
239
239
|
def product_preview_link(product)
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
)
|
240
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
241
|
+
Admin::BaseHelper#product_preview_link is deprecated and will be removed in Spree 5.0. - Use Admin::BaseHelper#external_page_preview_link
|
242
|
+
DEPRECATION
|
243
|
+
|
244
|
+
external_page_preview_link(product)
|
245
245
|
end
|
246
246
|
|
247
247
|
def taxon_preview_link(taxon)
|
248
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
249
|
+
Admin::BaseHelper#taxon_preview_link is deprecated and will be removed in Spree 5.0. - Use Admin::BaseHelper#external_page_preview_link
|
250
|
+
DEPRECATION
|
251
|
+
|
252
|
+
external_page_preview_link(taxon)
|
253
|
+
end
|
254
|
+
|
255
|
+
def external_page_preview_link(resource, options = {})
|
256
|
+
resource_name = options[:name] || resource.class.name.demodulize
|
257
|
+
|
248
258
|
button_link_to(
|
249
|
-
Spree.t(:
|
250
|
-
spree_storefront_resource_url(
|
251
|
-
class: 'btn-outline-secondary', icon: 'view.svg', id:
|
259
|
+
Spree.t('admin.utilities.preview', name: resource_name ),
|
260
|
+
spree_storefront_resource_url(resource),
|
261
|
+
class: 'btn-outline-secondary', icon: 'view.svg', id: "adminPreview#{resource_name}", target: :blank, data: { turbo: false }
|
252
262
|
)
|
253
263
|
end
|
254
264
|
|
@@ -285,6 +295,14 @@ module Spree
|
|
285
295
|
'default'
|
286
296
|
end
|
287
297
|
end
|
298
|
+
|
299
|
+
def product_wysiwyg_editor_enabled?
|
300
|
+
Spree::Backend::Config[:product_wysiwyg_editor_enabled]
|
301
|
+
end
|
302
|
+
|
303
|
+
def taxon_wysiwyg_editor_enabled?
|
304
|
+
Spree::Backend::Config[:taxon_wysiwyg_editor_enabled]
|
305
|
+
end
|
288
306
|
end
|
289
307
|
end
|
290
308
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
module DigitalHelper
|
4
|
+
def asset_icon(asset)
|
5
|
+
file_name = case asset.attachment.content_type
|
6
|
+
when /pdf\z/
|
7
|
+
'file-earmark-pdf.svg'
|
8
|
+
when /\Aimage/
|
9
|
+
'file-earmark-image.svg'
|
10
|
+
when /zip\z/
|
11
|
+
'file-earmark-zip.svg'
|
12
|
+
when 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
13
|
+
'file-earmark-spreadsheet.svg'
|
14
|
+
when /\Avideo/
|
15
|
+
'file-earmark-play.svg'
|
16
|
+
when /\Aaudio/
|
17
|
+
'file-earmark-music.svg'
|
18
|
+
when /\Afont/
|
19
|
+
'file-earmark-font.svg'
|
20
|
+
else
|
21
|
+
'file-earmark.svg'
|
22
|
+
end
|
23
|
+
|
24
|
+
svg_icon name: file_name, width: 50, height: 50
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,27 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
module MenuHelper
|
4
|
-
def menu_item_bar(menu, item)
|
5
|
-
render 'spree/admin/menus/nested_menu_items/item_bar', menu: menu, item: item
|
6
|
-
end
|
7
|
-
|
8
|
-
def build_menu_item(menu, item)
|
9
|
-
decendents = []
|
10
|
-
|
11
|
-
unless item.leaf?
|
12
|
-
item.children.each do |child_item|
|
13
|
-
decendents << build_menu_item(menu, child_item) unless item.leaf?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
info_row = menu_item_bar(menu, item)
|
18
|
-
menu_container = content_tag(:div, raw(decendents.join), class: 'menu-container', data: { parent_id: item.id })
|
19
|
-
|
20
|
-
content_tag(:div, info_row + menu_container,
|
21
|
-
class: 'menu-item menu-container-item dragable removable-dom-element',
|
22
|
-
data: { item_id: item.id })
|
23
|
-
end
|
24
|
-
|
25
4
|
def default_menu_for_store?(menu)
|
26
5
|
menu.store.default_locale == menu.locale
|
27
6
|
end
|