#18786: Don't update editor parts which are not rendered

Work Item: 18786

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-07-05 16:11:50 -07:00
parent 2289d821f3
commit 6679b4a197
3 changed files with 33 additions and 2 deletions

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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; }
}
}