mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 20:13:52 +08:00
#17555: Breaking change to Drivers
Adds string GroupId property to BuildShapeContext Adds OnGroup(string groupId) fluent method to ContentShapeResult ContentShapeResult.ApplyImplementation only utilizes shapes on the correct groupId Also adds GetContentItemMetadata virtual method for part and field drivers And adds groupId to BuildDisplay method for forward compatability Work Items:17555 --HG-- branch : 1.x extra : rebase_source : 0d052a2cf97a14c789ab451ab34b82bf3bf9011a
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
|
||||
var contentHandler = _container.Resolve<IContentHandler>();
|
||||
|
||||
var contentItem = new ContentItem();
|
||||
var context = new BuildDisplayContext(null, contentItem, "", new Mock<IShapeFactory>().Object);
|
||||
var context = new BuildDisplayContext(null, contentItem, "", "", new Mock<IShapeFactory>().Object);
|
||||
|
||||
driver1.Verify(x => x.BuildDisplay(context), Times.Never());
|
||||
driver2.Verify(x => x.BuildDisplay(context), Times.Never());
|
||||
@@ -64,7 +64,7 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
|
||||
var contentItem = new ContentItem();
|
||||
contentItem.Weld(new StubPart { Foo = new[] { "a", "b", "c" } });
|
||||
|
||||
var ctx = new BuildDisplayContext(null, null, "", null);
|
||||
var ctx = new BuildDisplayContext(null, null, "", "", null);
|
||||
var context = shapeFactory.Context(ctx);
|
||||
Assert.That(context.TopMeta, Is.Null);
|
||||
contentHandler.BuildDisplay(ctx);
|
||||
|
||||
@@ -14,20 +14,19 @@ namespace Orchard.Comments.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "CommentSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(CommentSettingsPart part, string groupInfoId, dynamic shapeHelper) {
|
||||
if (!string.Equals(groupInfoId, "comments", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
return ContentShape("Parts_Comments_SiteSettings",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Comments.SiteSettings", Model: part.Record, Prefix: Prefix));
|
||||
protected override DriverResult Editor(CommentSettingsPart part, dynamic shapeHelper) {
|
||||
return Editor(part, null, shapeHelper);
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(CommentSettingsPart part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) {
|
||||
if (!string.Equals(groupInfoId, "comments", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
protected override DriverResult Editor(CommentSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
updater.TryUpdateModel(part.Record, Prefix, null, null);
|
||||
return Editor(part, shapeHelper);
|
||||
return ContentShape("Parts_Comments_SiteSettings", () => {
|
||||
if (updater != null) {
|
||||
updater.TryUpdateModel(part.Record, Prefix, null, null);
|
||||
}
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.Comments.SiteSettings", Model: part.Record, Prefix: Prefix);
|
||||
})
|
||||
.OnGroup("comments");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,28 +20,24 @@ namespace Orchard.Email.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "SmtpSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, string groupInfoId, dynamic shapeHelper) {
|
||||
if (!string.Equals(groupInfoId, "email", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_SmtpSettings_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix))
|
||||
.OnGroup("email");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) {
|
||||
if (!string.Equals(groupInfoId, "email", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_SmtpSettings_Edit", () => {
|
||||
var previousPassword = part.Password;
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
|
||||
var previousPassword = part.Password;
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
|
||||
// restore password if the input is empty, meaning it has not been reseted
|
||||
if (string.IsNullOrEmpty(part.Password)) {
|
||||
part.Password = previousPassword;
|
||||
}
|
||||
|
||||
return ContentShape("Parts_SmtpSettings_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
|
||||
// restore password if the input is empty, meaning it has not been reseted
|
||||
if (string.IsNullOrEmpty(part.Password)) {
|
||||
part.Password = previousPassword;
|
||||
}
|
||||
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix);
|
||||
})
|
||||
.OnGroup("email");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,35 +23,33 @@ namespace Orchard.Search.Drivers {
|
||||
|
||||
protected override string Prefix { get { return "SearchSettings"; } }
|
||||
|
||||
protected override DriverResult Editor(SearchSettingsPart part, string groupInfoId, dynamic shapeHelper) {
|
||||
if (!string.Equals(groupInfoId, "search", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
SearchSettingsViewModel model = new SearchSettingsViewModel();
|
||||
String [] searchedFields = part.SearchedFields;
|
||||
|
||||
if (_indexManager.HasIndexProvider()) {
|
||||
model.Entries = new List<SearchSettingsEntry>();
|
||||
foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(SearchIndexName)) {
|
||||
model.Entries.Add(new SearchSettingsEntry { Field = field, Selected = searchedFields.Contains(field) });
|
||||
}
|
||||
}
|
||||
|
||||
return ContentShape("Parts_Search_SiteSettings",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Search.SiteSettings", Model: model, Prefix: Prefix));
|
||||
protected override DriverResult Editor(SearchSettingsPart part, dynamic shapeHelper) {
|
||||
return Editor(part, null, shapeHelper);
|
||||
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) {
|
||||
if (!string.Equals(groupInfoId, "search", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
protected override DriverResult Editor(SearchSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_Search_SiteSettings", () => {
|
||||
SearchSettingsViewModel model = new SearchSettingsViewModel();
|
||||
String[] searchedFields = part.SearchedFields;
|
||||
|
||||
SearchSettingsViewModel model = new SearchSettingsViewModel();
|
||||
if (updater != null) {
|
||||
// submitting: rebuild model from form data
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
// update part if successful
|
||||
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
||||
}
|
||||
}
|
||||
else if (_indexManager.HasIndexProvider()) {
|
||||
// viewing editor: build model from part
|
||||
model.Entries = new List<SearchSettingsEntry>();
|
||||
foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(SearchIndexName)) {
|
||||
model.Entries.Add(new SearchSettingsEntry { Field = field, Selected = searchedFields.Contains(field) });
|
||||
}
|
||||
}
|
||||
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
part.SearchedFields = model.Entries.Where(e => e.Selected).Select(e => e.Field).ToArray();
|
||||
}
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts/Search.SiteSettings", Model: model, Prefix: Prefix);
|
||||
}).OnGroup("search");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public dynamic BuildDisplay(IContent content, string displayType) {
|
||||
public dynamic BuildDisplay(IContent content, string displayType, string groupId) {
|
||||
var contentTypeDefinition = content.ContentItem.TypeDefinition;
|
||||
string stereotype;
|
||||
if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
|
||||
@@ -47,14 +47,14 @@ namespace Orchard.ContentManagement {
|
||||
itemShape.ContentItem = content.ContentItem;
|
||||
itemShape.Metadata.DisplayType = actualDisplayType;
|
||||
|
||||
var context = new BuildDisplayContext(itemShape, content, actualDisplayType, _shapeFactory);
|
||||
var context = new BuildDisplayContext(itemShape, content, actualDisplayType, groupId, _shapeFactory);
|
||||
BindPlacement(context, actualDisplayType, stereotype);
|
||||
|
||||
_handlers.Value.Invoke(handler => handler.BuildDisplay(context), Logger);
|
||||
return context.Shape;
|
||||
}
|
||||
|
||||
public dynamic BuildEditor(IContent content, string groupInfoId) {
|
||||
public dynamic BuildEditor(IContent content, string groupId) {
|
||||
var contentTypeDefinition = content.ContentItem.TypeDefinition;
|
||||
string stereotype;
|
||||
if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
|
||||
@@ -65,7 +65,7 @@ namespace Orchard.ContentManagement {
|
||||
dynamic itemShape = CreateItemShape(actualShapeType);
|
||||
itemShape.ContentItem = content.ContentItem;
|
||||
|
||||
var context = new BuildEditorContext(itemShape, content, groupInfoId, _shapeFactory);
|
||||
var context = new BuildEditorContext(itemShape, content, groupId, _shapeFactory);
|
||||
BindPlacement(context, null, stereotype);
|
||||
|
||||
_handlers.Value.Invoke(handler => handler.BuildEditor(context), Logger);
|
||||
|
||||
@@ -386,16 +386,16 @@ namespace Orchard.ContentManagement {
|
||||
return GetDisplayGroupInfos(content).FirstOrDefault(gi => string.Equals(gi.Id, groupInfoId, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public dynamic BuildDisplay(IContent content, string displayType = "") {
|
||||
return _contentDisplay.Value.BuildDisplay(content, displayType);
|
||||
public dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "") {
|
||||
return _contentDisplay.Value.BuildDisplay(content, displayType, groupId);
|
||||
}
|
||||
|
||||
public dynamic BuildEditor(IContent content, string groupInfoId = "") {
|
||||
return _contentDisplay.Value.BuildEditor(content, groupInfoId);
|
||||
public dynamic BuildEditor(IContent content, string groupId = "") {
|
||||
return _contentDisplay.Value.BuildEditor(content, groupId);
|
||||
}
|
||||
|
||||
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupInfoId = "") {
|
||||
return _contentDisplay.Value.UpdateEditor(content, updater, groupInfoId);
|
||||
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "") {
|
||||
return _contentDisplay.Value.UpdateEditor(content, updater, groupId);
|
||||
}
|
||||
|
||||
public IContentQuery<ContentItem> Query() {
|
||||
|
||||
@@ -11,6 +11,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
protected virtual string Prefix { get { return ""; } }
|
||||
protected virtual string Zone { get { return "Content"; } }
|
||||
|
||||
void IContentFieldDriver.GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||
Process(context.ContentItem, (part, field) => GetContentItemMetadata(part, field, context.Metadata));
|
||||
}
|
||||
|
||||
DriverResult IContentFieldDriver.BuildDisplayShape(BuildDisplayContext context) {
|
||||
return Process(context.ContentItem, (part, field) => Display(part, field, context.DisplayType, context.New));
|
||||
}
|
||||
@@ -24,31 +28,26 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Importing(ImportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => {
|
||||
Importing(part, field, context);
|
||||
return null;
|
||||
});
|
||||
Process(context.ContentItem, (part, field) => Importing(part, field, context));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Imported(ImportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => {
|
||||
Imported(part, field, context);
|
||||
return null;
|
||||
});
|
||||
Process(context.ContentItem, (part, field) => Imported(part, field, context));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Exporting(ExportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => {
|
||||
Exporting(part, field, context);
|
||||
return null;
|
||||
});
|
||||
Process(context.ContentItem, (part, field) => Exporting(part, field, context));
|
||||
}
|
||||
|
||||
void IContentFieldDriver.Exported(ExportContentContext context) {
|
||||
Process(context.ContentItem, (part, field) => {
|
||||
Exported(part, field, context);
|
||||
return null;
|
||||
});
|
||||
Process(context.ContentItem, (part, field) => Exported(part, field, context));
|
||||
}
|
||||
|
||||
void Process(ContentItem item, Action<ContentPart, TField> effort) {
|
||||
var occurences = item.Parts.SelectMany(part => part.Fields.OfType<TField>().Select(field => new { part, field }));
|
||||
foreach (var occurence in occurences) {
|
||||
effort(occurence.part, occurence.field);
|
||||
}
|
||||
}
|
||||
|
||||
DriverResult Process(ContentItem item, Func<ContentPart, TField, DriverResult> effort) {
|
||||
@@ -72,9 +71,12 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
return contentFieldInfo;
|
||||
}
|
||||
|
||||
protected virtual void GetContentItemMetadata(ContentPart part, TField field, ContentItemMetadata metadata) { return; }
|
||||
|
||||
protected virtual DriverResult Display(ContentPart part, TField field, string displayType, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(ContentPart part, TField field, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(ContentPart part, TField field, IUpdateModel updater, dynamic shapeHelper) { return null; }
|
||||
|
||||
protected virtual void Importing(ContentPart part, TField field, ImportContentContext context) { }
|
||||
protected virtual void Imported(ContentPart part, TField field, ImportContentContext context) { }
|
||||
protected virtual void Exporting(ContentPart part, TField field, ExportContentContext context) { }
|
||||
|
||||
@@ -9,6 +9,12 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
public abstract class ContentPartDriver<TContent> : IContentPartDriver where TContent : ContentPart, new() {
|
||||
protected virtual string Prefix { get { return ""; } }
|
||||
|
||||
void IContentPartDriver.GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
if (part != null)
|
||||
GetContentItemMetadata(part, context.Metadata);
|
||||
}
|
||||
|
||||
DriverResult IContentPartDriver.BuildDisplay(BuildDisplayContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
return part == null ? null : Display(part, context.DisplayType, context.New);
|
||||
@@ -16,16 +22,12 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
DriverResult IContentPartDriver.BuildEditor(BuildEditorContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
return part == null
|
||||
? null
|
||||
: !string.IsNullOrWhiteSpace(context.GroupInfoId) ? Editor(part, context.GroupInfoId, context.New) : Editor(part, context.New);
|
||||
return part == null ? null : Editor(part, context.New);
|
||||
}
|
||||
|
||||
DriverResult IContentPartDriver.UpdateEditor(UpdateEditorContext context) {
|
||||
var part = context.ContentItem.As<TContent>();
|
||||
return part == null
|
||||
? null
|
||||
: !string.IsNullOrWhiteSpace(context.GroupInfoId) ? Editor(part, context.Updater, context.GroupInfoId, context.New) : Editor(part, context.Updater, context.New);
|
||||
return part == null ? null : Editor(part, context.Updater, context.New);
|
||||
}
|
||||
|
||||
void IContentPartDriver.Importing(ImportContentContext context) {
|
||||
@@ -52,11 +54,12 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
Exported(part, context);
|
||||
}
|
||||
|
||||
protected virtual void GetContentItemMetadata(TContent context, ContentItemMetadata metadata) { return; }
|
||||
|
||||
protected virtual DriverResult Display(TContent part, string displayType, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, string groupInfoId, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, IUpdateModel updater, dynamic shapeHelper) { return null; }
|
||||
protected virtual DriverResult Editor(TContent part, IUpdateModel updater, string groupInfoId, dynamic shapeHelper) { return null; }
|
||||
|
||||
protected virtual void Importing(TContent part, ImportContentContext context) { return; }
|
||||
protected virtual void Imported(TContent part, ImportContentContext context) { return; }
|
||||
protected virtual void Exporting(TContent part, ExportContentContext context) { return; }
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
private readonly string _shapeType;
|
||||
private readonly string _prefix;
|
||||
private readonly Func<BuildShapeContext, dynamic> _shapeBuilder;
|
||||
private string _groupId;
|
||||
|
||||
public ContentShapeResult(string shapeType, string prefix, Func<BuildShapeContext, dynamic> shapeBuilder) {
|
||||
_shapeType = shapeType;
|
||||
@@ -25,6 +26,9 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
}
|
||||
|
||||
private void ApplyImplementation(BuildShapeContext context, string displayType) {
|
||||
if (!string.Equals(context.GroupId ?? "", _groupId ?? "", StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
var placement = context.FindPlacement(_shapeType, _differentiator, _defaultLocation);
|
||||
if (string.IsNullOrEmpty(placement.Location) || placement.Location == "-")
|
||||
return;
|
||||
@@ -66,9 +70,15 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
_defaultLocation = zone;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContentShapeResult Differentiator(string differentiator) {
|
||||
_differentiator = differentiator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContentShapeResult OnGroup(string groupId) {
|
||||
_groupId=groupId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,10 @@ namespace Orchard.ContentManagement.Drivers.Coordinators {
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||
_drivers.Invoke(driver => driver.GetContentItemMetadata(context), Logger);
|
||||
}
|
||||
|
||||
public override void BuildDisplay(BuildDisplayContext context) {
|
||||
_drivers.Invoke(driver => {
|
||||
var result = driver.BuildDisplayShape(context);
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace Orchard.ContentManagement.Drivers.Coordinators {
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||
_drivers.Invoke(driver => driver.GetContentItemMetadata(context), Logger);
|
||||
}
|
||||
|
||||
public override void BuildDisplay(BuildDisplayContext context) {
|
||||
_drivers.Invoke(driver => {
|
||||
var result = driver.BuildDisplay(context);
|
||||
|
||||
@@ -12,5 +12,6 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
void Exporting(ExportContentContext context);
|
||||
void Exported(ExportContentContext context);
|
||||
IEnumerable<ContentFieldInfo> GetFieldInfo();
|
||||
void GetContentItemMetadata(GetContentItemMetadataContext context);
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,6 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
void Exporting(ExportContentContext context);
|
||||
void Exported(ExportContentContext context);
|
||||
IEnumerable<ContentPartInfo> GetPartInfo();
|
||||
void GetContentItemMetadata(GetContentItemMetadataContext context);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ using Orchard.DisplayManagement;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class BuildDisplayContext : BuildShapeContext {
|
||||
public BuildDisplayContext(IShape model, IContent content, string displayType, IShapeFactory shapeFactory)
|
||||
: base(model, content, shapeFactory) {
|
||||
public BuildDisplayContext(IShape model, IContent content, string displayType, string groupId, IShapeFactory shapeFactory)
|
||||
: base(model, content, groupId, shapeFactory) {
|
||||
DisplayType = displayType;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,8 @@ using Orchard.DisplayManagement;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class BuildEditorContext : BuildShapeContext {
|
||||
public BuildEditorContext(IShape model, IContent content, string groupInfoId, IShapeFactory shapeFactory)
|
||||
: base(model, content, shapeFactory) {
|
||||
GroupInfoId = groupInfoId;
|
||||
public BuildEditorContext(IShape model, IContent content, string groupId, IShapeFactory shapeFactory)
|
||||
: base(model, content, groupId, shapeFactory) {
|
||||
}
|
||||
|
||||
public string GroupInfoId { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,18 @@ using Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class BuildShapeContext {
|
||||
protected BuildShapeContext(IShape shape, IContent content, IShapeFactory shapeFactory) {
|
||||
protected BuildShapeContext(IShape shape, IContent content, string groupId, IShapeFactory shapeFactory) {
|
||||
Shape = shape;
|
||||
ContentItem = content.ContentItem;
|
||||
New = shapeFactory;
|
||||
GroupId = groupId;
|
||||
FindPlacement = (partType, differentiator, defaultLocation) => new PlacementInfo {Location = defaultLocation, Source = String.Empty};
|
||||
}
|
||||
|
||||
public dynamic Shape { get; private set; }
|
||||
public ContentItem ContentItem { get; private set; }
|
||||
public dynamic New { get; private set; }
|
||||
public string GroupId { get; private set; }
|
||||
|
||||
public Func<string, string, string, PlacementInfo> FindPlacement { get; set; }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
protected override void BuildEditorShape(BuildEditorContext context, ContentPart<TRecord> part) {
|
||||
if (!string.IsNullOrWhiteSpace(_groupId) && !string.Equals(_groupId, context.GroupInfoId, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.Equals(_groupId, context.GroupId, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
var templateShape = context.New.EditorTemplate(TemplateName: _templateName, Model: part.Record, Prefix: _prefix);
|
||||
@@ -44,7 +44,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
protected override void UpdateEditorShape(UpdateEditorContext context, ContentPart<TRecord> part) {
|
||||
if (!string.IsNullOrWhiteSpace(_groupId) && !string.Equals(_groupId, context.GroupInfoId, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.Equals(_groupId, context.GroupId, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
context.Updater.TryUpdateModel(part.Record, _prefix, null, null);
|
||||
|
||||
@@ -33,15 +33,15 @@ namespace Orchard.ContentManagement {
|
||||
GroupInfo GetEditorGroupInfo(IContent contentItem, string groupInfoId);
|
||||
GroupInfo GetDisplayGroupInfo(IContent contentItem, string groupInfoId);
|
||||
|
||||
dynamic BuildDisplay(IContent content, string displayType = "");
|
||||
dynamic BuildEditor(IContent content, string groupInfoId = "");
|
||||
dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupInfoId = "");
|
||||
dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "");
|
||||
dynamic BuildEditor(IContent content, string groupId = "");
|
||||
dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "");
|
||||
}
|
||||
|
||||
public interface IContentDisplay : IDependency {
|
||||
dynamic BuildDisplay(IContent content, string displayType = "");
|
||||
dynamic BuildEditor(IContent content, string groupInfoId = "");
|
||||
dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupInfoId = "");
|
||||
dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "");
|
||||
dynamic BuildEditor(IContent content, string groupId = "");
|
||||
dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "");
|
||||
}
|
||||
|
||||
public class VersionOptions {
|
||||
|
||||
Reference in New Issue
Block a user