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 @@
|
|||||||
@{
|
@using Orchard.Core.Shapes
|
||||||
var tabs = ((IEnumerable<string>)Model.Tabs).ToList();
|
@{
|
||||||
|
var tabs = (IEnumerable<string>)CoreShapes.HarvestAndSortTabs(Model.Content);
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
Display.LocalNavigation(Tabs: tabs);
|
Display.LocalNavigation(Tabs: tabs);
|
||||||
}
|
}
|
||||||
<div class="edit-item">
|
<div class="edit-item">
|
||||||
@@ -19,11 +12,6 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="edit-item-secondary group">
|
<div class="edit-item-secondary group">
|
||||||
@if (Model.Actions != null) {
|
|
||||||
<div class="edit-item-actions">
|
|
||||||
@Display(Model.Actions)
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (Model.Sidebar != null) {
|
@if (Model.Sidebar != null) {
|
||||||
<div class="edit-item-sidebar group">
|
<div class="edit-item-sidebar group">
|
||||||
@Display(Model.Sidebar)
|
@Display(Model.Sidebar)
|
||||||
@@ -31,6 +19,11 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@if (Model.Actions != null) {
|
||||||
|
<div class="edit-item-actions">
|
||||||
|
@Display(Model.Actions)
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@if (!String.IsNullOrWhiteSpace(Request.QueryString["returnUrl"])) {
|
@if (!String.IsNullOrWhiteSpace(Request.QueryString["returnUrl"])) {
|
||||||
@Html.Hidden("returnUrl", Request.QueryString["returnUrl"])
|
@Html.Hidden("returnUrl", Request.QueryString["returnUrl"])
|
||||||
|
|||||||
@@ -345,6 +345,30 @@ namespace Orchard.Core.Shapes {
|
|||||||
return ordering.Select(ordered => ordered.item).ToList();
|
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]
|
[Shape]
|
||||||
public void HeadScripts(dynamic Display, TextWriter Output) {
|
public void HeadScripts(dynamic Display, TextWriter Output) {
|
||||||
WriteResources(Display, Output, "script", ResourceLocation.Head, null);
|
WriteResources(Display, Output, "script", ResourceLocation.Head, null);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
|
|
||||||
private void ApplyImplementation(BuildShapeContext context, string displayType) {
|
private void ApplyImplementation(BuildShapeContext context, string displayType) {
|
||||||
var placement = context.FindPlacement(_shapeType, _differentiator, _defaultLocation);
|
var placement = context.FindPlacement(_shapeType, _differentiator, _defaultLocation);
|
||||||
if (string.IsNullOrEmpty(placement.Location) || placement.Location == "-")
|
if (String.IsNullOrEmpty(placement.Location) || placement.Location == "-")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Parse group placement.
|
// Parse group placement.
|
||||||
@@ -37,7 +37,7 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
_groupId = group;
|
_groupId = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.Equals(context.GroupId ?? "", _groupId ?? "", StringComparison.OrdinalIgnoreCase))
|
if (!String.Equals(context.GroupId ?? "", _groupId ?? "", StringComparison.OrdinalIgnoreCase))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dynamic parentShape = context.Shape;
|
dynamic parentShape = context.Shape;
|
||||||
@@ -65,19 +65,7 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
newShapeMetadata.DisplayType = displayType;
|
newShapeMetadata.DisplayType = displayType;
|
||||||
newShapeMetadata.PlacementSource = placement.Source;
|
newShapeMetadata.PlacementSource = placement.Source;
|
||||||
newShapeMetadata.Tab = placement.GetTab();
|
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 a specific shape is provided, remove all previous alternates and wrappers.
|
||||||
if (!String.IsNullOrEmpty(placement.ShapeType)) {
|
if (!String.IsNullOrEmpty(placement.ShapeType)) {
|
||||||
newShapeMetadata.Type = placement.ShapeType;
|
newShapeMetadata.Type = placement.ShapeType;
|
||||||
|
|||||||
Reference in New Issue
Block a user