mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing widget layer editing and tidying up the widget management index template.
work item: 16837 --HG-- branch : dev
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
@@ -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">
|
||||
|
Reference in New Issue
Block a user