Part II of the previous checkin.

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2011-03-25 11:26:38 -07:00
parent 9cc26b20cc
commit 7106068dc8
5 changed files with 78 additions and 39 deletions

View File

@@ -158,6 +158,9 @@
<ItemGroup>
<Content Include="Views\WidgetLayerVisibility.cshtml" />
</ItemGroup>
<ItemGroup>
<None Include="Views\WidgetPlacement.Zones.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -35,21 +35,36 @@ margin-left:10px;
#widgets-zones, #widgets-available {
background:#F3F4F5;
border:1px solid #E4E5E6;
padding:0 5px;
padding:5px;
}
#widgets-zones-orphans {
margin-top:40px;
}
#widgets-zones-orphans p {
margin-bottom:10px;
}
/* The number seems slightly meaningless. Leaving it out for now. * /
#widgets-zones ol {
list-style:decimal inside;
}
*/
#widgets-zones ol {
}
#widgets-zones li, #widgets-available li {
background:#FFF;
color:#AEC3CE;
border:1px solid #EAEAEA;
margin:5px 0;
margin:0 0 5px;
padding:0 10px;
position:relative;
}
#widgets-available li {
margin:5px 0;
}
#widgets-zones li.last {
margin:0;
}
#widgets-zones li:hover, #widgets-zones li.on {
border-color:#bfd3a7;
}

View File

@@ -5,7 +5,7 @@
<div id="widgets" class="group">
@Display.WidgetLayersControl(Layers: Model.Layers, CurrentLayer: Model.CurrentLayer)
<div id="layout-widgets-placement">
@Display.WidgetPlacement(Widgets: Model.Widgets, Zones: Model.Zones, CurrentLayer: Model.CurrentLayer)
@Display.WidgetPlacement(Widgets: Model.Widgets, Zones: Model.Zones, OrphanZones: Model.OrphanZones, CurrentLayer: Model.CurrentLayer)
</div>
<div id="layout-widgets-assistance">
<div id="widgets-assistance">

View File

@@ -0,0 +1,44 @@
@using Orchard.Utility.Extensions;
@using Orchard.Widgets.Models;
@{
Style.Require("WidgetsAdmin");
IEnumerable<WidgetPart> widgets = Model.Widgets;
IEnumerable<string> zones = Model.Zones;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}
<ol>
@foreach (string zone in zones) {
int count = widgets.Where(w => w.Zone == zone).Count();
MvcHtmlString classAttr = null;
if (count == 0) {
classAttr = new MvcHtmlString(" class=\"widgets-none\"");
}
<li@(classAttr)>
<h2>@zone</h2>
<div class="widgets-actions">@Html.ActionLink(T("Add").Text, "ChooseWidget", new { layerId = Model.CurrentLayer.Id, zone, returnUrl }, new { @class = "button grey" })</div>
<ul class="widgets-zone-widgets">
@if (count > 0) {
int i = 0;
foreach (WidgetPart widget in widgets.Where(w => w.Zone == zone).OrderBy(w => w.Position, new Orchard.UI.FlatPositionComparer())) {
<li class="widgets-@(widget.LayerId == Model.CurrentLayer.Id ? "this" : "other")-layer widgets-layer-@widget.LayerId@(i == 0 ? " first" : (i == count ? " last" : ""))">
<h3>@Html.ActionLink(HasText(widget.Title) ? widget.Title : widget.TypeDefinition.DisplayName, "EditWidget", new { @widget.Id, returnUrl })</h3>
<div class="widgets-actions">
@if (widget.LayerId != Model.CurrentLayer.Id) {
<button name="moveHere" value="@widget.Id" class="link" type="submit">@T("Move to current layer")</button>
}
else { /* it could be useful to remove the widget regardless of the layer it's on but there's no place in the current UI for this and "Move to current layer" */
<button name="moveOut" value="@widget.Id" class="link" type="submit">@T("Remove")</button>
}
</div>
<div class="widgets-move-somewhere">
<button name="moveUp" value="@widget.Id" @(i == 0 ? "disabled='disabled'" : "") class="widgets-move widgets-move-up" type="submit" title="@T("Move up")">@T("Move up")</button>
<button name="moveDown" value="@widget.Id" @(++i == count ? "disabled='disabled'" : "") class="widgets-move widgets-move-down" type="submit" title="@T("Move down")">@T("Move down")</button>
@Html.Hidden("returnUrl", returnUrl)
</div>
</li>
}
}
</ul>
</li>
}
</ol>

View File

@@ -4,49 +4,26 @@
Style.Require("WidgetsAdmin");
IEnumerable<WidgetPart> widgets = Model.Widgets;
IEnumerable<string> zones = Model.Zones;
IEnumerable<string> orphanZones = Model.OrphanZones;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}
<div id="widgets-placement">
<div id="widgets-layers" class="widgets-container detail-view switchable">
<div id="widgets-zones">
@using (Html.BeginFormAntiForgeryPost()) {
<ol>
@foreach (string zone in zones) {
int count = widgets.Where(w => w.Zone == zone).Count();
MvcHtmlString classAttr = null;
if (count == 0) {
classAttr = new MvcHtmlString(" class=\"widgets-none\"");
}
<li@(classAttr)>
<h2>@zone</h2>
<div class="widgets-actions">@Html.ActionLink(T("Add").Text, "ChooseWidget", new { layerId = Model.CurrentLayer.Id, zone, returnUrl }, new { @class = "button grey" })</div>
<ul class="widgets-zone-widgets">
@if (count > 0) {
int i = 0;
foreach (WidgetPart widget in widgets.Where(w => w.Zone == zone).OrderBy(w => w.Position, new Orchard.UI.FlatPositionComparer())) {
<li class="widgets-@(widget.LayerId == Model.CurrentLayer.Id ? "this" : "other")-layer widgets-layer-@widget.LayerId">
<h3>@Html.ActionLink(HasText(widget.Title) ? widget.Title : widget.TypeDefinition.DisplayName, "EditWidget", new { @widget.Id, returnUrl })</h3>
<div class="widgets-actions">
@if (widget.LayerId != Model.CurrentLayer.Id) {
<button name="moveHere" value="@widget.Id" class="link" type="submit">@T("Move to current layer")</button>
}
else { /* it could be useful to remove the widget regardless of the layer it's on but there's no place in the current UI for this and "Move to current layer" */
<button name="moveOut" value="@widget.Id" class="link" type="submit">@T("Remove")</button>
}
</div>
<div class="widgets-move-somewhere">
<button name="moveUp" value="@widget.Id" @(i == 0 ? "disabled='disabled'" : "") class="widgets-move widgets-move-up" type="submit" title="@T("Move up")">@T("Move up")</button>
<button name="moveDown" value="@widget.Id" @(++i == count ? "disabled='disabled'" : "") class="widgets-move widgets-move-down" type="submit" title="@T("Move down")">@T("Move down")</button>
@Html.Hidden("returnUrl", returnUrl)
</div>
</li>
}
}
</ul>
</li>
}
</ol>
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.Zones, CurrentLayer: Model.CurrentLayer)
}
</div>
@if (orphanZones.Count() > 0) {
<div id="widgets-zones-orphans">
<h3>@T("Zones for other enabled themes.")</h3>
<p>@T("Widgets in these zones will not appear anywhere when your currently active theme is applied. They might still appear in selectively applied (e.g. mobile) themes.")</p>
<div id="widgets-zones">
@using (Html.BeginFormAntiForgeryPost()) {
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.OrphanZones, CurrentLayer: Model.CurrentLayer)
}
</div>
</div>
}
</div>
</div>