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.

Update nested set.

Matthew Kennedy0f4c27dc1e5a
diff --git a/backend/app/helpers/spree/admin/menu_helper.rb b/backend/app/helpers/spree/admin/menu_helper.rb
index 9a21f272a8..24a8c34370 100644
--- a/backend/app/helpers/spree/admin/menu_helper.rb
+++ b/backend/app/helpers/spree/admin/menu_helper.rb
@@ -19,7 +19,8 @@ module Spree
end
def menu_item_that_accepts_nested_items(menu, item)
- decendents = build_menu_item(menu, item.descendants[0]) unless item.leaf?
+
+ decendents = build_menu_item(menu, item.children[0]) unless item.leaf?
info_row = menu_item_bar(menu, item)
sub_menu_container = content_tag(:div, decendents, class: 'menu-container')
@@ -29,8 +30,7 @@ module Spree
def test(a, b)
- b.self_and_descendants.inspect
-
+ b.item.children[0]
end
end
end
diff --git a/backend/app/views/spree/admin/menu_items/_form.html.erb b/backend/app/views/spree/admin/menu_items/_form.html.erb
index 19c96695c1..67821854b2 100644
--- a/backend/app/views/spree/admin/menu_items/_form.html.erb
+++ b/backend/app/views/spree/admin/menu_items/_form.html.erb
@@ -12,14 +12,6 @@
<%= f.error_message_on :item_type %>
<% end %>
- <%= f.field_container :container do %>
- <div class="custom-control custom-checkbox">
- <%= f.check_box :container, class: 'custom-control-input' %>
- <%= f.label :container, Spree.t('admin.navigation.allow_this_menu_item_to_contain_nested_menu_items'), class: 'custom-control-label' %>
- <%= f.error_message_on :container %>
- </div>
- <% end %>
-
<div class="alert alert-info mt-3 mb-0">
<%= raw Spree.t('admin.navigation.menu_item_type_message') %>
</div>
diff --git a/backend/app/views/spree/admin/menus/edit.html.erb b/backend/app/views/spree/admin/menus/edit.html.erb
index 72f96fa998..c447f8c32d 100644
--- a/backend/app/views/spree/admin/menus/edit.html.erb
+++ b/backend/app/views/spree/admin/menus/edit.html.erb
@@ -21,8 +21,6 @@
</div>
</div>
-
-
<div id="menuArea">
<div class="row mt-5">
<div class="col-12">
@@ -40,12 +38,16 @@
<div class="card-body p-0 bg-light" >
<div id="primaryMenuContainer" class="menu-container">
- <% nested_set_options(@menu.menu_items) do |item| %>
- <% if item.root? %>
- <%= build_menu_item(@menu, item) %>
- <%= test(@menu, item) %>
- <% end %>
+ <%# nested_set_options(@menu.menu_items) do |item| %>
+ <%# if item.root? %>
+ <%#= build_menu_item(@menu, item) %>
+ <%# end %>
+ <%# end %>
+
+ <% @menu.menu_items.each_with_level(@menu.menu_items.root.self_and_descendants) do |item, level| %>
+ <%= build_menu_item(@menu, item) %>
<% end %>
+
</div>
</div>
</div>
@@ -53,3 +55,13 @@
</div>
</div>
+
+<% nested_set_options(@menu.menu_items) do |item| %>
+ <%= "L:#{item.level} NAME:#{item.name}" %>
+<% end %>
+
+
+<br>
+<% @menu.menu_items.each_with_level(@menu.menu_items.root.self_and_descendants) do |item, level| %>
+ <%= "L:#{item.level} NAME:#{item.name}" %>
+<% end %>
diff --git a/core/db/migrate/20210408092939_create_spree_menu_items.rb b/core/db/migrate/20210408092939_create_spree_menu_items.rb
index 759b08b95d..424af8a55f 100644
--- a/core/db/migrate/20210408092939_create_spree_menu_items.rb
+++ b/core/db/migrate/20210408092939_create_spree_menu_items.rb
@@ -6,7 +6,6 @@ class CreateSpreeMenuItems < ActiveRecord::Migration[6.0]
t.column :url, :string
t.column :new_window, :boolean, default: false
t.column :item_type, :string
- t.column :container, :boolean, default: false
t.column :linked_resource_type, :string, default: 'URL'
t.column :linked_resource_id, :integer
t.column :parent_id, :integer