mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -283,7 +283,7 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
#region Parts
|
||||
|
||||
public ActionResult EditPart(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||
@@ -300,7 +300,7 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
|
||||
[HttpPost, ActionName("EditPart")]
|
||||
public ActionResult EditPartPOST(EditPartViewModel viewModel) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(viewModel.Name);
|
||||
@@ -323,7 +323,7 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult AddFieldTo(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||
@@ -347,7 +347,7 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
|
||||
[HttpPost, ActionName("AddFieldTo")]
|
||||
public ActionResult AddFieldToPOST(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var viewModel = new AddFieldViewModel();
|
||||
@@ -391,6 +391,50 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
return RedirectToAction("EditPart", new { id });
|
||||
}
|
||||
|
||||
|
||||
public ActionResult RemoveFieldFrom(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||
|
||||
var viewModel = new RemoveFieldViewModel();
|
||||
if (contentPartDefinition == null
|
||||
|| !TryUpdateModel(viewModel)
|
||||
|| !contentPartDefinition.Fields.Any(p => p.Name == viewModel.Name))
|
||||
return new NotFoundResult();
|
||||
|
||||
viewModel.Part = new EditPartViewModel { Name = contentPartDefinition.Name };
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("RemoveFieldFrom")]
|
||||
public ActionResult RemoveFieldFromPOST(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a content part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||
|
||||
var viewModel = new RemoveFieldViewModel();
|
||||
if (contentPartDefinition == null
|
||||
|| !TryUpdateModel(viewModel)
|
||||
|| !contentPartDefinition.Fields.Any(p => p.Name == viewModel.Name))
|
||||
return new NotFoundResult();
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
viewModel.Part = new EditPartViewModel { Name = contentPartDefinition.Name };
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
_contentDefinitionManager.AlterPartDefinition(id, typeBuilder => typeBuilder.RemoveField(viewModel.Name));
|
||||
Services.Notifier.Information(T("The \"{0}\" field has been removed.", viewModel.Name));
|
||||
|
||||
if (_contentDefinitionService.GetTypeDefinition(id) != null)
|
||||
return RedirectToAction("Edit", new { id });
|
||||
|
||||
return RedirectToAction("EditPart", new { id });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
class Updater : IUpdateModel {
|
||||
|
@@ -77,6 +77,7 @@
|
||||
<Compile Include="Services\ContentDefinitionService.cs" />
|
||||
<Compile Include="Services\IContentDefinitionService.cs" />
|
||||
<Compile Include="ViewModels\AddFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\RemoveFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\RemovePartViewModel.cs" />
|
||||
<Compile Include="ViewModels\CreateTypeViewModel.cs" />
|
||||
<Compile Include="ViewModels\EditTypeViewModel.cs" />
|
||||
@@ -88,6 +89,7 @@
|
||||
<Content Include="Styles\admin.css" />
|
||||
<Content Include="Views\Admin\AddFieldTo.ascx" />
|
||||
<Content Include="Views\Admin\AddPartsTo.ascx" />
|
||||
<Content Include="Views\Admin\RemoveFieldFrom.ascx" />
|
||||
<Content Include="Views\Admin\RemovePartFrom.ascx" />
|
||||
<Content Include="Views\Admin\Create.ascx" />
|
||||
<Content Include="Views\Admin\EditPart.ascx" />
|
||||
@@ -97,10 +99,12 @@
|
||||
<Content Include="Views\DisplayTemplates\Field.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Fields.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Settings.ascx" />
|
||||
<Content Include="Views\EditorTemplates\TypePartField.ascx" />
|
||||
<Content Include="Views\EditorTemplates\TypePartFields.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Field.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Fields.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Part.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts.ascx" />
|
||||
<Content Include="Views\EditorTemplates\TypePart.ascx" />
|
||||
<Content Include="Views\EditorTemplates\TypeParts.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Settings.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Web.Debug.config">
|
||||
|
@@ -1,13 +1,24 @@
|
||||
.contents #main h2 {
|
||||
margin:1.5em 0 .5em;
|
||||
.orchard-contenttypes #main h2 {
|
||||
margin:1.5em 0 0;
|
||||
}
|
||||
.manage.add-to-type {
|
||||
margin-top:-4em;
|
||||
margin-top:-3.1em;
|
||||
}
|
||||
|
||||
.manage-part {
|
||||
margin-bottom:2em;
|
||||
}
|
||||
.manage-part h3,
|
||||
.manage-field h3 {
|
||||
border-bottom:1px solid #EAEAEA;
|
||||
padding-top:0;
|
||||
}
|
||||
.manage-part h3,
|
||||
.manage-field h3,
|
||||
.manage-part .manage-field,
|
||||
.manage-field fieldset,
|
||||
.manage-part .settings {
|
||||
padding-left:20px;
|
||||
}
|
||||
.manage-part .manage,
|
||||
.manage-field .manage {
|
||||
@@ -15,12 +26,27 @@
|
||||
margin-top:-2.4em;
|
||||
}
|
||||
.manage-part .manage.minor {
|
||||
margin-top:-1.7em;
|
||||
margin:0 0 -1.2em;
|
||||
}
|
||||
.manage-part label,
|
||||
.manage-field label {
|
||||
font-weight:normal;
|
||||
}
|
||||
.manage-part fieldset {
|
||||
margin:1.5em 0 0;
|
||||
padding:0;
|
||||
}
|
||||
.manage-field .settings {
|
||||
margin:-1.5em 0 0 1em;
|
||||
padding-left:0;
|
||||
}
|
||||
.manage-part .settings fieldset {
|
||||
padding-left:0;
|
||||
}
|
||||
|
||||
fieldset.action {
|
||||
margin-top:2em;
|
||||
}
|
||||
|
||||
/* should pull this back into the base admin theme css, w/out the .manage-part of course */
|
||||
.manage-part dl {
|
||||
@@ -28,8 +54,16 @@
|
||||
overflow:auto;
|
||||
padding:6px 0 0;
|
||||
}
|
||||
.manage-part dt {
|
||||
font-weight:bold;
|
||||
.manage-part dt,
|
||||
.manage-part dd {
|
||||
display:inline;
|
||||
}
|
||||
.manage-part dt::after {
|
||||
content:":";
|
||||
}
|
||||
.manage-part dd {
|
||||
font-style:italic;
|
||||
padding-left:.5em;
|
||||
}
|
||||
.manage-part dl dl {
|
||||
font-size:1em;
|
||||
|
@@ -0,0 +1,8 @@
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentTypes.ViewModels {
|
||||
public class RemoveFieldViewModel : BaseViewModel {
|
||||
public string Name { get; set; }
|
||||
public EditPartViewModel Part { get; set; }
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@
|
||||
%><h1><%:Html.TitleForPage(T("Edit Content Type").ToString())%></h1>
|
||||
<p class="breadcrumb"><%:Html.ActionLink(T("Content Types").Text, "index") %><%:T(" > ") %><%:T("Edit Content Type") %></p><%
|
||||
using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%--//todo: come up with real itemtype definitions and locations for said definitions--%>
|
||||
<%--// todo: come up with real itemtype definitions and locations for said definitions--%>
|
||||
<div itemscope itemid="<%:Model.Name %>" itemtype="http://orchardproject.net/data/ContentType"><%:Html.ValidationSummary() %>
|
||||
<fieldset>
|
||||
<label for="DisplayName"><%:T("Display Name") %></label>
|
||||
@@ -19,11 +19,11 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
Html.RenderTemplates(Model.Templates); %>
|
||||
<h2><%:T("Parts") %></h2>
|
||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddPartsTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" })%></div><%:
|
||||
Html.EditorFor(m => m.Parts, "Parts", "") %>
|
||||
Html.EditorFor(m => m.Parts, "TypeParts", "") %>
|
||||
<h2><%:T("Fields") %></h2>
|
||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" }) %></div><%:
|
||||
Html.EditorFor(m => m.Fields, "Fields", "") %>
|
||||
<fieldset>
|
||||
<fieldset class="action">
|
||||
<button class="primaryAction" type="submit"><%:T("Save") %></button>
|
||||
</fieldset>
|
||||
</div><%
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditPartViewModel>" %>
|
||||
<%
|
||||
Html.RegisterStyle("admin.css"); %>
|
||||
<h1><%:Html.TitleForPage(T("Edit Part").ToString()) %></h1><%
|
||||
<h1><%:Html.TitleForPage(T("Edit Part").ToString()) %></h1>
|
||||
<p class="breadcrumb"><%:Html.ActionLink(T("Content Types").Text, "index") %><%:T(" > ") %><%:T("Edit Part") %></p><%
|
||||
using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%:Html.ValidationSummary() %>
|
||||
<fieldset>
|
||||
@@ -13,7 +14,7 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<h2><%:T("Fields") %></h2>
|
||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Orchard.ContentTypes", id = Model.Name }, new { @class = "button" }) %></div>
|
||||
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
|
||||
<fieldset>
|
||||
<fieldset class="action">
|
||||
<button class="primaryAction" type="submit"><%:T("Save") %></button>
|
||||
</fieldset><%
|
||||
} %>
|
||||
|
@@ -0,0 +1,11 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.RemoveFieldViewModel>" %>
|
||||
<%
|
||||
Html.RegisterStyle("admin.css"); %>
|
||||
<h1><%:Html.TitleForPage(T("Remove the \"{0}\" part from \"{1}\"", Model.Name, Model.Part.Name).ToString())%></h1><%
|
||||
using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<p><%:T("Looks like you couldn't use the fancy way to remove the field. Try hitting the button below to force the issue.") %></p>
|
||||
<fieldset>
|
||||
<%=Html.HiddenFor(m => m.Name) %>
|
||||
<button class="primaryAction" type="submit"><%:T("Remove") %></button>
|
||||
</fieldset><%
|
||||
} %>
|
@@ -2,7 +2,7 @@
|
||||
<%@ import Namespace="Orchard.ContentManagement.MetaData.Models" %>
|
||||
<%
|
||||
if (Model.Any()) { %>
|
||||
<dl><%
|
||||
<dl class="settings"><%
|
||||
foreach (var setting in Model) { %>
|
||||
<dt><%:setting.Key %></dt>
|
||||
<dd><%:setting.Value %></dd><%
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<fieldset class="manage-field">
|
||||
<h3><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></h3>
|
||||
<div class="manage">
|
||||
<%:Html.Link("[remove]", "#forshowonlyandnotintendedtowork!") %>
|
||||
<%:Html.ActionLink(T("Remove").Text, "RemoveFieldFrom", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }, new { itemprop = "RemoveUrl UnsafeUrl" })%><%--// <- some experimentation--%>
|
||||
</div><%
|
||||
Html.RenderTemplates(Model.Templates); %>
|
||||
<%:Html.HiddenFor(m => m.Name) %><%:Html.HiddenFor(m => m.FieldDefinition.Name) %>
|
||||
|
@@ -4,10 +4,13 @@
|
||||
<div class="manage">
|
||||
<%:Html.ActionLink(T("Remove").Text, "RemovePartFrom", new { area = "Orchard.ContentTypes", id = Model.Type.Name, Model.PartDefinition.Name }, new { itemprop = "RemoveUrl UnsafeUrl" })%><%--// <- some experimentation--%>
|
||||
</div><%
|
||||
if (Model.Templates.Any()) { %>
|
||||
<div class="settings"><%
|
||||
Html.RenderTemplates(Model.Templates); %>
|
||||
<h4><%:T("Global configuration") %></h4>
|
||||
<div class="manage minor"><%:Html.ActionLink(T("Edit").Text, "EditPart", new { area = "Orchard.ContentTypes", id = Model.PartDefinition.Name }) %></div>
|
||||
</div><%
|
||||
} %>
|
||||
<div class="manage minor"><%:Html.ActionLink(T("Edit global part config").Text, "EditPart", new { area = "Orchard.ContentTypes", id = Model.PartDefinition.Name })%></div>
|
||||
<%:Html.DisplayFor(m => m.PartDefinition.Settings, "Settings", "PartDefinition")
|
||||
%><%:Html.EditorFor(m => m.PartDefinition.Fields, "Fields", "PartDefinition")
|
||||
%><%:Html.EditorFor(m => m.PartDefinition.Fields, "TypePartFields", "PartDefinition")
|
||||
%><%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
|
||||
</fieldset>
|
@@ -0,0 +1,10 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>" %>
|
||||
<fieldset class="manage-field">
|
||||
<h4><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></h4><%
|
||||
if (Model.Templates.Any()) { %>
|
||||
<div class="settings"><%
|
||||
Html.RenderTemplates(Model.Templates); %>
|
||||
</div><%
|
||||
} %>
|
||||
<%:Html.HiddenFor(m => m.Name) %><%:Html.HiddenFor(m => m.FieldDefinition.Name) %>
|
||||
</fieldset>
|
@@ -0,0 +1,10 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Orchard.ContentTypes.ViewModels.EditPartFieldViewModel>>" %>
|
||||
<%
|
||||
if (Model.Any()) {
|
||||
var fi = 0;
|
||||
foreach (var field in Model) {
|
||||
var f = field;
|
||||
var htmlFieldName = string.Format("Fields[{0}]", fi++); %>
|
||||
<%:Html.EditorFor(m => f, "TypePartField", htmlFieldName) %><%
|
||||
}
|
||||
} %>
|
@@ -6,7 +6,7 @@ if (Model.Any()) { %>
|
||||
foreach (var part in Model) {
|
||||
var p = part;
|
||||
var htmlFieldName = string.Format("Parts[{0}]", pi++); %>
|
||||
<%:Html.EditorFor(m => p, "Part", htmlFieldName) %><%
|
||||
<%:Html.EditorFor(m => p, "TypePart", htmlFieldName) %><%
|
||||
} %>
|
||||
</fieldset><%
|
||||
} %>
|
Reference in New Issue
Block a user