forked from OrchardCMS/OrchardCore
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menu item #1003
Closed
+5
−3
Closed
Menu item #1003
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
728554a
Update src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminCont…
hishamco a3d66b4
Merge branch 'main' into hishamco/menu-item
hishamco 45993ea
Address feedback
hishamco 662b9f6
Rewrite menu removal to use JsonDynamicObject.
sarahelsaig 3c404d2
Merge branch 'hishamco/menu-item' into menu-item
sarahelsaig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
using OrchardCore.DisplayManagement.ModelBinding; | ||
using OrchardCore.DisplayManagement.Notify; | ||
using OrchardCore.Menu.Models; | ||
using System.Text.Json.Dynamic; | ||
using YesSql; | ||
|
||
namespace OrchardCore.Menu.Controllers | ||
|
@@ -270,7 +271,7 @@ public async Task<IActionResult> Delete(string menuContentItemId, string menuIte | |
return NotFound(); | ||
} | ||
|
||
var menuContentAsJson = (JsonObject)menu.Content; | ||
var menuContentAsJson = (JsonDynamicObject)menu.Content; | ||
// Look for the target menu item in the hierarchy. | ||
var menuItem = FindMenuItem(menuContentAsJson, menuItemId); | ||
|
||
|
@@ -280,8 +281,9 @@ public async Task<IActionResult> Delete(string menuContentItemId, string menuIte | |
return NotFound(); | ||
} | ||
|
||
var menuItems = menuContentAsJson[nameof(MenuItemsListPart)]["MenuItems"] as JsonArray; | ||
menuItems.Remove(menuItem); | ||
var menuItemsListPart = menuContentAsJson[nameof(MenuItemsListPart)] as JsonDynamicObject; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the original code |
||
var menuItems = menuItemsListPart?[nameof(MenuItemsListPart.MenuItems)] as JsonDynamicArray; | ||
menuItems?.Remove(menuItem); | ||
|
||
await _contentManager.SaveDraftAsync(menu); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not need , see :
OrchardCore/src/OrchardCore/OrchardCore.Abstractions/Json/Dynamic/JsonDynamicObject.cs
Lines 162 to 164 in 7aab0f0