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:
@@ -136,6 +136,55 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
return RedirectToAction("Index");
|
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
|
#endregion
|
||||||
|
|
||||||
#region Content
|
#region Content
|
||||||
|
|||||||
@@ -55,6 +55,22 @@ namespace Orchard.Core.Contents.Services {
|
|||||||
throw new NotImplementedException();
|
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
|
//gratuitously stolen from the RoutableService
|
||||||
private static string GenerateTypeName(string displayName) {
|
private static string GenerateTypeName(string displayName) {
|
||||||
if (string.IsNullOrWhiteSpace(displayName))
|
if (string.IsNullOrWhiteSpace(displayName))
|
||||||
|
|||||||
@@ -8,5 +8,10 @@ namespace Orchard.Core.Contents.Services {
|
|||||||
void AddTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
void AddTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
||||||
void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
void AlterTypeDefinition(ContentTypeDefinition contentTypeDefinition);
|
||||||
void RemoveTypeDefinition(string name);
|
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 SettingsDictionary Settings { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EditPartViewModel {
|
public class EditPartViewModel : BaseViewModel {
|
||||||
public EditPartViewModel() {
|
public EditPartViewModel() {
|
||||||
Fields = new List<EditPartFieldViewModel>();
|
Fields = new List<EditPartFieldViewModel>();
|
||||||
Settings = new SettingsDictionary();
|
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>
|
<fieldset>
|
||||||
<label for="DisplayName"><%:T("Display Name") %></label>
|
<label for="DisplayName"><%:T("Display Name") %></label>
|
||||||
<%:Html.TextBoxFor(m => m.DisplayName, new {@class = "textMedium"}) %>
|
<%: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>
|
<label for="Name"><%:T("Name") %></label>
|
||||||
<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>
|
<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<%:Html.EditorFor(m => m.Settings) %>
|
<%:Html.EditorFor(m => m.Settings) %>
|
||||||
<h2><%:T("Parts") %></h2>
|
<h2><%:T("Parts") %></h2>
|
||||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddPart", new { }, new { @class = "button" })%></div>
|
<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>
|
<h2><%:T("Fields") %></h2>
|
||||||
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddField", new { }, new { @class = "button" })%></div>
|
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddField", new { }, new { @class = "button" })%></div>
|
||||||
<%--<%:Html.EditorFor(m => m.Fields, "ContentTypeFields")%>--%>
|
<%--<%: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()) { %>
|
if (Model.Any()) { %>
|
||||||
<fieldset><%
|
<fieldset>
|
||||||
|
<legend><%:T("Settings for this content type") %></legend><%
|
||||||
var si = 0;
|
var si = 0;
|
||||||
foreach (var setting in Model) {
|
foreach (var setting in Model) {
|
||||||
var s = setting;
|
var s = setting;
|
||||||
|
|||||||
@@ -11,11 +11,12 @@
|
|||||||
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
|
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
|
||||||
<% } %> --%>
|
<% } %> --%>
|
||||||
</div>
|
</div>
|
||||||
<%--
|
<%:Html.EditorFor(m => m.Settings, "Settings", "") %><%
|
||||||
what is this settings for?
|
if (Model.PartDefinition.Settings.Any()) { %>
|
||||||
<%:Html.EditorFor(m => m.PartDefinition.Settings, "Settings") %>--%>
|
<h4><%:T("Tenant-wide settings") %></h4>
|
||||||
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>
|
<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.EditorFor(m => m.PartDefinition.Fields, "FieldsOnPart") %>
|
||||||
<%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
|
<%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
|
||||||
<%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -6,7 +6,7 @@ if (Model.Any()) { %>
|
|||||||
foreach (var part in Model) {
|
foreach (var part in Model) {
|
||||||
var p = part;
|
var p = part;
|
||||||
var htmlFieldName = string.Format("Parts[{0}]", pi++); %>
|
var htmlFieldName = string.Format("Parts[{0}]", pi++); %>
|
||||||
<%:Html.EditorFor(m => p, "Part", htmlFieldName) %><%
|
<%:Html.EditorFor(m => p, "Type.Part", htmlFieldName) %><%
|
||||||
} %>
|
} %>
|
||||||
</fieldset><%
|
</fieldset><%
|
||||||
} %>
|
} %>
|
||||||
@@ -215,6 +215,7 @@
|
|||||||
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextContentField.ascx" />
|
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextContentField.ascx" />
|
||||||
<Content Include="Contents\Module.txt" />
|
<Content Include="Contents\Module.txt" />
|
||||||
<Content Include="Contents\Styles\admin.css" />
|
<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\EditType.ascx" />
|
||||||
<Content Include="Contents\Views\Admin\CreateType.ascx" />
|
<Content Include="Contents\Views\Admin\CreateType.ascx" />
|
||||||
<Content Include="Contents\Views\Admin\Types.ascx" />
|
<Content Include="Contents\Views\Admin\Types.ascx" />
|
||||||
@@ -224,11 +225,12 @@
|
|||||||
<Content Include="Contents\Views\Admin\Create.aspx" />
|
<Content Include="Contents\Views\Admin\Create.aspx" />
|
||||||
<Content Include="Contents\Views\DisplayTemplates\ContentTypeDefinition.ascx" />
|
<Content Include="Contents\Views\DisplayTemplates\ContentTypeDefinition.ascx" />
|
||||||
<Content Include="Contents\Views\DisplayTemplates\Items\Contents.Item.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\Settings.ascx" />
|
||||||
<Content Include="Contents\Views\EditorTemplates\FieldsOnPart.ascx" />
|
<Content Include="Contents\Views\EditorTemplates\FieldsOnPart.ascx" />
|
||||||
<Content Include="Contents\Views\EditorTemplates\FieldOnPart.ascx" />
|
<Content Include="Contents\Views\EditorTemplates\FieldOnPart.ascx" />
|
||||||
<Content Include="Contents\Views\EditorTemplates\Parts.ascx" />
|
<Content Include="Contents\Views\EditorTemplates\Type.Parts.ascx" />
|
||||||
<Content Include="Contents\Views\EditorTemplates\Part.ascx" />
|
<Content Include="Contents\Views\EditorTemplates\Type.Part.ascx" />
|
||||||
<Content Include="Contents\Views\EditorTemplates\Items\Contents.Item.ascx" />
|
<Content Include="Contents\Views\EditorTemplates\Items\Contents.Item.ascx" />
|
||||||
<Content Include="Contents\Views\Item\Preview.aspx" />
|
<Content Include="Contents\Views\Item\Preview.aspx" />
|
||||||
<Content Include="Contents\Views\Item\Display.aspx" />
|
<Content Include="Contents\Views\Item\Display.aspx" />
|
||||||
|
|||||||
Reference in New Issue
Block a user