mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Renaming methods to BuildDisplayModel, BuildEditorModel, UpdateEditorModel and models to ItemDisplayModel, ItemEditorModel
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043654
This commit is contained in:
@@ -175,7 +175,7 @@ namespace Orchard.Tests.Models {
|
||||
[Test]
|
||||
public void EditorsShouldBeOrderedByPositionAndDefaultPositionIsSix() {
|
||||
var alpha = _manager.New("alpha");
|
||||
var templates = _manager.GetDisplayViewModel(alpha, null, null).Displays;
|
||||
var templates = _manager.BuildDisplayModel(alpha, null, null).Displays;
|
||||
Assert.That(templates.Count(), Is.EqualTo(3));
|
||||
|
||||
var t0 = templates.First();
|
||||
|
@@ -93,7 +93,7 @@ namespace Orchard.Core.Common.Providers {
|
||||
}
|
||||
|
||||
|
||||
private void GetEditor(GetEditorViewModelContext context, CommonAspect instance) {
|
||||
private void GetEditor(BuildEditorModelContext context, CommonAspect instance) {
|
||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
if (!_authorizationService.CheckAccess(currentUser, Permissions.ChangeOwner)) {
|
||||
return;
|
||||
@@ -106,7 +106,7 @@ namespace Orchard.Core.Common.Providers {
|
||||
}
|
||||
|
||||
|
||||
private void UpdateEditor(UpdateEditorViewModelContext context, CommonAspect instance) {
|
||||
private void UpdateEditor(UpdateEditorModelContext context, CommonAspect instance) {
|
||||
// this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||
// kind of a loose rule of thumb. may not be sufficient
|
||||
instance.Record.ModifiedUtc = _clock.UtcNow;
|
||||
|
@@ -26,14 +26,14 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
public ActionResult Index(string tabName) {
|
||||
var model = new Orchard.Core.Settings.ViewModels.SettingsIndexViewModel {
|
||||
Site = _siteService.GetSiteSettings().As<SiteSettings>() };
|
||||
model.ItemView = _modelManager.GetEditorViewModel(model.Site, tabName);
|
||||
model.EditorModel = _modelManager.BuildEditorModel(model.Site, tabName);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[AcceptVerbs(HttpVerbs.Post)]
|
||||
public ActionResult Index(string tabName, FormCollection input) {
|
||||
var viewModel = new SettingsIndexViewModel { Site = _siteService.GetSiteSettings().As<SiteSettings>() };
|
||||
viewModel.ItemView = _modelManager.UpdateEditorViewModel(viewModel.Site.ContentItem, tabName, this);
|
||||
viewModel.EditorModel = _modelManager.UpdateEditorModel(viewModel.Site.ContentItem, tabName, this);
|
||||
|
||||
if (!TryUpdateModel(viewModel, input.ToValueProvider())) {
|
||||
return View(viewModel);
|
||||
|
@@ -8,7 +8,7 @@ using Orchard.Core.Settings.Models;
|
||||
namespace Orchard.Core.Settings.ViewModels {
|
||||
public class SettingsIndexViewModel : AdminViewModel {
|
||||
public SiteSettings Site { get; set; }
|
||||
public ItemEditorViewModel ItemView { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
|
@@ -18,6 +18,6 @@
|
||||
</ol>
|
||||
|
||||
|
||||
<% foreach(var e in Model.ItemView.Editors) {%>
|
||||
<% foreach(var e in Model.EditorModel.Editors) {%>
|
||||
<%=Html.EditorFor(m => e.Model, e.TemplateName, e.Prefix)%>
|
||||
<%} %>
|
||||
|
@@ -36,7 +36,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
public ActionResult List() {
|
||||
var model = new BlogsViewModel {
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.GetDisplayViewModel(b, null, "Summary"))
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.BuildDisplayModel(b, null, "Summary"))
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -44,7 +44,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
public ActionResult ListForAdmin() {
|
||||
var model = new BlogsForAdminViewModel {
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.GetDisplayViewModel(b, null, "SummaryAdmin"))
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.BuildDisplayModel(b, null, "SummaryAdmin"))
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -58,7 +58,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogViewModel {
|
||||
Blog = _contentManager.GetDisplayViewModel(blog, null, "Detail")
|
||||
Blog = _contentManager.BuildDisplayModel(blog, null, "Detail")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -72,7 +72,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogForAdminViewModel {
|
||||
Blog = _contentManager.GetDisplayViewModel(blog, null, "DetailAdmin")
|
||||
Blog = _contentManager.BuildDisplayModel(blog, null, "DetailAdmin")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -89,7 +89,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new CreateBlogViewModel {
|
||||
Blog = _contentManager.GetEditorViewModel(blog, null)
|
||||
Blog = _contentManager.BuildEditorModel(blog, null)
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -101,7 +101,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (!_authorizer.Authorize(Permissions.CreateBlog, T("Couldn't create blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
model.Blog = _contentManager.UpdateEditorViewModel(_contentManager.New<Blog>("blog"), null, this);
|
||||
model.Blog = _contentManager.UpdateEditorModel(_contentManager.New<Blog>("blog"), null, this);
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
@@ -127,7 +127,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogEditViewModel {
|
||||
Blog = _contentManager.GetEditorViewModel(blog, "")
|
||||
Blog = _contentManager.BuildEditorModel(blog, "")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -145,7 +145,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogEditViewModel {
|
||||
Blog = _contentManager.UpdateEditorViewModel(blog, "", this)
|
||||
Blog = _contentManager.UpdateEditorModel(blog, "", this)
|
||||
};
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
|
@@ -54,7 +54,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
var model = new BlogPostViewModel {
|
||||
Blog = blog,
|
||||
BlogPost = _contentManager.GetDisplayViewModel(post, null, "Detail")
|
||||
BlogPost = _contentManager.BuildDisplayModel(post, null, "Detail")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -93,7 +93,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var blogPost = _contentManager.GetEditorViewModel(_contentManager.New<BlogPost>("blogpost"), null);
|
||||
var blogPost = _contentManager.BuildEditorModel(_contentManager.New<BlogPost>("blogpost"), null);
|
||||
blogPost.Item.Blog = blog;
|
||||
|
||||
var model = new CreateBlogPostViewModel {
|
||||
@@ -116,7 +116,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
BlogPost blogPost = _contentManager.New<BlogPost>("blogpost");
|
||||
blogPost.Blog = blog;
|
||||
model.BlogPost = _contentManager.UpdateEditorViewModel(blogPost, null, this);
|
||||
model.BlogPost = _contentManager.UpdateEditorModel(blogPost, null, this);
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
@@ -146,7 +146,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogPostEditViewModel { Blog = blog, BlogPost = null };
|
||||
//model.ItemView = _contentManager.GetEditorViewModel(model.Post.ContentItem, null);
|
||||
//model.EditorModel = _contentManager.BuildEditorModel(model.Post.ContentItem, null);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogPostEditViewModel { Blog = blog, BlogPost = null };
|
||||
//model.ItemView = _contentManager.UpdateEditorViewModel(model.Post, null, this);
|
||||
//model.EditorModel = _contentManager.UpdateEditorModel(model.Post, null, this);
|
||||
|
||||
IValueProvider values = input.ToValueProvider();
|
||||
TryUpdateModel(model, values);
|
||||
|
@@ -57,14 +57,14 @@ namespace Orchard.Blogs.Models {
|
||||
switch(context.DisplayType) {
|
||||
case "Detail":
|
||||
context.AddDisplay(
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.GetDisplayViewModel(bp, null, "Summary"))) {
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, null, "Summary"))) {
|
||||
TemplateName = "BlogPostList",
|
||||
ZoneName = "body"
|
||||
});
|
||||
break;
|
||||
case "DetailAdmin":
|
||||
context.AddDisplay(
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.GetDisplayViewModel(bp, null, "SummaryAdmin"))) {
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, null, "SummaryAdmin"))) {
|
||||
TemplateName = "BlogPostListAdmin",
|
||||
ZoneName = "body"
|
||||
});
|
||||
|
@@ -4,6 +4,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogEditViewModel : AdminViewModel {
|
||||
public ItemEditorViewModel<Blog> Blog { get; set; }
|
||||
public ItemEditorModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -4,6 +4,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogForAdminViewModel : AdminViewModel {
|
||||
public ItemDisplayViewModel<Blog> Blog { get; set; }
|
||||
public ItemDisplayModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -5,6 +5,6 @@ using Orchard.Mvc.ViewModels;
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogPostEditViewModel : AdminViewModel {
|
||||
public Blog Blog { get; set; }
|
||||
public ItemEditorViewModel<BlogPost> BlogPost { get; set; }
|
||||
public ItemEditorModel<BlogPost> BlogPost { get; set; }
|
||||
}
|
||||
}
|
@@ -5,6 +5,6 @@ using Orchard.Mvc.ViewModels;
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogPostViewModel : BaseViewModel {
|
||||
public Blog Blog { get; set; }
|
||||
public ItemDisplayViewModel<BlogPost> BlogPost { get; set; }
|
||||
public ItemDisplayModel<BlogPost> BlogPost { get; set; }
|
||||
}
|
||||
}
|
@@ -4,6 +4,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogViewModel : BaseViewModel {
|
||||
public ItemDisplayViewModel<Blog> Blog { get; set; }
|
||||
public ItemDisplayModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -5,6 +5,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogsForAdminViewModel : AdminViewModel {
|
||||
public IEnumerable<ItemDisplayViewModel<Blog>> Blogs { get; set; }
|
||||
public IEnumerable<ItemDisplayModel<Blog>> Blogs { get; set; }
|
||||
}
|
||||
}
|
@@ -5,6 +5,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogsViewModel : BaseViewModel {
|
||||
public IEnumerable<ItemDisplayViewModel<Blog>> Blogs { get; set; }
|
||||
public IEnumerable<ItemDisplayModel<Blog>> Blogs { get; set; }
|
||||
}
|
||||
}
|
@@ -4,6 +4,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class CreateBlogPostViewModel : AdminViewModel {
|
||||
public ItemEditorViewModel<BlogPost> BlogPost { get; set; }
|
||||
public ItemEditorModel<BlogPost> BlogPost { get; set; }
|
||||
}
|
||||
}
|
@@ -4,6 +4,6 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class CreateBlogViewModel : AdminViewModel {
|
||||
public ItemEditorViewModel<Blog> Blog { get; set; }
|
||||
public ItemEditorModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<Blog>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<Blog>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<BlogPost>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemDisplayViewModel<BlogPost>>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemDisplayModel<BlogPost>>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemDisplayViewModel<BlogPost>>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemDisplayModel<BlogPost>>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<BlogPost>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<BlogPost>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Models"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<Blog>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<Blog>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorViewModel<Blog>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorViewModel<BlogPost>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
|
@@ -19,21 +19,21 @@ namespace Orchard.Comments.Models {
|
||||
Filters.Add(new ActivatingFilter<HasComments>("blogpost"));
|
||||
}
|
||||
|
||||
protected override void GetDisplayViewModel(GetDisplayViewModelContext context) {
|
||||
protected override void BuildDisplayModel(BuildDisplayModelContext context) {
|
||||
if (context.ContentItem.Has<HasComments>() == false) {
|
||||
return;
|
||||
}
|
||||
context.AddDisplay(new TemplateViewModel(context.ContentItem.Get<HasComments>()) { Position = "999" });
|
||||
}
|
||||
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
if (context.ContentItem.Has<HasComments>() == false) {
|
||||
return;
|
||||
}
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasComments>()));
|
||||
}
|
||||
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context) {
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
if (context.ContentItem.Has<HasComments>() == false) {
|
||||
return;
|
||||
}
|
||||
|
@@ -36,8 +36,8 @@ namespace Orchard.DevTools.Controllers {
|
||||
.Select(x => x.GetType())
|
||||
.SelectMany(x => AllTypes(x))
|
||||
.Distinct();
|
||||
model.DisplayView = _contentManager.GetDisplayViewModel(model.Item, null, null);
|
||||
model.EditorView = _contentManager.GetEditorViewModel(model.Item, null);
|
||||
model.DisplayModel = _contentManager.BuildDisplayModel(model.Item, null, null);
|
||||
model.EditorModel = _contentManager.BuildEditorModel(model.Item, null);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
@@ -3,10 +3,10 @@ using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.DevTools.Models {
|
||||
public class DebugLinkHandler : ContentHandler {
|
||||
protected override void GetDisplayViewModel(GetDisplayViewModelContext context) {
|
||||
protected override void BuildDisplayModel(BuildDisplayModelContext context) {
|
||||
context.AddDisplay(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { ZoneName = "recap", Position = "9999" });
|
||||
}
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
context.AddEditor(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { ZoneName = "recap", Position = "9999" });
|
||||
}
|
||||
}
|
||||
|
@@ -13,13 +13,13 @@ namespace Orchard.DevTools.ViewModels {
|
||||
|
||||
public IEnumerable<Type> PartTypes { get; set; }
|
||||
|
||||
public ItemDisplayViewModel DisplayView { get; set; }
|
||||
public ItemDisplayModel DisplayModel { get; set; }
|
||||
|
||||
public ItemEditorViewModel EditorView { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
|
||||
public IEnumerable<TemplateViewModel> Displays { get { return DisplayView.Displays; } }
|
||||
public IEnumerable<TemplateViewModel> Displays { get { return DisplayModel.Displays; } }
|
||||
|
||||
public IEnumerable<TemplateViewModel> Editors { get { return EditorView.Editors; } }
|
||||
public IEnumerable<TemplateViewModel> Editors { get { return EditorModel.Editors; } }
|
||||
|
||||
public object Locate(Type type) {
|
||||
return Item.ContentItem.Get(type);
|
||||
|
@@ -23,7 +23,7 @@ namespace Orchard.Media.Models {
|
||||
settings.Record.RootMediaFolder = "~/Media";
|
||||
}
|
||||
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
var model = context.ContentItem.As<MediaSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Media.Models {
|
||||
context.AddEditor(new TemplateViewModel(model.Record, "MediaSettings"));
|
||||
}
|
||||
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context) {
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
var model = context.ContentItem.As<MediaSettings>();
|
||||
if (model == null)
|
||||
return;
|
||||
|
@@ -29,7 +29,7 @@ namespace Orchard.Roles.Models {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRoles>();
|
||||
if (userRoles != null) {
|
||||
var roles =
|
||||
@@ -50,7 +50,7 @@ namespace Orchard.Roles.Models {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context) {
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRoles>();
|
||||
if (userRoles != null) {
|
||||
var viewModel = new UserRolesViewModel();
|
||||
|
@@ -32,7 +32,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
Pages = _contentManager.Query<SandboxPage, SandboxPageRecord>()
|
||||
.OrderBy(x => x.Name)
|
||||
.List()
|
||||
.Select(x => _contentManager.GetDisplayViewModel(x, null, "SummaryList"))
|
||||
.Select(x => _contentManager.BuildDisplayModel(x, null, "SummaryList"))
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
public ActionResult Show(int id) {
|
||||
var page = _contentManager.Get<SandboxPage>(id);
|
||||
var model = new PageShowViewModel {
|
||||
Page = _contentManager.GetDisplayViewModel(page, null, "Detail")
|
||||
Page = _contentManager.BuildDisplayModel(page, null, "Detail")
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
var page = _contentManager.Get<SandboxPage>(id);
|
||||
var model = new PageEditViewModel {
|
||||
Page = _contentManager.GetEditorViewModel(page, null)
|
||||
Page = _contentManager.BuildEditorModel(page, null)
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
var page = _contentManager.Get<SandboxPage>(id);
|
||||
var model = new PageEditViewModel {
|
||||
Page = _contentManager.UpdateEditorViewModel(page, null, this)
|
||||
Page = _contentManager.UpdateEditorModel(page, null, this)
|
||||
};
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
|
@@ -6,6 +6,6 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageEditViewModel : BaseViewModel {
|
||||
public ItemEditorViewModel<SandboxPage> Page { get; set; }
|
||||
public ItemEditorModel<SandboxPage> Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,6 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageIndexViewModel : BaseViewModel {
|
||||
public IEnumerable<ItemDisplayViewModel<SandboxPage>> Pages { get; set; }
|
||||
public IEnumerable<ItemDisplayModel<SandboxPage>> Pages { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,6 @@ using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageShowViewModel : BaseViewModel {
|
||||
public ItemDisplayViewModel<SandboxPage> Page { get; set; }
|
||||
public ItemDisplayModel<SandboxPage> Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<SandboxPage>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels" %>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<SandboxPage>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels" %>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorViewModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<SandboxPage>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels" %>
|
||||
|
@@ -102,7 +102,7 @@ namespace Orchard.Tags.Controllers {
|
||||
var tag = _tagService.GetTagByName(tagName);
|
||||
var items =
|
||||
_tagService.GetTaggedContentItems(tag.Id).Select(
|
||||
ic => _contentManager.GetDisplayViewModel(ic, null, "SummaryForSearch"));
|
||||
ic => _contentManager.BuildDisplayModel(ic, null, "SummaryForSearch"));
|
||||
|
||||
var viewModel = new TagsSearchViewModel {
|
||||
TagName = tag.TagName,
|
||||
|
@@ -37,14 +37,14 @@ namespace Orchard.Tags.Models {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
if (context.ContentItem.Has<HasTags>() == false) {
|
||||
return;
|
||||
}
|
||||
context.AddEditor(new TemplateViewModel(context.ContentItem.Get<HasTags>()) { Position = "0" });
|
||||
}
|
||||
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context) {
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
if (context.ContentItem.Has<HasTags>() == false) {
|
||||
return;
|
||||
}
|
||||
|
@@ -6,6 +6,6 @@ using Orchard.Mvc.ViewModels;
|
||||
namespace Orchard.Tags.ViewModels {
|
||||
public class TagsSearchViewModel : BaseViewModel {
|
||||
public string TagName { get; set; }
|
||||
public IEnumerable<ItemDisplayViewModel<IContent>> Items { get; set; }
|
||||
public IEnumerable<ItemDisplayModel<IContent>> Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ namespace Orchard.Users.Controllers {
|
||||
public ActionResult Create() {
|
||||
var user = _contentManager.New("user");
|
||||
var model = new UserCreateViewModel {
|
||||
ItemView = _contentManager.GetEditorViewModel(user, null)
|
||||
EditorModel = _contentManager.BuildEditorModel(user, null)
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace Orchard.Users.Controllers {
|
||||
ModelState.AddModelError("ConfirmPassword", T("Password confirmation must match").ToString());
|
||||
}
|
||||
if (ModelState.IsValid == false) {
|
||||
model.ItemView = _contentManager.UpdateEditorViewModel(_contentManager.New("user"), null, this);
|
||||
model.EditorModel = _contentManager.UpdateEditorModel(_contentManager.New("user"), null, this);
|
||||
return View(model);
|
||||
}
|
||||
var user = _membershipService.CreateUser(new CreateUserParams(
|
||||
@@ -69,7 +69,7 @@ namespace Orchard.Users.Controllers {
|
||||
model.Password,
|
||||
model.Email,
|
||||
null, null, true));
|
||||
model.ItemView = _contentManager.UpdateEditorViewModel(user, null, this);
|
||||
model.EditorModel = _contentManager.UpdateEditorModel(user, null, this);
|
||||
if (ModelState.IsValid == false) {
|
||||
//TODO: rollback transaction
|
||||
return View(model);
|
||||
@@ -80,14 +80,14 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
public ActionResult Edit(int id) {
|
||||
var model = new UserEditViewModel { User = _contentManager.Get<User>(id) };
|
||||
model.ItemView = _contentManager.GetEditorViewModel(model.User.ContentItem, null);
|
||||
model.EditorModel = _contentManager.BuildEditorModel(model.User.ContentItem, null);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Edit(int id, FormCollection input) {
|
||||
var model = new UserEditViewModel { User = _contentManager.Get<User>(id) };
|
||||
model.ItemView = _contentManager.UpdateEditorViewModel(model.User.ContentItem, null, this);
|
||||
model.EditorModel = _contentManager.UpdateEditorModel(model.User.ContentItem, null, this);
|
||||
|
||||
if (!TryUpdateModel(model, input.ToValueProvider())) {
|
||||
return View(model);
|
||||
|
@@ -18,6 +18,6 @@ namespace Orchard.Users.ViewModels {
|
||||
[Required, DataType(DataType.Password)]
|
||||
public string ConfirmPassword { get; set; }
|
||||
|
||||
public ItemEditorViewModel ItemView { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
}
|
||||
}
|
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Models;
|
||||
@@ -10,7 +8,7 @@ using Orchard.Users.Models;
|
||||
namespace Orchard.Users.ViewModels {
|
||||
public class UserEditViewModel : AdminViewModel {
|
||||
public User User { get; set; }
|
||||
public ItemEditorViewModel ItemView { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<%=Html.EditorFor(m=>m.Password, "inputPasswordLarge") %>
|
||||
<%=Html.EditorFor(m=>m.ConfirmPassword, "inputPasswordLarge") %>
|
||||
</fieldset><%
|
||||
foreach(var e in Model.ItemView.Editors) {
|
||||
foreach(var e in Model.EditorModel.Editors) {
|
||||
var editor = e;%>
|
||||
<fieldset>
|
||||
<%=Html.EditorFor(m => editor.Model, editor.TemplateName, editor.Prefix)%>
|
||||
|
@@ -7,6 +7,6 @@
|
||||
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||
</ol>
|
||||
|
||||
<% foreach(var e in Model.ItemView.Editors) {%>
|
||||
<% foreach(var e in Model.EditorModel.Editors) {%>
|
||||
<%=Html.EditorFor(m => e.Model, e.TemplateName, e.Prefix)%>
|
||||
<%} %>
|
||||
|
@@ -136,34 +136,34 @@ namespace Orchard.Models {
|
||||
return context.Metadata;
|
||||
}
|
||||
|
||||
public ItemDisplayViewModel<TContentPart> GetDisplayViewModel<TContentPart>(TContentPart content, string groupName, string displayType) where TContentPart : IContent {
|
||||
var itemView = new ItemDisplayViewModel<TContentPart> {Item = content, Displays = Enumerable.Empty<TemplateViewModel>()};
|
||||
var context = new GetDisplayViewModelContext(itemView, groupName, displayType);
|
||||
public ItemDisplayModel<TContentPart> BuildDisplayModel<TContentPart>(TContentPart content, string groupName, string displayType) where TContentPart : IContent {
|
||||
var itemView = new ItemDisplayModel<TContentPart> {Item = content, Displays = Enumerable.Empty<TemplateViewModel>()};
|
||||
var context = new BuildDisplayModelContext(itemView, groupName, displayType);
|
||||
foreach (var handler in Handlers) {
|
||||
handler.GetDisplayViewModel(context);
|
||||
handler.BuildDisplayModel(context);
|
||||
}
|
||||
context.ViewModel.Displays = OrderTemplates(context.ViewModel.Displays);
|
||||
context.DisplayModel.Displays = OrderTemplates(context.DisplayModel.Displays);
|
||||
return itemView;
|
||||
}
|
||||
|
||||
public ItemEditorViewModel<TContentPart> GetEditorViewModel<TContentPart>(TContentPart content, string groupName) where TContentPart : IContent {
|
||||
var itemView = new ItemEditorViewModel<TContentPart> { Item = content, Editors = Enumerable.Empty<TemplateViewModel>() };
|
||||
var context = new GetEditorViewModelContext(itemView, groupName);
|
||||
public ItemEditorModel<TContentPart> BuildEditorModel<TContentPart>(TContentPart content, string groupName) where TContentPart : IContent {
|
||||
var itemView = new ItemEditorModel<TContentPart> { Item = content, Editors = Enumerable.Empty<TemplateViewModel>() };
|
||||
var context = new BuildEditorModelContext(itemView, groupName);
|
||||
foreach (var handler in Handlers) {
|
||||
handler.GetEditorViewModel(context);
|
||||
handler.BuildEditorModel(context);
|
||||
}
|
||||
context.ViewModel.Editors = OrderTemplates(context.ViewModel.Editors);
|
||||
context.EditorModel.Editors = OrderTemplates(context.EditorModel.Editors);
|
||||
return itemView;
|
||||
}
|
||||
|
||||
public ItemEditorViewModel<TContentPart> UpdateEditorViewModel<TContentPart>(TContentPart content, string groupName, IUpdateModel updater) where TContentPart : IContent {
|
||||
var itemView = new ItemEditorViewModel<TContentPart> { Item = content, Editors = Enumerable.Empty<TemplateViewModel>() };
|
||||
public ItemEditorModel<TContentPart> UpdateEditorModel<TContentPart>(TContentPart content, string groupName, IUpdateModel updater) where TContentPart : IContent {
|
||||
var itemView = new ItemEditorModel<TContentPart> { Item = content, Editors = Enumerable.Empty<TemplateViewModel>() };
|
||||
|
||||
var context = new UpdateEditorViewModelContext(itemView, groupName, updater);
|
||||
var context = new UpdateEditorModelContext(itemView, groupName, updater);
|
||||
foreach (var handler in Handlers) {
|
||||
handler.UpdateEditorViewModel(context);
|
||||
handler.UpdateEditorModel(context);
|
||||
}
|
||||
context.ViewModel.Editors = OrderTemplates(context.ViewModel.Editors);
|
||||
context.EditorModel.Editors = OrderTemplates(context.EditorModel.Editors);
|
||||
return itemView;
|
||||
}
|
||||
|
||||
|
@@ -4,22 +4,22 @@ using System.Linq;
|
||||
using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class GetDisplayViewModelContext {
|
||||
public GetDisplayViewModelContext(ItemDisplayViewModel viewModel, string groupName, string displayType) {
|
||||
ContentItem = viewModel.Item;
|
||||
public class BuildDisplayModelContext {
|
||||
public BuildDisplayModelContext(ItemDisplayModel displayModel, string groupName, string displayType) {
|
||||
ContentItem = displayModel.Item;
|
||||
GroupName = groupName;
|
||||
DisplayType = displayType;
|
||||
ViewModel = viewModel;
|
||||
DisplayModel = displayModel;
|
||||
}
|
||||
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
public ItemDisplayViewModel ViewModel { get; set; }
|
||||
public ItemDisplayModel DisplayModel { get; set; }
|
||||
|
||||
|
||||
public void AddDisplay(TemplateViewModel display) {
|
||||
ViewModel.Displays = ViewModel.Displays.Concat(new[] { display });
|
||||
DisplayModel.Displays = DisplayModel.Displays.Concat(new[] { display });
|
||||
}
|
||||
}
|
||||
}
|
22
src/Orchard/Models/Driver/BuildEditorModelContext.cs
Normal file
22
src/Orchard/Models/Driver/BuildEditorModelContext.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class BuildEditorModelContext {
|
||||
public BuildEditorModelContext(ItemEditorModel editorModel, string groupName) {
|
||||
ContentItem = editorModel.Item;
|
||||
GroupName = groupName;
|
||||
EditorModel = editorModel;
|
||||
}
|
||||
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
|
||||
public void AddEditor(TemplateViewModel editor) {
|
||||
EditorModel.Editors = EditorModel.Editors.Concat(new[] { editor });
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,15 +36,15 @@ namespace Orchard.Models.Driver {
|
||||
protected void OnGetItemMetadata<TPart>(Action<GetItemMetadataContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineTemplateFilter<TPart> { OnGetItemMetadata = handler });
|
||||
}
|
||||
protected void OnGetDisplayViewModel<TPart>(Action<GetDisplayViewModelContext, TPart> handler) where TPart : class, IContent {
|
||||
protected void OnGetDisplayViewModel<TPart>(Action<BuildDisplayModelContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineTemplateFilter<TPart> { OnGetDisplayViewModel = handler });
|
||||
}
|
||||
|
||||
protected void OnGetEditorViewModel<TPart>(Action<GetEditorViewModelContext, TPart> handler) where TPart : class, IContent {
|
||||
protected void OnGetEditorViewModel<TPart>(Action<BuildEditorModelContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineTemplateFilter<TPart> { OnGetEditorViewModel = handler });
|
||||
}
|
||||
|
||||
protected void OnUpdateEditorViewModel<TPart>(Action<UpdateEditorViewModelContext, TPart> handler) where TPart : class, IContent {
|
||||
protected void OnUpdateEditorViewModel<TPart>(Action<UpdateEditorModelContext, TPart> handler) where TPart : class, IContent {
|
||||
Filters.Add(new InlineTemplateFilter<TPart> { OnUpdateEditorViewModel = handler });
|
||||
}
|
||||
|
||||
@@ -73,19 +73,19 @@ namespace Orchard.Models.Driver {
|
||||
|
||||
class InlineTemplateFilter<TPart> : TemplateFilterBase<TPart> where TPart : class, IContent {
|
||||
public Action<GetItemMetadataContext, TPart> OnGetItemMetadata { get; set; }
|
||||
public Action<GetDisplayViewModelContext, TPart> OnGetDisplayViewModel { get; set; }
|
||||
public Action<GetEditorViewModelContext, TPart> OnGetEditorViewModel { get; set; }
|
||||
public Action<UpdateEditorViewModelContext, TPart> OnUpdateEditorViewModel { get; set; }
|
||||
public Action<BuildDisplayModelContext, TPart> OnGetDisplayViewModel { get; set; }
|
||||
public Action<BuildEditorModelContext, TPart> OnGetEditorViewModel { get; set; }
|
||||
public Action<UpdateEditorModelContext, TPart> OnUpdateEditorViewModel { get; set; }
|
||||
protected override void GetItemMetadata(GetItemMetadataContext context, TPart instance) {
|
||||
if (OnGetItemMetadata != null) OnGetItemMetadata(context, instance);
|
||||
}
|
||||
protected override void GetDisplayViewModel(GetDisplayViewModelContext context, TPart instance) {
|
||||
protected override void BuildDisplayModel(BuildDisplayModelContext context, TPart instance) {
|
||||
if (OnGetDisplayViewModel != null) OnGetDisplayViewModel(context, instance);
|
||||
}
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context, TPart instance) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context, TPart instance) {
|
||||
if (OnGetEditorViewModel != null) OnGetEditorViewModel(context, instance);
|
||||
}
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context, TPart instance) {
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context, TPart instance) {
|
||||
if (OnUpdateEditorViewModel != null) OnUpdateEditorViewModel(context, instance);
|
||||
}
|
||||
}
|
||||
@@ -136,20 +136,20 @@ namespace Orchard.Models.Driver {
|
||||
filter.GetItemMetadata(context);
|
||||
GetItemMetadata(context);
|
||||
}
|
||||
void IContentHandler.GetDisplayViewModel(GetDisplayViewModelContext context) {
|
||||
void IContentHandler.BuildDisplayModel(BuildDisplayModelContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentTemplateFilter>())
|
||||
filter.GetDisplayViewModel(context);
|
||||
GetDisplayViewModel(context);
|
||||
filter.BuildDisplayModel(context);
|
||||
BuildDisplayModel(context);
|
||||
}
|
||||
void IContentHandler.GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
void IContentHandler.BuildEditorModel(BuildEditorModelContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentTemplateFilter>())
|
||||
filter.GetEditorViewModel(context);
|
||||
GetEditorViewModel(context);
|
||||
filter.BuildEditorModel(context);
|
||||
BuildEditorModel(context);
|
||||
}
|
||||
void IContentHandler.UpdateEditorViewModel(UpdateEditorViewModelContext context) {
|
||||
void IContentHandler.UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
foreach (var filter in Filters.OfType<IContentTemplateFilter>())
|
||||
filter.UpdateEditorViewModel(context);
|
||||
UpdateEditorViewModel(context);
|
||||
filter.UpdateEditorModel(context);
|
||||
UpdateEditorModel(context);
|
||||
}
|
||||
|
||||
protected virtual void Activating(ActivatingContentContext context) { }
|
||||
@@ -162,8 +162,8 @@ namespace Orchard.Models.Driver {
|
||||
protected virtual void Created(CreateContentContext context) { }
|
||||
|
||||
protected virtual void GetItemMetadata(GetItemMetadataContext context) { }
|
||||
protected virtual void GetDisplayViewModel(GetDisplayViewModelContext context) { }
|
||||
protected virtual void GetEditorViewModel(GetEditorViewModelContext context) { }
|
||||
protected virtual void UpdateEditorViewModel(UpdateEditorViewModelContext context) {}
|
||||
protected virtual void BuildDisplayModel(BuildDisplayModelContext context) { }
|
||||
protected virtual void BuildEditorModel(BuildEditorModelContext context) { }
|
||||
protected virtual void UpdateEditorModel(UpdateEditorModelContext context) {}
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@ namespace Orchard.Models.Driver {
|
||||
private readonly string _templateName;
|
||||
private readonly string _prefix;
|
||||
private readonly string[] _displayTypes;
|
||||
private Action<UpdateEditorViewModelContext, ItemEditorViewModel<TContent>> _updater;
|
||||
private Action<UpdateEditorModelContext, ItemEditorModel<TContent>> _updater;
|
||||
|
||||
public ContentItemTemplates(string templateName, params string[] displayTypes) {
|
||||
_templateName = templateName;
|
||||
@@ -16,16 +16,16 @@ namespace Orchard.Models.Driver {
|
||||
_updater = (context, viewModel) => context.Updater.TryUpdateModel(viewModel, "", null, null);
|
||||
}
|
||||
|
||||
protected override void GetDisplayViewModel(GetDisplayViewModelContext context, TContent instance) {
|
||||
protected override void BuildDisplayModel(BuildDisplayModelContext context, TContent instance) {
|
||||
var longestMatch = LongestMatch(context.DisplayType);
|
||||
context.ViewModel.TemplateName = _templateName + longestMatch;
|
||||
context.ViewModel.Prefix = _prefix;
|
||||
context.DisplayModel.TemplateName = _templateName + longestMatch;
|
||||
context.DisplayModel.Prefix = _prefix;
|
||||
|
||||
if (context.ViewModel.GetType() != typeof(ItemDisplayViewModel<TContent>)) {
|
||||
context.ViewModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemDisplayViewModel<TContent>>(
|
||||
if (context.DisplayModel.GetType() != typeof(ItemDisplayModel<TContent>)) {
|
||||
context.DisplayModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemDisplayModel<TContent>>(
|
||||
html.ViewContext,
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemDisplayViewModel<TContent>(viewModel)) },
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemDisplayModel<TContent>(viewModel)) },
|
||||
html.RouteCollection);
|
||||
};
|
||||
}
|
||||
@@ -45,18 +45,29 @@ namespace Orchard.Models.Driver {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context, TContent instance) {
|
||||
context.ViewModel.TemplateName = _templateName;
|
||||
context.ViewModel.Prefix = _prefix;
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context, TContent instance) {
|
||||
context.EditorModel.TemplateName = _templateName;
|
||||
context.EditorModel.Prefix = _prefix;
|
||||
if (context.EditorModel.GetType() != typeof(ItemEditorModel<TContent>)) {
|
||||
context.EditorModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemEditorModel<TContent>>(
|
||||
html.ViewContext,
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemEditorModel<TContent>(viewModel)) },
|
||||
html.RouteCollection);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context, TContent instance) {
|
||||
_updater(context, (ItemEditorViewModel<TContent>)context.ViewModel);
|
||||
context.ViewModel.TemplateName = _templateName;
|
||||
context.ViewModel.Prefix = _prefix;
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context, TContent instance) {
|
||||
if (context.EditorModel is ItemEditorModel<TContent>)
|
||||
_updater(context, (ItemEditorModel<TContent>)context.EditorModel);
|
||||
else
|
||||
_updater(context, new ItemEditorModel<TContent>(context.EditorModel));
|
||||
context.EditorModel.TemplateName = _templateName;
|
||||
context.EditorModel.Prefix = _prefix;
|
||||
}
|
||||
|
||||
public void Updater(Action<UpdateEditorViewModelContext, ItemEditorViewModel<TContent>> updater) {
|
||||
public void Updater(Action<UpdateEditorModelContext, ItemEditorModel<TContent>> updater) {
|
||||
_updater = updater;
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class GetEditorViewModelContext {
|
||||
public GetEditorViewModelContext(ItemEditorViewModel viewModel, string groupName) {
|
||||
ContentItem = viewModel.Item;
|
||||
GroupName = groupName;
|
||||
ViewModel = viewModel;
|
||||
}
|
||||
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
public ItemEditorViewModel ViewModel { get; set; }
|
||||
|
||||
public void AddEditor(TemplateViewModel editor) {
|
||||
ViewModel.Editors = ViewModel.Editors.Concat(new[] { editor });
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,8 +12,8 @@ namespace Orchard.Models.Driver {
|
||||
void Loaded(LoadContentContext context);
|
||||
|
||||
void GetItemMetadata(GetItemMetadataContext context);
|
||||
void GetDisplayViewModel(GetDisplayViewModelContext context);
|
||||
void GetEditorViewModel(GetEditorViewModelContext context);
|
||||
void UpdateEditorViewModel(UpdateEditorViewModelContext context);
|
||||
void BuildDisplayModel(BuildDisplayModelContext context);
|
||||
void BuildEditorModel(BuildEditorModelContext context);
|
||||
void UpdateEditorModel(UpdateEditorModelContext context);
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ using System.Text;
|
||||
namespace Orchard.Models.Driver {
|
||||
interface IContentTemplateFilter : IContentFilter {
|
||||
void GetItemMetadata(GetItemMetadataContext context);
|
||||
void GetDisplayViewModel(GetDisplayViewModelContext context);
|
||||
void GetEditorViewModel(GetEditorViewModelContext context);
|
||||
void UpdateEditorViewModel(UpdateEditorViewModelContext context);
|
||||
void BuildDisplayModel(BuildDisplayModelContext context);
|
||||
void BuildEditorModel(BuildEditorModelContext context);
|
||||
void UpdateEditorModel(UpdateEditorModelContext context);
|
||||
}
|
||||
}
|
||||
|
@@ -7,28 +7,28 @@ namespace Orchard.Models.Driver {
|
||||
public abstract class TemplateFilterBase<TPart> : IContentTemplateFilter where TPart : class, IContent {
|
||||
|
||||
protected virtual void GetItemMetadata(GetItemMetadataContext context, TPart instance) { }
|
||||
protected virtual void GetDisplayViewModel(GetDisplayViewModelContext context, TPart instance) { }
|
||||
protected virtual void GetEditorViewModel(GetEditorViewModelContext context, TPart instance) { }
|
||||
protected virtual void UpdateEditorViewModel(UpdateEditorViewModelContext context, TPart instance) { }
|
||||
protected virtual void BuildDisplayModel(BuildDisplayModelContext context, TPart instance) { }
|
||||
protected virtual void BuildEditorModel(BuildEditorModelContext context, TPart instance) { }
|
||||
protected virtual void UpdateEditorModel(UpdateEditorModelContext context, TPart instance) { }
|
||||
|
||||
void IContentTemplateFilter.GetItemMetadata(GetItemMetadataContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
GetItemMetadata(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentTemplateFilter.GetDisplayViewModel(GetDisplayViewModelContext context) {
|
||||
void IContentTemplateFilter.BuildDisplayModel(BuildDisplayModelContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
GetDisplayViewModel(context, context.ContentItem.As<TPart>());
|
||||
BuildDisplayModel(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentTemplateFilter.GetEditorViewModel(GetEditorViewModelContext context) {
|
||||
void IContentTemplateFilter.BuildEditorModel(BuildEditorModelContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
GetEditorViewModel(context, context.ContentItem.As<TPart>());
|
||||
BuildEditorModel(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
void IContentTemplateFilter.UpdateEditorViewModel(UpdateEditorViewModelContext context) {
|
||||
void IContentTemplateFilter.UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
if (context.ContentItem.Is<TPart>())
|
||||
UpdateEditorViewModel(context, context.ContentItem.As<TPart>());
|
||||
UpdateEditorModel(context, context.ContentItem.As<TPart>());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,11 +9,11 @@ namespace Orchard.Models.Driver {
|
||||
_prefix = prefix;
|
||||
}
|
||||
|
||||
protected override void GetEditorViewModel(GetEditorViewModelContext context, ContentPart<TRecord> part) {
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context, ContentPart<TRecord> part) {
|
||||
context.AddEditor(new TemplateViewModel(part.Record, _prefix));
|
||||
}
|
||||
|
||||
protected override void UpdateEditorViewModel(UpdateEditorViewModelContext context, ContentPart<TRecord> part) {
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context, ContentPart<TRecord> part) {
|
||||
context.Updater.TryUpdateModel(part.Record, _prefix, null, null);
|
||||
context.AddEditor(new TemplateViewModel(part.Record, _prefix));
|
||||
}
|
||||
|
12
src/Orchard/Models/Driver/UpdateEditorModelContext.cs
Normal file
12
src/Orchard/Models/Driver/UpdateEditorModelContext.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class UpdateEditorModelContext : BuildEditorModelContext {
|
||||
public UpdateEditorModelContext(ItemEditorModel editorModel, string groupName, IUpdateModel updater)
|
||||
: base(editorModel, groupName) {
|
||||
Updater = updater;
|
||||
}
|
||||
|
||||
public IUpdateModel Updater { get; set; }
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Models.Driver {
|
||||
public class UpdateEditorViewModelContext : GetEditorViewModelContext {
|
||||
public UpdateEditorViewModelContext(ItemEditorViewModel viewModel, string groupName, IUpdateModel updater)
|
||||
: base(viewModel, groupName) {
|
||||
Updater = updater;
|
||||
}
|
||||
|
||||
public IUpdateModel Updater { get; set; }
|
||||
}
|
||||
}
|
@@ -16,8 +16,8 @@ namespace Orchard.Models {
|
||||
|
||||
ContentItemMetadata GetItemMetadata(IContent contentItem);
|
||||
|
||||
ItemDisplayViewModel<TContent> GetDisplayViewModel<TContent>(TContent content, string groupName, string displayType) where TContent : IContent;
|
||||
ItemEditorViewModel<TContent> GetEditorViewModel<TContent>(TContent content, string groupName) where TContent : IContent;
|
||||
ItemEditorViewModel<TContent> UpdateEditorViewModel<TContent>(TContent content, string groupName, IUpdateModel updater) where TContent : IContent;
|
||||
ItemDisplayModel<TContent> BuildDisplayModel<TContent>(TContent content, string groupName, string displayType) where TContent : IContent;
|
||||
ItemEditorModel<TContent> BuildEditorModel<TContent>(TContent content, string groupName) where TContent : IContent;
|
||||
ItemEditorModel<TContent> UpdateEditorModel<TContent>(TContent content, string groupName, IUpdateModel updater) where TContent : IContent;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
namespace Orchard.Models.Records {
|
||||
public abstract class ContentPartRecord : ContentPart {
|
||||
public abstract class ContentPartRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual ContentItemRecord ContentItemRecord { get; set; }
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ namespace Orchard.Models.Records {
|
||||
var mapping = (AutoMapping<T>)mappingObj;
|
||||
mapping.Id(x => x.Id).GeneratedBy.Foreign("ContentItemRecord");
|
||||
mapping.HasOne(x => x.ContentItemRecord).Constrained();
|
||||
mapping.IgnoreProperty(x => x.ContentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,20 +4,20 @@ using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Models.ViewModels {
|
||||
public class ItemDisplayViewModel {
|
||||
public class ItemDisplayModel {
|
||||
private ContentItem _item;
|
||||
|
||||
protected ItemDisplayViewModel() {
|
||||
protected ItemDisplayModel() {
|
||||
}
|
||||
|
||||
protected ItemDisplayViewModel(ItemDisplayViewModel viewModel) {
|
||||
TemplateName = viewModel.TemplateName;
|
||||
Prefix = viewModel.Prefix;
|
||||
Displays = viewModel.Displays.ToArray();
|
||||
Item = viewModel.Item;
|
||||
protected ItemDisplayModel(ItemDisplayModel displayModel) {
|
||||
TemplateName = displayModel.TemplateName;
|
||||
Prefix = displayModel.Prefix;
|
||||
Displays = displayModel.Displays.ToArray();
|
||||
Item = displayModel.Item;
|
||||
}
|
||||
|
||||
public ItemDisplayViewModel(ContentItem item) {
|
||||
public ItemDisplayModel(ContentItem item) {
|
||||
Item = item;
|
||||
}
|
||||
|
||||
@@ -30,20 +30,20 @@ namespace Orchard.Models.ViewModels {
|
||||
_item = value;
|
||||
}
|
||||
|
||||
public Func<HtmlHelper, ItemDisplayViewModel, HtmlHelper> Adaptor { get; set; }
|
||||
public Func<HtmlHelper, ItemDisplayModel, HtmlHelper> Adaptor { get; set; }
|
||||
public string TemplateName { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public IEnumerable<TemplateViewModel> Displays { get; set; }
|
||||
}
|
||||
|
||||
public class ItemDisplayViewModel<TPart> : ItemDisplayViewModel where TPart : IContent {
|
||||
public class ItemDisplayModel<TPart> : ItemDisplayModel where TPart : IContent {
|
||||
private TPart _item;
|
||||
|
||||
public ItemDisplayViewModel() {
|
||||
public ItemDisplayModel() {
|
||||
|
||||
}
|
||||
public ItemDisplayViewModel(ItemDisplayViewModel viewModel)
|
||||
: base(viewModel) {
|
||||
public ItemDisplayModel(ItemDisplayModel displayModel)
|
||||
: base(displayModel) {
|
||||
}
|
||||
|
||||
public new TPart Item {
|
@@ -1,8 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Models.ViewModels {
|
||||
public class ItemEditorViewModel {
|
||||
public class ItemEditorModel {
|
||||
private ContentItem _item;
|
||||
|
||||
protected ItemEditorModel() {
|
||||
}
|
||||
|
||||
protected ItemEditorModel(ItemEditorModel editorModel) {
|
||||
TemplateName = editorModel.TemplateName;
|
||||
Prefix = editorModel.Prefix;
|
||||
Editors = editorModel.Editors.ToArray();
|
||||
Item = editorModel.Item;
|
||||
}
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { SetItem(value); }
|
||||
@@ -12,14 +26,23 @@ namespace Orchard.Models.ViewModels {
|
||||
_item = value;
|
||||
}
|
||||
|
||||
public Func<HtmlHelper, ItemEditorModel, HtmlHelper> Adaptor { get; set; }
|
||||
public string TemplateName { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
|
||||
public IEnumerable<TemplateViewModel> Editors { get; set; }
|
||||
}
|
||||
|
||||
public class ItemEditorViewModel<TPart> : ItemEditorViewModel where TPart : IContent {
|
||||
public class ItemEditorModel<TPart> : ItemEditorModel where TPart : IContent {
|
||||
private TPart _item;
|
||||
|
||||
|
||||
public ItemEditorModel() {
|
||||
|
||||
}
|
||||
public ItemEditorModel(ItemEditorModel editorModel)
|
||||
: base(editorModel) {
|
||||
}
|
||||
|
||||
public new TPart Item {
|
||||
get { return _item; }
|
||||
set { SetItem(value.ContentItem); }
|
@@ -45,7 +45,7 @@ namespace Orchard.Mvc.Html {
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemDisplayTemplate(this HtmlHelper html, IContent content, string template) {
|
||||
return html.Partial(string.Format("{0}/{1}", content.ContentItem.ContentType, template), new ItemDisplayViewModel(content.ContentItem));
|
||||
return html.Partial(string.Format("{0}/{1}", content.ContentItem.ContentType, template), new ItemDisplayModel(content.ContentItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,10 +8,10 @@ using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ItemDisplayExtensions {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, TItemViewModel itemViewModel) where TItemViewModel : ItemDisplayViewModel {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, TItemViewModel itemViewModel) where TItemViewModel : ItemDisplayModel {
|
||||
return html.DisplayForItem(x => itemViewModel);
|
||||
}
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemViewModel>> expression) where TItemViewModel : ItemDisplayViewModel {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemViewModel>> expression) where TItemViewModel : ItemDisplayModel {
|
||||
|
||||
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
|
||||
var model = (TItemViewModel)metadata.Model;
|
||||
@@ -24,22 +24,22 @@ namespace Orchard.Mvc.Html {
|
||||
}
|
||||
|
||||
|
||||
public static MvcHtmlString DisplayZone<TModel>(this HtmlHelper<TModel> html, string zoneName) where TModel : ItemDisplayViewModel {
|
||||
public static MvcHtmlString DisplayZone<TModel>(this HtmlHelper<TModel> html, string zoneName) where TModel : ItemDisplayModel {
|
||||
var templates = html.ViewData.Model.Displays.Where(x => x.ZoneName == zoneName && x.WasUsed == false);
|
||||
return DisplayZoneImplementation(html, templates);
|
||||
}
|
||||
|
||||
public static MvcHtmlString DisplayZonesAny<TModel>(this HtmlHelper<TModel> html) where TModel : ItemDisplayViewModel {
|
||||
public static MvcHtmlString DisplayZonesAny<TModel>(this HtmlHelper<TModel> html) where TModel : ItemDisplayModel {
|
||||
var templates = html.ViewData.Model.Displays.Where(x => x.WasUsed == false);
|
||||
return DisplayZoneImplementation(html, templates);
|
||||
}
|
||||
|
||||
public static MvcHtmlString DisplayZones<TModel>(this HtmlHelper<TModel> html, params string[] include) where TModel : ItemDisplayViewModel {
|
||||
public static MvcHtmlString DisplayZones<TModel>(this HtmlHelper<TModel> html, params string[] include) where TModel : ItemDisplayModel {
|
||||
var templates = html.ViewData.Model.Displays.Where(x => include.Contains(x.ZoneName) && x.WasUsed == false);
|
||||
return DisplayZoneImplementation(html, templates);
|
||||
}
|
||||
|
||||
public static MvcHtmlString DisplayZonesExcept<TModel>(this HtmlHelper<TModel> html, params string[] exclude) where TModel : ItemDisplayViewModel {
|
||||
public static MvcHtmlString DisplayZonesExcept<TModel>(this HtmlHelper<TModel> html, params string[] exclude) where TModel : ItemDisplayModel {
|
||||
var templates = html.ViewData.Model.Displays.Where(x => !exclude.Contains(x.ZoneName) && x.WasUsed == false);
|
||||
return DisplayZoneImplementation(html, templates);
|
||||
}
|
||||
|
@@ -8,31 +8,35 @@ using Orchard.Models.ViewModels;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ItemEditorExtensions {
|
||||
public static MvcHtmlString EditorForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemViewModel>> expression) where TItemViewModel : ItemEditorViewModel {
|
||||
public static MvcHtmlString EditorForItem<TModel, TItemViewModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemViewModel>> expression) where TItemViewModel : ItemEditorModel {
|
||||
|
||||
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
|
||||
var model = (TItemViewModel)metadata.Model;
|
||||
|
||||
if (model.Adaptor != null) {
|
||||
return model.Adaptor(html, model).EditorForModel(model.TemplateName, model.Prefix ?? "");
|
||||
}
|
||||
|
||||
return html.EditorFor(expression, model.TemplateName, model.Prefix ?? "");
|
||||
}
|
||||
|
||||
|
||||
public static MvcHtmlString EditorZone<TModel>(this HtmlHelper<TModel> html, string zoneName) where TModel : ItemEditorViewModel {
|
||||
public static MvcHtmlString EditorZone<TModel>(this HtmlHelper<TModel> html, string zoneName) where TModel : ItemEditorModel {
|
||||
var templates = html.ViewData.Model.Editors.Where(x => x.ZoneName == zoneName && x.WasUsed == false);
|
||||
return EditorZoneImplementation(html, templates);
|
||||
}
|
||||
|
||||
public static MvcHtmlString EditorZonesAny<TModel>(this HtmlHelper<TModel> html) where TModel : ItemEditorViewModel {
|
||||
public static MvcHtmlString EditorZonesAny<TModel>(this HtmlHelper<TModel> html) where TModel : ItemEditorModel {
|
||||
var templates = html.ViewData.Model.Editors.Where(x => x.WasUsed == false);
|
||||
return EditorZoneImplementation(html, templates);
|
||||
}
|
||||
|
||||
public static MvcHtmlString EditorZones<TModel>(this HtmlHelper<TModel> html, params string[] include) where TModel : ItemEditorViewModel {
|
||||
public static MvcHtmlString EditorZones<TModel>(this HtmlHelper<TModel> html, params string[] include) where TModel : ItemEditorModel {
|
||||
var templates = html.ViewData.Model.Editors.Where(x => include.Contains(x.ZoneName) && x.WasUsed == false);
|
||||
return EditorZoneImplementation(html, templates);
|
||||
}
|
||||
|
||||
public static MvcHtmlString EditorZonesExcept<TModel>(this HtmlHelper<TModel> html, params string[] exclude) where TModel : ItemEditorViewModel {
|
||||
public static MvcHtmlString EditorZonesExcept<TModel>(this HtmlHelper<TModel> html, params string[] exclude) where TModel : ItemEditorModel {
|
||||
var templates = html.ViewData.Model.Editors.Where(x => !exclude.Contains(x.ZoneName) && x.WasUsed == false);
|
||||
return EditorZoneImplementation(html, templates);
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@
|
||||
<Compile Include="Models\Driver\ActivatedContentContext.cs" />
|
||||
<Compile Include="Models\Driver\ActivatingFilter.cs" />
|
||||
<Compile Include="Models\Driver\ContentItemTemplates.cs" />
|
||||
<Compile Include="Models\Driver\GetDisplayViewModelContext.cs" />
|
||||
<Compile Include="Models\Driver\BuildDisplayModelContext.cs" />
|
||||
<Compile Include="Models\Driver\GetItemMetadataContext.cs" />
|
||||
<Compile Include="Models\Driver\IContentActivatingFilter.cs" />
|
||||
<Compile Include="Models\Driver\IContentFilter.cs" />
|
||||
@@ -166,7 +166,7 @@
|
||||
<Compile Include="Models\Driver\ContentItemBuilder.cs" />
|
||||
<Compile Include="Models\Driver\ContentHandler.cs" />
|
||||
<Compile Include="Models\Driver\ActivatingContentContext.cs" />
|
||||
<Compile Include="Models\Driver\GetEditorViewModelContext.cs" />
|
||||
<Compile Include="Models\Driver\BuildEditorModelContext.cs" />
|
||||
<Compile Include="Models\Driver\StorageFilter.cs" />
|
||||
<Compile Include="Models\Driver\StorageFilterBase.cs" />
|
||||
<Compile Include="Models\Driver\TemplateFilterBase.cs" />
|
||||
@@ -183,10 +183,10 @@
|
||||
<Compile Include="Models\Records\ContentPartRecordAlteration.cs" />
|
||||
<Compile Include="Models\Records\ContentTypeRecord.cs" />
|
||||
<Compile Include="Models\Records\ContentItemRecord.cs" />
|
||||
<Compile Include="Models\Driver\UpdateEditorViewModelContext.cs" />
|
||||
<Compile Include="Models\Driver\UpdateEditorModelContext.cs" />
|
||||
<Compile Include="Models\ViewModels\TemplateViewModel.cs" />
|
||||
<Compile Include="Models\ViewModels\ItemDisplayViewModel.cs" />
|
||||
<Compile Include="Models\ViewModels\ItemEditorViewModel.cs" />
|
||||
<Compile Include="Models\ViewModels\ItemDisplayModel.cs" />
|
||||
<Compile Include="Models\ViewModels\ItemEditorModel.cs" />
|
||||
<Compile Include="Mvc\Html\ContentItemExtensions.cs" />
|
||||
<Compile Include="Mvc\Html\ItemDisplayExtensions.cs" />
|
||||
<Compile Include="Mvc\Html\ItemEditorExtensions.cs" />
|
||||
|
Reference in New Issue
Block a user