IDeliverable / IDeliverable.Widgets

A module for the Orchard CMS that provides a number of useful functional enhancements to the widgets system.
6 stars 9 forks source link

Issues with Shape Tracing #13

Open jeffolmstead opened 8 years ago

jeffolmstead commented 8 years ago

If you utilize the Ajaxified Widget and have shape tracing enabled, Orchard.DesignerTools.Services.ShapeTracingFactory will throw an error in the OnDisplaying method, line 115:

var descriptor = shapeTable.Descriptors[shapeMetadata.Type];

This error is thrown when it is looking for shape Widget__Ajaxified It simply does not exist in the dictionary. I don't yet have a fix for this, will post back here if I do.

sfmskywalker commented 8 years ago

Very cool, thanks Jeff.

jeffolmstead commented 8 years ago

Here is what I am thinking (but don't know how to actually prove it). It seems to me that because the shape type is being dynamically changed in /Shapes/AjaxWidgetShapes OnDisplaying event to "Wiget__Ajaxified" this shape type is never registered in the shapeTable.Descriptors. In other words, it is never served up via a driver and it isn't really an alternate so I don't think the shape table builder would ever find it.

For reference, the actual shape table is being built in Orchard.Framework --> DisplayManagement\Descriptors\DefaultShapeTableManager

So question 1 is do you see things differently? Is there a way to update your module to get it into the shape table?

Assuming we cannot get your shape to be recognized one option is to say that ShapeTracingFactory (i.e. Orchard.DesignerTools.Services.ShapeTracingFactory line 115) should use code like this:

ShapeDescriptor descriptor;
if (!shapeTable.Descriptors.TryGetValue(shapeMetadata.Type, out descriptor)) {
     return;
}

Which seems like that would be a good idea anyway as there might be something else in the future which would prevent shape tracing from finding the type. Unfortunately you would also have to alter ShapeTracingMeta.cshtml and ShapeTracingWrapper.cshtml to wrap them with a check on the Model.ShapeId like this:

@if (Model.ShapeId != null) { 

I don't feel that is the best solution though. Thoughts?