Making progress on updating the content manager API fit better with the new dynamic UI composition scheme

- Includes changing display-related implementations (drivers & views) to work with shapes
- Editor implementations still on the old template model
- Orchard.Blogs is currently using a different display type instead of specifying alterations (for Blog and BlogPost)

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-10-11 02:06:01 -07:00
parent b7c3ada825
commit ddca57edd4
128 changed files with 635 additions and 454 deletions

View File

@@ -31,7 +31,7 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
[Test]
public void DriverHandlerShouldNotThrowException() {
var contentHandler = _container.Resolve<IContentHandler>();
contentHandler.BuildDisplayShape(null);
contentHandler.BuildDisplay(null);
}
[Test]
@@ -45,13 +45,13 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
var contentHandler = _container.Resolve<IContentHandler>();
var contentItem = new ContentItem();
var context = new BuildDisplayModelContext(contentItem, "", null, new ShapeHelperFactory(null));
var context = new BuildDisplayContext(null, contentItem, "", new ShapeHelperFactory(null));
driver1.Verify(x => x.BuildDisplayShape(context), Times.Never());
driver2.Verify(x => x.BuildDisplayShape(context), Times.Never());
contentHandler.BuildDisplayShape(context);
driver1.Verify(x => x.BuildDisplayShape(context));
driver2.Verify(x => x.BuildDisplayShape(context));
driver1.Verify(x => x.BuildDisplay(context), Times.Never());
driver2.Verify(x => x.BuildDisplay(context), Times.Never());
contentHandler.BuildDisplay(context);
driver1.Verify(x => x.BuildDisplay(context));
driver2.Verify(x => x.BuildDisplay(context));
}
[Test, Ignore("no implementation for IZoneCollection")]
@@ -66,10 +66,10 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
var contentItem = new ContentItem();
contentItem.Weld(new StubPart { Foo = new[] { "a", "b", "c" } });
var ctx = new BuildDisplayModelContext(contentItem, "", null, null);
var ctx = new BuildDisplayContext(null, null, "", null);
var context = shapeHelperFactory.CreateHelper().Context(ctx);
Assert.That(context.TopMeta, Is.Null);
contentHandler.BuildDisplayShape(ctx);
contentHandler.BuildDisplay(ctx);
Assert.That(context.TopMeta, Is.Not.Null);
Assert.That(context.TopMeta.Count == 1);
}
@@ -79,20 +79,25 @@ namespace Orchard.Tests.ContentManagement.Handlers.Coordinators {
get { return "Stub"; }
}
protected override DriverResult Display(StubPart part, string displayType) {
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
if (displayType.StartsWith("Summary"))
return ContentPartTemplate(viewModel, "StubViewModelTerse").Location("TopMeta");
protected override DriverResult Display(StubPart part, string displayType, dynamic shapeHelper) {
var stub = shapeHelper.Stub(ContentPart: part, Foo: string.Join(",", part.Foo));
if (!string.IsNullOrWhiteSpace(displayType))
stub.Metadata.Type = string.Format("{0}.{1}", stub.Metadata.Type, displayType);
return ContentShape(stub).Location("TopMeta");
//var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
//if (displayType.StartsWith("Summary"))
// return ContentPartTemplate(viewModel, "StubViewModelTerse").Location("TopMeta");
return ContentPartTemplate(viewModel).Location("TopMeta");
//return ContentPartTemplate(viewModel).Location("TopMeta");
}
protected override DriverResult Editor(StubPart part) {
protected override DriverResult Editor(StubPart part, dynamic shapeHelper) {
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
return ContentPartTemplate(viewModel).Location("last", "10");
}
protected override DriverResult Editor(StubPart part, IUpdateModel updater) {
protected override DriverResult Editor(StubPart part, IUpdateModel updater, dynamic shapeHelper) {
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
updater.TryUpdateModel(viewModel, Prefix, null, null);
part.Foo = viewModel.Foo.Split(new[] { ',' }).Select(x => x.Trim()).ToArray();

View File

@@ -3,7 +3,7 @@
namespace Orchard.Tests.ContentManagement.Models {
public class AlphaHandler : ContentHandler {
public AlphaHandler() {
OnGetDisplayShape<Alpha>((ctx, part) => ctx.Model.Zones["Main"].Add(part, "3"));
OnGetDisplayShape<Alpha>((ctx, part) => ctx.Shape.Zones["Main"].Add(part, "3"));
}
protected override void Activating(ActivatingContentContext context) {

View File

@@ -3,7 +3,7 @@
namespace Orchard.Tests.ContentManagement.Models {
public class FlavoredHandler : ContentHandler {
public FlavoredHandler() {
OnGetDisplayShape<Flavored>((ctx, part) => ctx.Model.Zones["Main"].Add(part));
OnGetDisplayShape<Flavored>((ctx, part) => ctx.Shape.Zones["Main"].Add(part));
}
protected override void Activating(ActivatingContentContext context) {
if (context.ContentType == "beta" || context.ContentType == "alpha") {

View File

@@ -3,7 +3,7 @@
namespace Orchard.Tests.ContentManagement.Models {
public class StyledHandler : ContentHandler {
public StyledHandler() {
OnGetDisplayShape<Styled>((ctx, part) => ctx.Model.Zones["Main"].Add(part, "10"));
OnGetDisplayShape<Styled>((ctx, part) => ctx.Shape.Zones["Main"].Add(part, "10"));
}
protected override void Activating(ActivatingContentContext context) {