Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add flash error message if the menu_item move is not saved.

Matthew Kennedy7af8684b06fd
diff --git a/backend/app/assets/javascripts/spree/backend/navigation/menu.es6 b/backend/app/assets/javascripts/spree/backend/navigation/menu.es6
index 98a5c58f4e..13db609b81 100644
--- a/backend/app/assets/javascripts/spree/backend/navigation/menu.es6
+++ b/backend/app/assets/javascripts/spree/backend/navigation/menu.es6
@@ -43,9 +43,16 @@ function handleMenuItemMove(evt, successCallback) {
body: JSON.stringify(data)
})
.then(response => {
- console.log(response);
+ if (response.ok !== true) {
+ handleMenuItemMoveError(response)
+ }
})
.catch(err => {
console.error(err);
});
}
+
+function handleMenuItemMoveError (response) {
+ // eslint-disable-next-line no-undef
+ show_flash('error', Spree.translations.move_could_not_be_saved)
+}
diff --git a/backend/app/views/spree/admin/shared/_translations.html.erb b/backend/app/views/spree/admin/shared/_translations.html.erb
index 5660015af2..54ccb87ad8 100644
--- a/backend/app/views/spree/admin/shared/_translations.html.erb
+++ b/backend/app/views/spree/admin/shared/_translations.html.erb
@@ -18,6 +18,7 @@
month_names: I18n.t(:month_names, scope: :date).instance_eval {|o|
o.try(:reject, &:blank?) || o},
more: Spree.t(:more),
+ move_could_not_be_saved: Spree.t('admin.navigation.move_could_not_be_saved'),
name: Spree.t(:name),
new_taxon: Spree.t(:new_taxon),
next: Spree.t(:next),
diff --git a/backend/config/routes.rb b/backend/config/routes.rb
index 615897a1d4..1b7dc93147 100644
--- a/backend/config/routes.rb
+++ b/backend/config/routes.rb
@@ -189,7 +189,7 @@ Spree::Core::Engine.add_routes do
end
resources :menus do
- resources :menu_items
+ resources :menu_items, except: :index
end
end
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 82415a1c7c..91d55f116d 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -586,6 +586,7 @@ en:
link_settings: Link Settings
link_to: Link To
image_asset: Add a Promotion image or Link icon.
+ move_could_not_be_saved: 'ERROR: This move could not be saved.'
new_menu_item: New Menu Item
new_menu: New Menu
nested_under: Nested under