public dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "") { var shape = _origami.ContentShape(content, displayType); _origami.Build(_origami.ContentBuilder(content).WithDisplayType(String.IsNullOrWhiteSpace(displayType)?"Detail":displayType).WithGroup(groupId), shape); return(shape); }
protected override ModelDriverResult Build(ConnectorEventContext model, dynamic shapeHelper, ModelShapeContext context) { return(Combined( ModelShape("Connectors_Connector", () => { var builder = _origami.ContentBuilder(model.ConnectorContent).WithDisplayType(context.DisplayType).WithParent(context).WithMode("Display"); builder.Context.CustomContext[typeof(SocketParentContext)] = new SocketParentContext(model) { ModelContext = context }; var shape = _origami.ContentShape(model.ConnectorContent.ContentItem, context.DisplayType, prefix: context.Prefix); _origami.Build(builder, shape); return shape; }), ModelShape("Connectors_Right", () => { var builder = _origami.ContentBuilder(model.Right.Content).WithDisplayType(context.DisplayType).WithParent(context).WithMode("Display"); builder.Context.CustomContext[typeof(SocketParentContext)] = new SocketParentContext(model) { ModelContext = context }; var shape = _origami.ContentShape(model.Right.Content.ContentItem, context.DisplayType, prefix: context.Prefix); _origami.Build(builder, shape); return shape; }) // ModelShape("Connectors_Left", () => { // var builder = _origami.ContentBuilder(model.ConnectorContent).WithDisplayType(context.DisplayType).WithParent(context); // }) )); }
public void Subscribe(RootBuilder describe) { describe.Scope("Content", mix => { mix.Factory <RootShape, dynamic>((context) => _origami.ContentShape(context.Get <Model, object>() as IContent, context.Get <ShapeMetadataFactory, ShapeMetadata>().DisplayType)); mix.Factory <ModelBuilder, ModelShapeBuilder>((context) => _origami.ContentBuilder(context.Get <Model, object>() as IContent).WithDisplayType(context.Get <ShapeMetadataFactory, ShapeMetadata>().DisplayType)); mix.Parameter <int>("contentId", (mix2) => { mix2.Factory <Model, object>((ctx) => _contentManager.Get(mix2.Get(ctx), VersionOptions.Published)); }); }); }
protected override DriverResult Display(ConnectorPart part, string displayType, dynamic shapeHelper) { // TODO: Right now this has become irrelevant but it could be useful in some circumstances... return(ContentShape("Parts_Connector", () => { var rightItem = part.RightContent; if (rightItem == null) { // TODO: Notify this error? It will be logged as-is throw new Exception("Connection with invalid right item"); } return _origami.Build( _origami.ContentBuilder(rightItem).WithDisplayType(displayType), _origami.ContentShape(rightItem, displayType)); })); }
public void Subscribe(RootBuilder describe) { describe.Scope("ContentList", mix => { mix.Factory <RootShape, dynamic>((context) => Shape.ContentList(ListItems: ((ContentListViewModel)context.Get <Model, object>()).Rendered)); mix.Factory <ContentList, ShapeMetadata>((context) => new ShapeMetadata() { DisplayType = "Summary", }); mix.Factory <ContentList, ParadigmsContext>((context) => new ParadigmsContext()); mix.Factory <ContentList, ContentListQuery>((context) => new ContentListQuery() { Query = _contentManager.Query() }); mix.Factory <ContentList, IEnumerable <IContent> >((context) => { var query = context.Get <ContentList, ContentListQuery>(); var pager = context.Get <ContentList, PagerData>(); if (pager != null) { return(query.Query.Slice(pager.PageSize * (pager.Page - 1), pager.PageSize)); } return(query.Query.List()); }); mix.Factory <ContentModelBuilder, Func <IContent, ModelShapeBuilder> >((context) => (c) => Builder(c, context)); // TODO: Could support prefix here mix.Factory <ContentShapeBuilder, Func <IContent, object> >((context) => (s) => _origami.ContentShape(s, context.Get <ContentList, ShapeMetadata>().DisplayType)); mix.Factory <Model, object>((context) => { var source = context.Get <ContentList, IEnumerable <IContent> >(); var builder = context.Get <ContentModelBuilder, Func <IContent, ModelShapeBuilder> >(); return(new ContentListViewModel() { Rendered = source.Select(s => { var root = context.Get <ContentShapeBuilder, Func <IContent, object> >()(s); _origami.Build(builder(s), root); return root; }).ToList() }); }); // TODO: Get page size from settings mix.Factory <ContentList, PagerData>((context) => { var pager = new PagerData() { Page = 1, PageSize = 10 }; return(pager); }); mix.Parameter <int>("PageSize", (pageSize) => { pageSize.Mutate <ContentList, PagerData>((pager, context) => { pager.PageSize = pageSize.Get(context); }); }); mix.Parameter <int>("Page", (page) => { page.Mutate <ContentList, PagerData>((pager, context) => { pager.Page = page.Get(context); }); }); mix.Parameter <string>("ContentType", (ct) => { ct.Mutate <ContentList, ContentListQuery>((q, context) => q.Query = q.Query.ForType(ct.Get(context))); }); mix.Parameter <string>("ContentTypes", (ct) => { ct.Mutate <ContentList, ContentListQuery>((q, context) => q.Query = q.Query.ForType(ct.Get(context).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))); }); // Calculate total pages at end mix.Mutate <ContentList, PagerData>((pager, context) => { var query = context.Get <ContentList, ContentListQuery>(); pager.TotalPages = query.Query.Count() / pager.PageSize; // TODO: Check calculation }); }); }