mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#19135: Fixing menu item hirerachies deletion
Work Item: 19135 --HG-- branch : 1.x
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
@@ -117,13 +118,22 @@ namespace Orchard.Core.Navigation.Controllers {
|
|||||||
if (menuPart != null) {
|
if (menuPart != null) {
|
||||||
menuId = menuPart.Menu.Id;
|
menuId = menuPart.Menu.Id;
|
||||||
|
|
||||||
// if the menu item is a concrete content item, don't delete it, just unreference the menu
|
// get all sub-menu items from the same menu
|
||||||
if (!menuPart.ContentItem.TypeDefinition.Settings.ContainsKey("Stereotype") || menuPart.ContentItem.TypeDefinition.Settings["Stereotype"] != "MenuItem") {
|
var menuItems = _menuService.GetMenuParts(menuPart.Menu.Id)
|
||||||
menuPart.Menu = null;
|
.Where(x => x.MenuPosition.StartsWith(menuPart.MenuPosition + "."))
|
||||||
}
|
.Select(x => x.As<MenuPart>())
|
||||||
else {
|
.ToList();
|
||||||
_menuService.Delete(menuPart);
|
|
||||||
|
foreach (var menuItem in menuItems.Concat(new [] {menuPart})) {
|
||||||
|
// if the menu item is a concrete content item, don't delete it, just unreference the menu
|
||||||
|
if (!menuPart.ContentItem.TypeDefinition.Settings.ContainsKey("Stereotype") || menuPart.ContentItem.TypeDefinition.Settings["Stereotype"] != "MenuItem") {
|
||||||
|
menuPart.Menu = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_menuService.Delete(menuItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index", new { menuId });
|
return RedirectToAction("Index", new { menuId });
|
||||||
|
Reference in New Issue
Block a user