mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -44,16 +44,19 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to create a content type.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if(String.IsNullOrWhiteSpace(viewModel.DisplayName)) {
|
||||
ModelState.AddModelError("DisplayName", T("The Content Type name can't be empty.").ToString());
|
||||
viewModel.DisplayName = viewModel.DisplayName ?? String.Empty;
|
||||
viewModel.Name = viewModel.Name ?? String.Empty;
|
||||
|
||||
if (String.IsNullOrWhiteSpace(viewModel.DisplayName)) {
|
||||
ModelState.AddModelError("DisplayName", T("The Display Name name can't be empty.").ToString());
|
||||
}
|
||||
|
||||
if ( _contentDefinitionService.GetTypes().Any(t => String.Equals(t.Name.Trim(), viewModel.Name.Trim(), StringComparison.OrdinalIgnoreCase)) ) {
|
||||
ModelState.AddModelError("Name", T("A type with the same technical name already exists.").ToString());
|
||||
ModelState.AddModelError("Name", T("A type with the same Id already exists.").ToString());
|
||||
}
|
||||
|
||||
if ( _contentDefinitionService.GetTypes().Any(t => String.Equals(t.DisplayName.Trim(), viewModel.DisplayName.Trim(), StringComparison.OrdinalIgnoreCase)) ) {
|
||||
ModelState.AddModelError("DisplayName", T("A type with the same name already exists.").ToString());
|
||||
ModelState.AddModelError("DisplayName", T("A type with the same Name already exists.").ToString());
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<fieldset>
|
||||
<label for="DisplayName">@T("Display Name")</label>
|
||||
@Html.TextBoxFor(m => m.DisplayName, new {@class = "textMedium", autofocus = "autofocus"})
|
||||
<label for="Name">@T("Technical Name")</label>
|
||||
<label for="Name">@T("Content Type Id")</label>
|
||||
@Html.TextBoxFor(m => m.Name, new {@class = "text"})
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<label for="DisplayName">@T("Display Name")</label>
|
||||
@Html.TextBoxFor(m => m.DisplayName, new { @class = "textMedium" }) @T("Technical name: {0}", Model.Name)
|
||||
@Html.TextBoxFor(m => m.DisplayName, new { @class = "textMedium" })
|
||||
<span class="hint">@T("Content Type Id: {0}", Model.Name)</span>
|
||||
@* todo: if we continue to go down the midrodata route, some helpers would be nice *@
|
||||
<meta itemprop="DisplayName" content="@Model.DisplayName" />
|
||||
@* has unintended consequences (renamging the type) - changing the name creates a new type of that name *@
|
||||
<meta itemprop="Name" content="@Model.Name" />
|
||||
<meta itemprop="Id" content="@Model.Name" />
|
||||
@Html.HiddenFor(m => m.Name)
|
||||
</fieldset>
|
||||
@{ Html.RenderTemplates(Model.Templates); }
|
||||
|
||||
@@ -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