mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18786: Don't update editor parts which are not rendered
Work Item: 18786 --HG-- branch : 1.x
This commit is contained in:
@@ -93,7 +93,12 @@ namespace Orchard.ContentManagement {
|
||||
dynamic itemShape = CreateItemShape(actualShapeType);
|
||||
itemShape.ContentItem = content.ContentItem;
|
||||
|
||||
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory);
|
||||
var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);
|
||||
|
||||
var theme = workContext.CurrentTheme;
|
||||
var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);
|
||||
|
||||
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable);
|
||||
BindPlacement(context, null, stereotype);
|
||||
|
||||
_handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
|
||||
|
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
|
||||
namespace Orchard.ContentManagement.Drivers {
|
||||
@@ -55,6 +56,26 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
return null;
|
||||
}
|
||||
|
||||
// checking if the editor needs to be updated (e.g. if it was not hidden)
|
||||
var editor = Editor(part, context.New) as ContentShapeResult;
|
||||
|
||||
if(editor != null) {
|
||||
ShapeDescriptor descriptor;
|
||||
if(context.ShapeTable.Descriptors.TryGetValue(editor.GetShapeType(), out descriptor)) {
|
||||
var placementContext = new ShapePlacementContext {
|
||||
ContentType = part.ContentItem.ContentType,
|
||||
Differentiator = editor.GetDifferentiator(),
|
||||
DisplayType = null
|
||||
};
|
||||
|
||||
var location = descriptor.Placement(placementContext).Location;
|
||||
|
||||
if(String.IsNullOrEmpty(location) || location == "-") {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DriverResult result = Editor(part, context.Updater, context.New);
|
||||
|
||||
if (result != null) {
|
||||
|
@@ -1,12 +1,17 @@
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class UpdateEditorContext : BuildEditorContext {
|
||||
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory)
|
||||
|
||||
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable)
|
||||
: base(model, content, groupInfoId, shapeFactory) {
|
||||
|
||||
ShapeTable = shapeTable;
|
||||
Updater = updater;
|
||||
}
|
||||
|
||||
public IUpdateModel Updater { get; private set; }
|
||||
public ShapeTable ShapeTable { get; private set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user