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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Update view.
Matthew Kennedyac5b5fb762d6
diff --git a/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6 b/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6index f114212e51..c47ae531f3 100644--- a/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6+++ b/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6@@ -1,8 +1,9 @@document.addEventListener('DOMContentLoaded', function() {- $('#LinkToSelect2').select2()+ $('#menu_item_linked_resource_type').select2()+ $('#menu_item_item_type').select2()- $('#LinkToSelect2').on('change', function() {- const selectedLinkTo = $('#LinkToSelect2').val()+ $('#menu_item_linked_resource_type').on('change', function() {+ const selectedLinkTo = $('#menu_item_linked_resource_type').val()const message = document.getElementById('alertToClickUpdate')const activePanel = document.getElementById('linkResourcePanel')const panelType = activePanel.dataset.panelType@@ -21,4 +22,24 @@ document.addEventListener('DOMContentLoaded', function() {message.classList.add('d-block')}});++ updateContainerMessage()++ $('#menu_item_item_type').on('change', function() {+ updateContainerMessage()+ });++ function updateContainerMessage () {+ const selectedLinkType = $('#menu_item_item_type').val()+ const linkSettingsPanel = document.getElementById('LinkSettings')+ const usingConainerMessage = document.getElementById('usingContainerInfo')++ if (selectedLinkType === 'Container') {+ linkSettingsPanel.classList.add('d-none')+ usingConainerMessage.classList.remove('d-none')+ } else {+ linkSettingsPanel.classList.remove('d-none')+ usingConainerMessage.classList.add('d-none')+ }+ }})diff --git a/backend/app/views/spree/admin/menu_items/_form.html.erb b/backend/app/views/spree/admin/menu_items/_form.html.erbindex 4605f8116f..cfd10ff29b 100644--- a/backend/app/views/spree/admin/menu_items/_form.html.erb+++ b/backend/app/views/spree/admin/menu_items/_form.html.erb@@ -8,7 +8,7 @@<div class="card-body"><%= f.field_container :item_type, class: ['form-group'] do %><%= f.label :item_type, Spree.t('admin.navigation.item_type') %>- <%= f.select(:item_type, @menu_item_types, {include_blank: false}, { class: 'select2' }) %>+ <%= f.select(:item_type, @menu_item_types, {include_blank: false}) %><%= f.error_message_on :item_type %><% end %>@@ -30,12 +30,12 @@</small><% end %>- <hr>-- <div class="alert alert-info mt-3 mb-0">- <%= raw Spree.t('admin.navigation.menu_item_type_message') %>+ <div class="d-none" id="usingContainerInfo">+ <hr>+ <div class="alert alert-info mt-3 mb-0">+ <%= raw Spree.t('admin.navigation.menu_item_type_container_message') %>+ </div></div>-</div></div></div>@@ -70,6 +70,7 @@<%= f.error_message_on :image_asset %><% end %><% end %>+</div></div></div>@@ -77,36 +78,44 @@<div class="row"><div class="col-12">- <div class="card mb-3">- <div class="card-header">- <h5 class="mb-0"><%= Spree.t('admin.navigation.link_settings') %></h5>- </div>- <div class="card-body">- <div class="row">- <div class="col-6">- <%= f.field_container :linked_resource_type, class: ['form-group'] do %>- <%= f.label :linked_resource_type, Spree.t('admin.navigation.link_to') %>- <%= f.select(:linked_resource_type, @linked_resource_types, {include_blank: false}, { class: 'selec2', id: 'LinkToSelect2' }) %>- <%= f.error_message_on :linked_resource_type %>- <% end %>- </div>- <div class="col-6">- <%= render 'link_input', linked_resource_type: @menu_item.linked_resource_type, f: f %>+ <div id="LinkSettings">+ <div class="card mb-3">+ <div class="card-header">+ <h5 class="mb-0"><%= Spree.t('admin.navigation.link_settings') %></h5>+ </div>+ <div class="card-body">+ <div class="row">+ <div class="col-6">+ <%= f.field_container :linked_resource_type, class: ['form-group'] do %>+ <%= f.label :linked_resource_type, Spree.t('admin.navigation.link_to') %>+ <%= f.select(:linked_resource_type, @linked_resource_types, {include_blank: false}) %>+ <%= f.error_message_on :linked_resource_type %>+ <% end %>+ </div>+ <div class="col-6">- <div id="alertToClickUpdate" class="d-none">- <div class="alert alert-warning mt-3">- <% if %w[new create].include? controller.action_name %>- <%= raw Spree.t('admin.navigation.click_create_to_load_new_link') %>- <% else %>- <%= raw Spree.t('admin.navigation.click_update_to_load_new_link') %>- <% end %>+ <%= render 'link_input', linked_resource_type: @menu_item.linked_resource_type, f: f %>++ <div id="alertToClickUpdate" class="d-none">+ <div class="alert alert-warning mt-3">+ <% if %w[new create].include? controller.action_name %>+ <%= raw Spree.t('admin.navigation.click_create_to_load_new_link') %>+ <% else %>+ <%= raw Spree.t('admin.navigation.click_update_to_load_new_link') %>+ <% end %>+ </div></div></div></div></div></div></div>+ <div class="d-none" id="usingContainerInfo">+ <div class="alert alert-info mt-3 mb-0">+ <%= raw Spree.t('admin.navigation.menu_item_type_container_message') %>+ </div>+ </div></div></div></div>diff --git a/core/app/models/spree/app_configuration.rb b/core/app/models/spree/app_configuration.rbindex fdffb4721b..434ee205b4 100644--- a/core/app/models/spree/app_configuration.rb+++ b/core/app/models/spree/app_configuration.rb@@ -76,9 +76,9 @@ module Spree@searcher_class ||= Spree::Core::Search::Baseend- # These are used if no frontend is being used.+ # These paths are used if Spree::Frontend is not being used.preference :api_product_path, :string, default: 'products'- preference :api_taxon_path, :string, default: 'categories'+ preference :api_taxon_path, :string, default: 'collection'attr_writer :searcher_classenddiff --git a/core/app/models/spree/menu_item.rb b/core/app/models/spree/menu_item.rbindex 84a6dcb6f1..5af6a7cfb1 100644--- a/core/app/models/spree/menu_item.rb+++ b/core/app/models/spree/menu_item.rb@@ -67,10 +67,12 @@ module Spreeenddef reset_link_attributes- if linked_resource_type_changed?+ if linked_resource_type_changed? || item_type == 'Container'self.linked_resource_id = nilself.destination = nilself.new_window = false++ self.linked_resource_type = 'URL' if item_type == 'Container'endenddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 95f34506c4..48ee35e3a7 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -596,6 +596,7 @@ en:open_link_in_new_window: Open this link in a new windowmenu_item_type_message: "For more information about Menu Item Types, Nesting and using Codes, visit the documentation by<a href='https://guides.spreecommerce.org/user/configuration/configuring_geography.html#zones' target='_blank' class='alert-link'>clicking here</a>."+ menu_item_type_container_message: "<b>Containers</b> are used to organize other Menu Items, such as Links, or Promotions into groups using the Menu Item code.<ul><li>Containers do not link to a location.</li></ul> To learn more, please see the <a href='https://guides.spreecommerce.org/user/configuration/configuring_geography.html#zones' target='_blank' class='alert-link'>documentation</a>."menus: Menusmenu_items: '%{menu_name} Items'public_details: Public Details