From ef380832d16a44973787b5ea9c131cd4a031f0d2 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Mon, 18 Oct 2010 14:15:39 -0700 Subject: [PATCH] Converting widgets to new shape API. --HG-- branch : dev --- .../Drivers/LayerPartDriver.cs | 6 ++---- .../Drivers/WidgetBagPartDriver.cs | 7 ++----- .../Drivers/WidgetPartDriver.cs | 5 ++--- .../Modules/Orchard.Widgets/Migrations.cs | 20 ------------------- .../Orchard.Widgets/Orchard.Widgets.csproj | 4 +++- .../Modules/Orchard.Widgets/Placement.info | 5 +++++ 6 files changed, 14 insertions(+), 33 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Placement.info diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs index f13fd91de..dfa200634 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/LayerPartDriver.cs @@ -9,10 +9,8 @@ namespace Orchard.Widgets.Drivers { public class LayerPartDriver : ContentPartDriver { protected override DriverResult Editor(LayerPart layerPart, dynamic shapeHelper) { - - // TODO: andrerod convert to new shape API. Location code kept for reference. - // ContentLocation location = layerPart.GetLocation("Editor"); - return ContentPartTemplate(layerPart, "Parts/Widgets.LayerPart"); //.Location(location); + return ContentShape("Parts_Widgets_LayerPart", + () => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.LayerPart", Model: layerPart)); } protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) { diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs index 43143b008..8f6faf7bd 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs @@ -5,12 +5,9 @@ using Orchard.Widgets.Models; namespace Orchard.Widgets.Drivers { [UsedImplicitly] public class WidgetBagPartDriver : ContentPartDriver { - private const string TemplateName = "Parts/Widgets.WidgetBagPart"; - protected override DriverResult Editor(WidgetBagPart part, dynamic shapeHelper) { - //var location = part.GetLocation("Editor"); - // TODO: andrerod convert to new shape API. Location code kept for reference. - return ContentPartTemplate("", TemplateName, Prefix); //.Location(location); + return ContentShape("Parts_Widgets_WidegetBagPart", + () => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.WidgetBagPart", Model: part)); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs index aa8555634..48ff5d6ad 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs @@ -17,9 +17,8 @@ namespace Orchard.Widgets.Drivers { protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelper) { widgetPart.AvailableZones = _widgetsService.GetZones(); - // TODO: andrerod convert to new shape API. Location code kept for reference. - //ContentLocation location = widgetPart.GetLocation("Editor"); - return ContentPartTemplate(widgetPart, "Parts/Widgets.WidgetPart"); //.Location(location); + return ContentShape("Parts_Widgets_WidgetPart", + () => shapeHelper.EditorTemplate(TemplateName: "Parts/Widgets.WidgetPart", Model: widgetPart)); } protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) { diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs index adc4b2864..c36a59214 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs @@ -64,26 +64,6 @@ namespace Orchard.Widgets { } public int UpdateFrom1() { - ContentDefinitionManager.AlterPartDefinition(typeof(LayerPart).Name, - cfg => cfg - .WithLocation(new Dictionary { - {"Editor", new ContentLocation { Zone = "Primary", Position = "1" }} - }) - ); - - ContentDefinitionManager.AlterPartDefinition(typeof(WidgetPart).Name, - cfg => cfg - .WithLocation(new Dictionary { - {"Editor", new ContentLocation { Zone = "Primary", Position = "1" }} - }) - ); - - ContentDefinitionManager.AlterPartDefinition(typeof(WidgetBagPart).Name, - cfg => cfg - .WithLocation(new Dictionary { - {"Editor", new ContentLocation {Zone = "Primary", Position = "5"}} - }) - ); ContentDefinitionManager.AlterTypeDefinition("WidgetPage", cfg => cfg .WithPart("CommonPart") diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj index fb0730577..d189f6d0d 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj @@ -97,7 +97,9 @@ - + + + {9916839C-39FC-4CEB-A5AF-89CA7E87119F} diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info b/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info new file mode 100644 index 000000000..174ee3b11 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Placement.info @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file