mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-31 18:27:15 +08:00
#18439: Fixing ContentField and ContentPart automatic assignment to shapes
Work Item: 18439 --HG-- branch : 1.x
This commit is contained in:
parent
840cc057ee
commit
f2c0a599cb
@ -5,4 +5,4 @@ ce578373f907c0a55fd91229a344f0755f290174 src/Orchard.Web/Modules/Orchard.TaskLea
|
||||
a7c7f06ac79d4db2f4295a2a1473417647e6889c src/Orchard.Web/Modules/Orchard.Tokens
|
||||
88a640948e19a1a9dd79b859856375e292d53f2f src/orchard.web/Modules/Orchard.Alias
|
||||
892939eaeb765c7cc0d10f64922d53f14ab3aee1 src/orchard.web/Modules/Orchard.Projections
|
||||
a181451f1871e9f876700700bd4dc9350562a0ab src/orchard.web/modules/Orchard.Fields
|
||||
7ec9df536beace788a0784f7cf471b1f32a07436 src/orchard.web/modules/Orchard.Fields
|
||||
|
@ -12,6 +12,17 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
public override void Apply(BuildDisplayContext context) {
|
||||
foreach (var result in _results) {
|
||||
|
||||
// copy the ContentPart which was used to render this result to its children
|
||||
// so they can assign it to the concrete shapes
|
||||
if (result.ContentPart == null && ContentPart != null) {
|
||||
result.ContentPart = ContentPart;
|
||||
}
|
||||
|
||||
if (result.ContentField == null && ContentField != null) {
|
||||
result.ContentField = ContentField;
|
||||
}
|
||||
|
||||
result.Apply(context);
|
||||
}
|
||||
}
|
||||
|
@ -17,25 +17,28 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
DriverResult IContentFieldDriver.BuildDisplayShape(BuildDisplayContext context) {
|
||||
return Process(context.ContentItem, (part, field) => {
|
||||
context.ContentPart = part;
|
||||
context.ContentField = field;
|
||||
return Display(part, field, context.DisplayType, context.New);
|
||||
DriverResult result = Display(part, field, context.DisplayType, context.New);
|
||||
result.ContentPart = part;
|
||||
result.ContentField = field;
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
DriverResult IContentFieldDriver.BuildEditorShape(BuildEditorContext context) {
|
||||
return Process(context.ContentItem, (part, field) => {
|
||||
context.ContentPart = part;
|
||||
context.ContentField = field;
|
||||
return Editor(part, field, context.New);
|
||||
DriverResult result = Editor(part, field, context.New);
|
||||
result.ContentPart = part;
|
||||
result.ContentField = field;
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
DriverResult IContentFieldDriver.UpdateEditorShape(UpdateEditorContext context) {
|
||||
return Process(context.ContentItem, (part, field) => {
|
||||
context.ContentPart = part;
|
||||
context.ContentField = field;
|
||||
return Editor(part, field, context.Updater, context.New);
|
||||
DriverResult result = Editor(part, field, context.Updater, context.New);
|
||||
result.ContentPart = part;
|
||||
result.ContentField = field;
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
@ -126,16 +129,6 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
ShapeMetadata metadata = shape.Metadata;
|
||||
|
||||
// if no ContentField property has been set, assign it
|
||||
if (shape.ContentField == null) {
|
||||
shape.ContentField = ctx.ContentField;
|
||||
}
|
||||
|
||||
// if no ContentPart property has been set, assign it
|
||||
if (shape.ContentPart == null) {
|
||||
shape.ContentPart = ctx.ContentPart;
|
||||
}
|
||||
|
||||
// if no ContentItem property has been set, assign it
|
||||
if (shape.ContentItem == null) {
|
||||
shape.ContentItem = ctx.ContentItem;
|
||||
|
@ -23,9 +23,9 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
return null;
|
||||
}
|
||||
|
||||
context.ContentPart = part;
|
||||
|
||||
return Display(part, context.DisplayType, context.New);
|
||||
DriverResult result = Display(part, context.DisplayType, context.New);
|
||||
result.ContentPart = part;
|
||||
return result;
|
||||
}
|
||||
|
||||
DriverResult IContentPartDriver.BuildEditor(BuildEditorContext context) {
|
||||
@ -35,9 +35,9 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
return null;
|
||||
}
|
||||
|
||||
context.ContentPart = part;
|
||||
|
||||
return Editor(part, context.New);
|
||||
DriverResult result = Editor(part, context.New);
|
||||
result.ContentPart = part;
|
||||
return result;
|
||||
}
|
||||
|
||||
DriverResult IContentPartDriver.UpdateEditor(UpdateEditorContext context) {
|
||||
@ -47,9 +47,9 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
return null;
|
||||
}
|
||||
|
||||
context.ContentPart = part;
|
||||
|
||||
return Editor(part, context.Updater, context.New);
|
||||
DriverResult result = Editor(part, context.Updater, context.New);
|
||||
result.ContentPart = part;
|
||||
return result;
|
||||
}
|
||||
|
||||
void IContentPartDriver.Importing(ImportContentContext context) {
|
||||
@ -107,11 +107,6 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
private static dynamic AddAlternates(dynamic shape, BuildShapeContext ctx) {
|
||||
ShapeMetadata metadata = shape.Metadata;
|
||||
|
||||
// if no ContentPart property has been set, assign it
|
||||
if (shape.ContentPart == null) {
|
||||
shape.ContentPart = ctx.ContentPart;
|
||||
}
|
||||
|
||||
// if no ContentItem property has been set, assign it
|
||||
if (shape.ContentItem == null) {
|
||||
shape.ContentItem = ctx.ContentItem;
|
||||
|
@ -35,6 +35,15 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
|
||||
dynamic parentShape = context.Shape;
|
||||
var newShape = _shapeBuilder(context);
|
||||
|
||||
if (ContentPart != null && newShape.ContentPart == null) {
|
||||
newShape.ContentPart = ContentPart;
|
||||
}
|
||||
|
||||
if (ContentField != null && newShape.ContentField == null) {
|
||||
newShape.ContentField = ContentField;
|
||||
}
|
||||
|
||||
ShapeMetadata newShapeMetadata = newShape.Metadata;
|
||||
newShapeMetadata.Prefix = _prefix;
|
||||
newShapeMetadata.DisplayType = displayType;
|
||||
|
@ -4,5 +4,8 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
public class DriverResult {
|
||||
public virtual void Apply(BuildDisplayContext context) { }
|
||||
public virtual void Apply(BuildEditorContext context) { }
|
||||
|
||||
public ContentPart ContentPart { get; set; }
|
||||
public ContentField ContentField { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
public dynamic Shape { get; private set; }
|
||||
public IContent Content { get; private set; }
|
||||
public ContentItem ContentItem { get; private set; }
|
||||
public ContentPart ContentPart { get; set; }
|
||||
public ContentField ContentField { get; set; }
|
||||
public dynamic New { get; private set; }
|
||||
public string GroupId { get; private set; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user