Fixing widget layer editing and tidying up the widget management index template.

work item: 16837

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-24 23:31:49 -08:00
parent a7a6067497
commit 5e1a3cb3ac
6 changed files with 137 additions and 18 deletions

View File

@@ -33,18 +33,21 @@ namespace Orchard.Widgets.Drivers {
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {
if(updater.TryUpdateModel(layerPart, Prefix, null, null)) {
if ( String.IsNullOrWhiteSpace(layerPart.LayerRule) ) {
if (String.IsNullOrWhiteSpace(layerPart.LayerRule)) {
layerPart.LayerRule = "true";
}
if ( _widgetsService.GetLayers().Any(l => String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
if (_widgetsService.GetLayers()
.Any(l =>
l.Id != layerPart.Id
&& String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
updater.AddModelError("Name", T("A Layer with the same name already exists"));
}
try {
_ruleManager.Matches(layerPart.LayerRule);
}
catch ( Exception e ) {
catch (Exception e) {
updater.AddModelError("Description", T("The rule is not valid: {0}", e.Message));
}
}

View File

@@ -52,21 +52,16 @@
<div class="widgets-layers">
<ul>
@foreach (var layer in Model.Layers) {
var layerClass = "widgets-editLayer";
if (layer.Id == Model.CurrentLayer.Id) {
<li class="widgets-currentLayer widgets-editLayer">
<a href="@Url.Action("EditLayer", new { @layer.Id })">
<img width="15" height="15" src="@Url.Content("~/modules/orchard.widgets/Content/Admin/images/edit.png")" />
</a>
@Html.ActionLink(@layer.Name, "Index", new { @layer.Id })
</li>
} else {
<li class="widgets-editLayer">
<a href="@Url.Action("EditLayer", new { @layer.Id })">
<img width="15" height="15" src="@Url.Content("~/modules/orchard.widgets/Content/Admin/images/edit.png")" />
</a>
@Html.ActionLink(@layer.Name, "Index", new { @layer.Id })
</li>
layerClass += " widgets-currentLayer";
}
<li class="@layerClass">
<a href="@Url.Action("EditLayer", new { @layer.Id })" title="@T("Edit {0} layer", layer.Name)">
<img width="15" height="15" src="@Url.Content("~/modules/orchard.widgets/Content/Admin/images/edit.png")" />
</a>
@Html.ActionLink(@layer.Name, "Index", new { @layer.Id })
</li>
}
</ul>
<div class="new-layer">