mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#19095: Implementing Content Part Descriptions.
Work Item: 19095 --HG-- branch : 1.x extra : rebase_source : 910b3f365f4c9b6f69c8922e68639cce80010ed2
This commit is contained in:
@@ -6,11 +6,17 @@ namespace Orchard.Core.Contents.Extensions {
|
||||
public static ContentTypeDefinitionBuilder Creatable(this ContentTypeDefinitionBuilder builder, bool creatable = true) {
|
||||
return builder.WithSetting("ContentTypeSettings.Creatable", creatable.ToString());
|
||||
}
|
||||
|
||||
public static ContentTypeDefinitionBuilder Draftable(this ContentTypeDefinitionBuilder builder, bool draftable = true) {
|
||||
return builder.WithSetting("ContentTypeSettings.Draftable", draftable.ToString());
|
||||
}
|
||||
|
||||
public static ContentPartDefinitionBuilder Attachable(this ContentPartDefinitionBuilder builder, bool attachable = true) {
|
||||
return builder.WithSetting("ContentPartSettings.Attachable", attachable.ToString());
|
||||
}
|
||||
|
||||
public static ContentPartDefinitionBuilder Description(this ContentPartDefinitionBuilder builder, string description) {
|
||||
return builder.WithSetting("ContentPartSettings.Description", description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,7 @@
|
||||
/// This setting is used to display a Content Part in list of Parts to attach to a Content Type
|
||||
/// </summary>
|
||||
public bool Attachable { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
Type = typeViewModel,
|
||||
PartSelections = _contentDefinitionService.GetParts(false/*metadataPartsOnly*/)
|
||||
.Where(cpd => !typeViewModel.Parts.Any(p => p.PartDefinition.Name == cpd.Name) && cpd.Settings.GetModel<ContentPartSettings>().Attachable)
|
||||
.Select(cpd => new PartSelectionViewModel { PartName = cpd.Name, PartDisplayName = cpd.DisplayName })
|
||||
.Select(cpd => new PartSelectionViewModel { PartName = cpd.Name, PartDisplayName = cpd.DisplayName, PartDescription = cpd.Description})
|
||||
};
|
||||
|
||||
return View(viewModel);
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Orchard.ContentTypes.Settings {
|
||||
var model = new ContentPartSettings();
|
||||
updateModel.TryUpdateModel(model, "ContentPartSettings", null, null);
|
||||
builder.Attachable(model.Attachable);
|
||||
builder.Description(model.Description);
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@
|
||||
margin:0 0 0 15px;
|
||||
padding-left:0;
|
||||
}
|
||||
|
||||
.manage-part .description {
|
||||
color: #333;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.manage-part .settings {
|
||||
overflow:auto;
|
||||
}
|
||||
@@ -111,6 +117,13 @@ fieldset.action {
|
||||
padding-left:.5em;
|
||||
}
|
||||
|
||||
.available-parts .part.hint {
|
||||
display: block;
|
||||
margin-left: 29px;
|
||||
line-height: 16px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
|
||||
/* PLACEMENT EDITOR */
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
public class PartSelectionViewModel {
|
||||
public string PartName { get; set; }
|
||||
public string PartDisplayName { get; set; }
|
||||
public string PartDescription { get;set; }
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,19 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
|
||||
public string Prefix { get { return "PartDefinition"; } }
|
||||
public string Name { get; set; }
|
||||
|
||||
private string _displayName;
|
||||
[Required]
|
||||
public string DisplayName {
|
||||
get { return !string.IsNullOrWhiteSpace(_displayName) ? _displayName : Name.TrimEnd("Part").CamelFriendly(); }
|
||||
set { _displayName = value; }
|
||||
}
|
||||
|
||||
public string Description {
|
||||
get { return Settings.ContainsKey("ContentPartSettings.Description") ? Settings["ContentPartSettings.Description"] : null; }
|
||||
set { Settings["ContentPartSettings.Description"] = value;}
|
||||
}
|
||||
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public IEnumerable<EditPartFieldViewModel> Fields { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
|
||||
@@ -12,15 +12,21 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
Index = index;
|
||||
PartDefinition = new EditPartViewModel(part.PartDefinition);
|
||||
Settings = part.Settings;
|
||||
PartSettings = part.PartDefinition.Settings;
|
||||
_Definition = part;
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
public string Prefix { get { return "Parts[" + Index + "]"; } }
|
||||
public EditPartViewModel PartDefinition { get; set; }
|
||||
public SettingsDictionary PartSettings { 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 string Description {
|
||||
get { return PartSettings.ContainsKey("ContentPartSettings.Description") ? PartSettings["ContentPartSettings.Description"] : null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
Style.Require("ContentTypesAdmin");
|
||||
Layout.Title = T("Add Parts To \"{0}\"", Model.Type.DisplayName).ToString();
|
||||
}
|
||||
@T("Choose the Parts to add to this Content Type. Adding the <b>Containable</b> part makes it possible to add content items of this type to a <b>List</b>.")
|
||||
@T("Choose the Parts to add to this Content Type.")
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
@@ -11,12 +11,14 @@
|
||||
Model.PartSelections,
|
||||
(partSelection, i) => {
|
||||
var fieldNameStart = "PartSelections[" + i + "].";
|
||||
var fieldId = ViewData.TemplateInfo.GetFullHtmlFieldId(fieldNameStart + "IsSelected");
|
||||
return MvcHtmlString.Create(
|
||||
string.Format(
|
||||
"{0} <label for=\"{1}\" class=\"forcheckbox\">{2}</label>{3}",
|
||||
"{0} <label for=\"{1}\" class=\"forcheckbox\">{2}</label>{3}{4}",
|
||||
Html.CheckBox(fieldNameStart + "IsSelected"),
|
||||
ViewData.TemplateInfo.GetFullHtmlFieldId(fieldNameStart + "IsSelected"),
|
||||
fieldId,
|
||||
partSelection.PartDisplayName,
|
||||
!string.IsNullOrWhiteSpace(partSelection.PartDescription) ? string.Format("<label for=\"{0}\" class=\"part hint\">{1}</label>", fieldId, partSelection.PartDescription) : "",
|
||||
Html.Hidden(fieldNameStart + "PartName", partSelection.PartName)));
|
||||
|
||||
},
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
@model Orchard.Core.Contents.Settings.ContentPartSettings
|
||||
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Description)">@T("Description")</label>
|
||||
@Html.TextBoxFor(m => m.Description, new { @class = "text large"})
|
||||
<span class="hint">@T("Optionally provide a description for this part")</span>
|
||||
@Html.ValidationMessageFor(m => m.Description)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.EditorFor(m => m.Attachable)
|
||||
<label for="@Html.FieldIdFor(m => m.Attachable)" class="forcheckbox">@T("Attachable")</label>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<h3>@Model.DisplayName</h3>
|
||||
@if(!string.IsNullOrWhiteSpace(Model.Description)) {<span class="hint">@T(Model.Description)</span>}
|
||||
</div>
|
||||
<div class="related">
|
||||
@Html.ActionLink(T("Edit").ToString(), "EditPart", new { area = "Orchard.ContentTypes", id = Model.Name })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@model Orchard.ContentTypes.ViewModels.EditTypePartViewModel
|
||||
@using Orchard.Core.Contents.Settings;
|
||||
<fieldset class="manage-part" itemscope="itemscope" itemid="@Model.PartDefinition.Name" itemtype="http://orchardproject.net/data/ContentTypePart">
|
||||
<h3 itemprop="Name">@Model.PartDefinition.DisplayName</h3>
|
||||
<h3 itemprop="Name">@Model.PartDefinition.DisplayName @if(!string.IsNullOrWhiteSpace(Model.Description)){<span class="description"> - @Model.Description</span>}</h3>
|
||||
<div class="manage">
|
||||
@if (Model.PartDefinition.Settings.GetModel<ContentPartSettings>().Attachable) {
|
||||
@Html.ActionLink(T("Remove").Text, "RemovePartFrom", new { area = "Orchard.ContentTypes", id = Model.Type.Name, Model.PartDefinition.Name }, new { itemprop = "RemoveUrl UnsafeUrl" });
|
||||
|
||||
Reference in New Issue
Block a user