mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Simplified tabs harvesting and implemented sorting by shape position.
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
@{
|
||||
var tabs = ((IEnumerable<string>)Model.Tabs).ToList();
|
||||
|
||||
// If we have any tabs, make sure we have at least the Content tab and that it is the first one,
|
||||
// since that's where we will put antyhing else not part of a tab.
|
||||
if (tabs.Any()) {
|
||||
tabs.Remove("Content");
|
||||
tabs.Insert(0, "Content");
|
||||
}
|
||||
|
||||
@using Orchard.Core.Shapes
|
||||
@{
|
||||
var tabs = (IEnumerable<string>)CoreShapes.HarvestAndSortTabs(Model.Content);
|
||||
Display.LocalNavigation(Tabs: tabs);
|
||||
}
|
||||
<div class="edit-item">
|
||||
@@ -19,11 +12,6 @@
|
||||
}
|
||||
</div>
|
||||
<div class="edit-item-secondary group">
|
||||
@if (Model.Actions != null) {
|
||||
<div class="edit-item-actions">
|
||||
@Display(Model.Actions)
|
||||
</div>
|
||||
}
|
||||
@if (Model.Sidebar != null) {
|
||||
<div class="edit-item-sidebar group">
|
||||
@Display(Model.Sidebar)
|
||||
@@ -31,6 +19,11 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (Model.Actions != null) {
|
||||
<div class="edit-item-actions">
|
||||
@Display(Model.Actions)
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!String.IsNullOrWhiteSpace(Request.QueryString["returnUrl"])) {
|
||||
@Html.Hidden("returnUrl", Request.QueryString["returnUrl"])
|
||||
|
||||
@@ -345,6 +345,30 @@ namespace Orchard.Core.Shapes {
|
||||
return ordering.Select(ordered => ordered.item).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<string> HarvestAndSortTabs(IEnumerable<dynamic> shapes) {
|
||||
var orderedShapes = Order(shapes).ToArray();
|
||||
var tabs = new List<string>();
|
||||
|
||||
foreach (var shape in orderedShapes) {
|
||||
var tab = (string)shape.Metadata.Tab;
|
||||
|
||||
if (String.IsNullOrEmpty(tab))
|
||||
continue;
|
||||
|
||||
if(!tabs.Contains(tab))
|
||||
tabs.Add(tab);
|
||||
}
|
||||
|
||||
// If we have any tabs, make sure we have at least the Content tab and that it is the first one,
|
||||
// since that's where we will put anything else not part of a tab.
|
||||
if (tabs.Any()) {
|
||||
tabs.Remove("Content");
|
||||
tabs.Insert(0, "Content");
|
||||
}
|
||||
|
||||
return tabs;
|
||||
}
|
||||
|
||||
[Shape]
|
||||
public void HeadScripts(dynamic Display, TextWriter Output) {
|
||||
WriteResources(Display, Output, "script", ResourceLocation.Head, null);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
private void ApplyImplementation(BuildShapeContext context, string displayType) {
|
||||
var placement = context.FindPlacement(_shapeType, _differentiator, _defaultLocation);
|
||||
if (string.IsNullOrEmpty(placement.Location) || placement.Location == "-")
|
||||
if (String.IsNullOrEmpty(placement.Location) || placement.Location == "-")
|
||||
return;
|
||||
|
||||
// Parse group placement.
|
||||
@@ -37,7 +37,7 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
_groupId = group;
|
||||
}
|
||||
|
||||
if (!string.Equals(context.GroupId ?? "", _groupId ?? "", StringComparison.OrdinalIgnoreCase))
|
||||
if (!String.Equals(context.GroupId ?? "", _groupId ?? "", StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
dynamic parentShape = context.Shape;
|
||||
@@ -66,18 +66,6 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
newShapeMetadata.PlacementSource = placement.Source;
|
||||
newShapeMetadata.Tab = placement.GetTab();
|
||||
|
||||
// If a tab name is specified, add it to the list of tabs on the parent shape so it can render them.
|
||||
var tabs = (HashSet<string>)parentShape.Tabs;
|
||||
|
||||
if (tabs == null) {
|
||||
tabs = new HashSet<string>();
|
||||
parentShape.Tabs = tabs;
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(newShapeMetadata.Tab)) {
|
||||
tabs.Add(newShapeMetadata.Tab);
|
||||
}
|
||||
|
||||
// If a specific shape is provided, remove all previous alternates and wrappers.
|
||||
if (!String.IsNullOrEmpty(placement.ShapeType)) {
|
||||
newShapeMetadata.Type = placement.ShapeType;
|
||||
|
||||
Reference in New Issue
Block a user