mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Correcting Part editing
- http://orchardqa.codeplex.com/workitem/102 --HG-- branch : dev
This commit is contained in:
@@ -80,6 +80,10 @@
|
||||
<Compile Include="Services\IContentDefinitionService.cs" />
|
||||
<Compile Include="ViewModels\AddFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\CreatePartViewModel.cs" />
|
||||
<Compile Include="ViewModels\EditFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\EditPartFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\EditPartViewModel.cs" />
|
||||
<Compile Include="ViewModels\EditTypePartViewModel.cs" />
|
||||
<Compile Include="ViewModels\ListContentPartsViewModel.cs" />
|
||||
<Compile Include="ViewModels\RemoveFieldViewModel.cs" />
|
||||
<Compile Include="ViewModels\RemovePartViewModel.cs" />
|
||||
|
@@ -0,0 +1,16 @@
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
|
||||
namespace Orchard.ContentTypes.ViewModels {
|
||||
|
||||
public class EditFieldViewModel {
|
||||
public EditFieldViewModel() { }
|
||||
|
||||
public EditFieldViewModel(ContentFieldDefinition contentFieldDefinition) {
|
||||
Name = contentFieldDefinition.Name;
|
||||
_Definition = contentFieldDefinition;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public ContentFieldDefinition _Definition { get; private set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
|
||||
namespace Orchard.ContentTypes.ViewModels {
|
||||
public class EditPartFieldViewModel {
|
||||
|
||||
public EditPartFieldViewModel() {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditPartFieldViewModel(int index, ContentPartFieldDefinition field) {
|
||||
Index = index;
|
||||
Name = field.Name;
|
||||
FieldDefinition = new EditFieldViewModel(field.FieldDefinition);
|
||||
Settings = field.Settings;
|
||||
_Definition = field;
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
public string Prefix { get { return "Fields[" + Index + "]"; } }
|
||||
public EditPartViewModel Part { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public EditFieldViewModel FieldDefinition { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public ContentPartFieldDefinition _Definition { get; private set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.ContentTypes.Extensions;
|
||||
|
||||
namespace Orchard.ContentTypes.ViewModels {
|
||||
public class EditPartViewModel {
|
||||
public EditPartViewModel() {
|
||||
Fields = new List<EditPartFieldViewModel>();
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditPartViewModel(ContentPartDefinition contentPartDefinition) {
|
||||
Name = contentPartDefinition.Name;
|
||||
Fields = contentPartDefinition.Fields.Select((f, i) => new EditPartFieldViewModel(i, f) { Part = this }).ToList();
|
||||
Settings = contentPartDefinition.Settings;
|
||||
_Definition = contentPartDefinition;
|
||||
}
|
||||
|
||||
public string Prefix { get { return "PartDefinition"; } }
|
||||
public string Name { get; set; }
|
||||
private string _displayName;
|
||||
public string DisplayName {
|
||||
get { return !string.IsNullOrWhiteSpace(_displayName) ? _displayName : Name.TrimEnd("Part").CamelFriendly(); }
|
||||
set { _displayName = value; }
|
||||
}
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public IEnumerable<EditPartFieldViewModel> Fields { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public ContentPartDefinition _Definition { get; private set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
|
||||
namespace Orchard.ContentTypes.ViewModels {
|
||||
public class EditTypePartViewModel {
|
||||
public EditTypePartViewModel() {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditTypePartViewModel(int index, ContentTypePartDefinition part) {
|
||||
Index = index;
|
||||
PartDefinition = new EditPartViewModel(part.PartDefinition);
|
||||
Settings = part.Settings;
|
||||
_Definition = part;
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
public string Prefix { get { return "Parts[" + Index + "]"; } }
|
||||
public EditPartViewModel PartDefinition { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public EditTypeViewModel Type { get; set; }
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public ContentTypePartDefinition _Definition { get; private set; }
|
||||
}
|
||||
}
|
@@ -3,8 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.ContentTypes.Extensions;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.ContentTypes.ViewModels {
|
||||
public class EditTypeViewModel {
|
||||
@@ -46,87 +44,4 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
}
|
||||
}
|
||||
|
||||
public class EditTypePartViewModel {
|
||||
public EditTypePartViewModel() {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditTypePartViewModel(int index, ContentTypePartDefinition part) {
|
||||
Index = index;
|
||||
PartDefinition = new EditPartViewModel(part.PartDefinition);
|
||||
Settings = part.Settings;
|
||||
_Definition = part;
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
public string Prefix { get { return "Parts[" + Index + "]"; } }
|
||||
public EditPartViewModel PartDefinition { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public EditTypeViewModel Type { get; set; }
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public ContentTypePartDefinition _Definition { get; private set; }
|
||||
}
|
||||
|
||||
public class EditPartViewModel {
|
||||
public EditPartViewModel() {
|
||||
Fields = new List<EditPartFieldViewModel>();
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditPartViewModel(ContentPartDefinition contentPartDefinition) {
|
||||
Name = contentPartDefinition.Name;
|
||||
Fields = contentPartDefinition.Fields.Select((f, i) => new EditPartFieldViewModel(i, f) { Part = this }).ToList();
|
||||
Settings = contentPartDefinition.Settings;
|
||||
_Definition = contentPartDefinition;
|
||||
}
|
||||
|
||||
public string Prefix { get { return "PartDefinition"; } }
|
||||
public string Name { get; set; }
|
||||
private string _displayName;
|
||||
public string DisplayName {
|
||||
get { return !string.IsNullOrWhiteSpace(_displayName) ? _displayName : Name.TrimEnd("Part").CamelFriendly(); }
|
||||
set { _displayName = value; }
|
||||
}
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public IEnumerable<EditPartFieldViewModel> Fields { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public ContentPartDefinition _Definition { get; private set; }
|
||||
}
|
||||
|
||||
public class EditPartFieldViewModel {
|
||||
|
||||
public EditPartFieldViewModel() {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditPartFieldViewModel(int index, ContentPartFieldDefinition field) {
|
||||
Index = index;
|
||||
Name = field.Name;
|
||||
FieldDefinition = new EditFieldViewModel(field.FieldDefinition);
|
||||
Settings = field.Settings;
|
||||
_Definition = field;
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
public string Prefix { get { return "Fields[" + Index + "]"; } }
|
||||
public EditPartViewModel Part { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public EditFieldViewModel FieldDefinition { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public ContentPartFieldDefinition _Definition { get; private set; }
|
||||
}
|
||||
|
||||
public class EditFieldViewModel {
|
||||
public EditFieldViewModel() { }
|
||||
|
||||
public EditFieldViewModel(ContentFieldDefinition contentFieldDefinition) {
|
||||
Name = contentFieldDefinition.Name;
|
||||
_Definition = contentFieldDefinition;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public ContentFieldDefinition _Definition { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
@model Orchard.ContentTypes.ViewModels.EditPartViewModel
|
||||
@{ Style.Require("ContentTypesAdmin"); }
|
||||
|
||||
<h1>@Html.TitleForPage(T("Edit Part").ToString())</h1>
|
||||
<p class="breadcrumb">@Html.ActionLink(T("Content Types").Text, "index")@T(" > ")@Html.ActionLink(T("Content Parts").Text, "listparts")@T(" > ")@T("Edit Part")</p>
|
||||
@@ -6,19 +7,30 @@
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<label for="Name">@T("Name")</label>
|
||||
@* has unintended consequences (renamging the part) - changing the name creates a new part of that name *@
|
||||
@* has unintended consequences (renaming the part) - changing the name creates a new part of that name *@
|
||||
@Html.TextBoxFor(m => m.Name, new {@class = "textMedium", disabled = "disabled"})
|
||||
@Html.HiddenFor(m => m.Name)
|
||||
</fieldset>
|
||||
<div class="manage-part">
|
||||
<div class="settings">
|
||||
@DisplayChildren(Model.Templates)
|
||||
@{ Html.RenderTemplates(Model.Templates); }
|
||||
</div>
|
||||
<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>
|
||||
@DisplayChildren(Model.Fields)
|
||||
@Html.EditorFor(m => m.Fields, "Fields", "")
|
||||
</div>
|
||||
<fieldset class="action">
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
@using(Script.Foot()){
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
(function ($) {
|
||||
$(".manage-field h3,.manage-part h3").expandoControl(function (controller) { return controller.nextAll(".details"); }, { collapse: true, remember: false });
|
||||
$(".manage-field h4").expandoControl(function (controller) { return controller.nextAll(".settings"); }, { collapse: true, remember: false });
|
||||
})(jQuery);
|
||||
//]]>
|
||||
</script>
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
@model 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 class="settings">@{Html.RenderTemplates(Model.Templates);}
|
||||
</div>}
|
||||
@Html.HiddenFor(m => m.Name)@Html.HiddenFor(m => m.FieldDefinition.Name)@Html.HiddenFor(m => m.Index)
|
||||
</fieldset>
|
Reference in New Issue
Block a user