mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -136,6 +136,55 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult EditPart(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||
|
||||
if (contentPartDefinition == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
return View(new EditPartViewModel(contentPartDefinition));
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("EditPart")]
|
||||
public ActionResult EditPartPOST(string id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
|
||||
|
||||
if (contentPartDefinition == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var viewModel = new EditPartViewModel();
|
||||
TryUpdateModel(viewModel);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
return EditPart(id);
|
||||
}
|
||||
|
||||
//todo: apply the changes along the lines of but definately not resembling
|
||||
// for now this _might_ just get a little messy ->
|
||||
_contentDefinitionService.AlterPartDefinition(
|
||||
new ContentPartDefinition(
|
||||
viewModel.Name,
|
||||
viewModel.Fields.Select(
|
||||
f => new ContentPartDefinition.Field(
|
||||
new ContentFieldDefinition(f.FieldDefinition.Name),
|
||||
f.Name,
|
||||
f.Settings
|
||||
)
|
||||
),
|
||||
viewModel.Settings
|
||||
)
|
||||
);
|
||||
// little == lot
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Content
|
||||
|
@@ -55,6 +55,22 @@ namespace Orchard.Core.Contents.Services {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ContentPartDefinition GetPartDefinition(string name) {
|
||||
return _contentDefinitionManager.GetPartDefinition(name);
|
||||
}
|
||||
|
||||
public void AddPartDefinition(ContentPartDefinition contentPartDefinition) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void AlterPartDefinition(ContentPartDefinition contentPartDefinition) {
|
||||
_contentDefinitionManager.StorePartDefinition(contentPartDefinition);
|
||||
}
|
||||
|
||||
public void RemovePartDefinition(string name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//gratuitously stolen from the RoutableService
|
||||
private static string GenerateTypeName(string displayName) {
|
||||
if (string.IsNullOrWhiteSpace(displayName))
|
||||
|
@@ -8,5 +8,10 @@ namespace Orchard.Core.Contents.Services {
|
||||
void AddTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
||||
void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
||||
void RemoveTypeDefinition(string name);
|
||||
|
||||
ContentPartDefinition GetPartDefinition(string name);
|
||||
void AddPartDefinition(ContentPartDefinition contentPartDefinition);
|
||||
void AlterPartDefinition(ContentPartDefinition contentPartDefinition);
|
||||
void RemovePartDefinition(string name);
|
||||
}
|
||||
}
|
@@ -35,7 +35,7 @@ namespace Orchard.Core.Contents.ViewModels {
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
}
|
||||
|
||||
public class EditPartViewModel {
|
||||
public class EditPartViewModel : BaseViewModel {
|
||||
public EditPartViewModel() {
|
||||
Fields = new List<EditPartFieldViewModel>();
|
||||
Settings = new SettingsDictionary();
|
||||
|
19
src/Orchard.Web/Core/Contents/Views/Admin/EditPart.ascx
Normal file
19
src/Orchard.Web/Core/Contents/Views/Admin/EditPart.ascx
Normal file
@@ -0,0 +1,19 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditPartViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
|
||||
Html.RegisterStyle("admin.css"); %>
|
||||
<h1><%:Html.TitleForPage(T("Edit Part").ToString())%></h1><%
|
||||
using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%:Html.ValidationSummary() %>
|
||||
<%--// has unintended consequences (renamging the part) - changing the name creates a new part of that name--%>
|
||||
<fieldset>
|
||||
<label for="Name"><%:T("Name") %></label>
|
||||
<%--<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>--%>
|
||||
</fieldset>
|
||||
<%:Html.EditorFor(m => m.Settings, "Settings", "")%>
|
||||
<h2><%:T("Fields") %></h2>
|
||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddField", new { }, new { @class = "button" })%></div>
|
||||
<%--<%:Html.EditorFor(m => m.Fields, "ContentTypeFields")%>--%>
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit"><%:T("Save") %></button>
|
||||
</fieldset><%
|
||||
} %>
|
@@ -7,13 +7,14 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<fieldset>
|
||||
<label for="DisplayName"><%:T("Display Name") %></label>
|
||||
<%:Html.TextBoxFor(m => m.DisplayName, new {@class = "textMedium"}) %>
|
||||
<%--// has unintended consequences (renamging the type) - changing the name creates a new type of that name--%>
|
||||
<label for="Name"><%:T("Name") %></label>
|
||||
<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>
|
||||
</fieldset>
|
||||
<%:Html.EditorFor(m => m.Settings) %>
|
||||
<h2><%:T("Parts") %></h2>
|
||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddPart", new { }, new { @class = "button" })%></div>
|
||||
<%:Html.EditorFor(m => m.Parts, "Parts", "") %>
|
||||
<%:Html.EditorFor(m => m.Parts, "Type.Parts", "") %>
|
||||
<h2><%:T("Fields") %></h2>
|
||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddField", new { }, new { @class = "button" })%></div>
|
||||
<%--<%:Html.EditorFor(m => m.Fields, "ContentTypeFields")%>--%>
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SettingsDictionary>" %>
|
||||
<%@ import Namespace="Orchard.ContentManagement.MetaData.Models" %>
|
||||
<dl><%
|
||||
foreach (var setting in Model) { %>
|
||||
<dt><%:setting.Key %></dt>
|
||||
<dd><%:setting.Value %></dd><%
|
||||
} %>
|
||||
</dl>
|
@@ -1,6 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.ContentManagement.MetaData.Models.SettingsDictionary>" %><%
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SettingsDictionary>" %>
|
||||
<%@ import Namespace="Orchard.ContentManagement.MetaData.Models" %><%
|
||||
if (Model.Any()) { %>
|
||||
<fieldset><%
|
||||
<fieldset>
|
||||
<legend><%:T("Settings for this content type") %></legend><%
|
||||
var si = 0;
|
||||
foreach (var setting in Model) {
|
||||
var s = setting;
|
||||
|
@@ -11,11 +11,12 @@
|
||||
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
|
||||
<% } %> --%>
|
||||
</div>
|
||||
<%--
|
||||
what is this settings for?
|
||||
<%:Html.EditorFor(m => m.PartDefinition.Settings, "Settings") %>--%>
|
||||
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>
|
||||
<%:Html.EditorFor(m => m.Settings, "Settings", "") %><%
|
||||
if (Model.PartDefinition.Settings.Any()) { %>
|
||||
<h4><%:T("Tenant-wide settings") %></h4>
|
||||
<div class="manage"><%:Html.ActionLink(T("Edit part settings").Text, "EditPart", new { area = "Contents", id = Model.PartDefinition.Name }) %></div>
|
||||
<%:Html.DisplayFor(m => m.PartDefinition.Settings, "Settings", "PartDefinition") %><%
|
||||
} %>
|
||||
<%:Html.EditorFor(m => m.PartDefinition.Fields, "FieldsOnPart") %>
|
||||
<%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
|
||||
<%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
|
||||
</fieldset>
|
@@ -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, "Type.Part", htmlFieldName) %><%
|
||||
} %>
|
||||
</fieldset><%
|
||||
} %>
|
@@ -215,6 +215,7 @@
|
||||
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextContentField.ascx" />
|
||||
<Content Include="Contents\Module.txt" />
|
||||
<Content Include="Contents\Styles\admin.css" />
|
||||
<Content Include="Contents\Views\Admin\EditPart.ascx" />
|
||||
<Content Include="Contents\Views\Admin\EditType.ascx" />
|
||||
<Content Include="Contents\Views\Admin\CreateType.ascx" />
|
||||
<Content Include="Contents\Views\Admin\Types.ascx" />
|
||||
@@ -224,11 +225,12 @@
|
||||
<Content Include="Contents\Views\Admin\Create.aspx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\ContentTypeDefinition.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Items\Contents.Item.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Settings.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Settings.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\FieldsOnPart.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\FieldOnPart.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Parts.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Part.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Type.Parts.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Type.Part.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Items\Contents.Item.ascx" />
|
||||
<Content Include="Contents\Views\Item\Preview.aspx" />
|
||||
<Content Include="Contents\Views\Item\Display.aspx" />
|
||||
|
Reference in New Issue
Block a user