mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Once the ItemDisplayModel and ItemEditorModel were converted to use ZoneCollection they became identical. Collapsing them into the same ItemViewModel class.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044987
This commit is contained in:
@@ -11,7 +11,7 @@ using NUnit.Framework;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.Tests.ContentManagement {
|
||||
@@ -43,7 +43,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
});
|
||||
var contentHandler = _container.Resolve<IContentHandler>();
|
||||
|
||||
var ctx = new BuildDisplayModelContext(new ItemDisplayModel(new ContentItem()), null);
|
||||
var ctx = new BuildDisplayModelContext(new ItemViewModel(new ContentItem()), null);
|
||||
|
||||
driver1.Verify(x => x.BuildDisplayModel(ctx), Times.Never());
|
||||
contentHandler.BuildDisplayModel(ctx);
|
||||
@@ -60,12 +60,12 @@ namespace Orchard.Tests.ContentManagement {
|
||||
var item = new ContentItem();
|
||||
item.Weld(new StubPart { Foo = new[] { "a", "b", "c" } });
|
||||
|
||||
var ctx = new BuildDisplayModelContext(new ItemDisplayModel(item), "");
|
||||
Assert.That(ctx.DisplayModel.Zones.Count(), Is.EqualTo(0));
|
||||
var ctx = new BuildDisplayModelContext(new ItemViewModel(item), "");
|
||||
Assert.That(ctx.ViewModel.Zones.Count(), Is.EqualTo(0));
|
||||
contentHandler.BuildDisplayModel(ctx);
|
||||
Assert.That(ctx.DisplayModel.Zones.Count(), Is.EqualTo(1));
|
||||
Assert.That(ctx.DisplayModel.Zones.Single().Key, Is.EqualTo("topmeta"));
|
||||
Assert.That(ctx.DisplayModel.Zones.Single().Value.Items.OfType<PartDisplayZoneItem>().Single().Prefix, Is.EqualTo("Stub"));
|
||||
Assert.That(ctx.ViewModel.Zones.Count(), Is.EqualTo(1));
|
||||
Assert.That(ctx.ViewModel.Zones.Single().Key, Is.EqualTo("topmeta"));
|
||||
Assert.That(ctx.ViewModel.Zones.Single().Value.Items.OfType<PartDisplayZoneItem>().Single().Prefix, Is.EqualTo("Stub"));
|
||||
|
||||
}
|
||||
|
||||
|
@@ -26,14 +26,14 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
var model = new Orchard.Core.Settings.ViewModels.SettingsIndexViewModel {
|
||||
Site = _siteService.GetSiteSettings().As<SiteSettings>()
|
||||
};
|
||||
model.EditorModel = _modelManager.BuildEditorModel(model.Site);
|
||||
model.ViewModel = _modelManager.BuildEditorModel(model.Site);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Index")]
|
||||
public ActionResult IndexPOST(string tabName) {
|
||||
var viewModel = new SettingsIndexViewModel { Site = _siteService.GetSiteSettings().As<SiteSettings>() };
|
||||
viewModel.EditorModel = _modelManager.UpdateEditorModel(viewModel.Site.ContentItem, this);
|
||||
viewModel.ViewModel = _modelManager.UpdateEditorModel(viewModel.Site.ContentItem, this);
|
||||
|
||||
if (!TryUpdateModel(viewModel)) {
|
||||
return View(viewModel);
|
||||
|
@@ -1,13 +1,12 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Core.Settings.Models;
|
||||
|
||||
namespace Orchard.Core.Settings.ViewModels {
|
||||
public class SettingsIndexViewModel : AdminViewModel {
|
||||
public SiteSettings Site { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
public ItemViewModel ViewModel { get; set; }
|
||||
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
|
@@ -24,7 +24,7 @@
|
||||
<%=Html.EditorFor(s=>s.Id) %>
|
||||
</fieldset>
|
||||
|
||||
<%= Html.EditorForItem(Model.EditorModel) %>
|
||||
<%= Html.EditorForItem(Model.ViewModel) %>
|
||||
|
||||
<fieldset>
|
||||
<input class="button" type="submit" value="Save" />
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<SiteSettings>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<SiteSettings>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Core.Settings.Models"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<% Html.Zone("primary"); %>
|
||||
<% Html.ZonesAny(); %>
|
||||
|
@@ -6,7 +6,7 @@ using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.Controllers {
|
||||
[UsedImplicitly]
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
protected override DriverResult Display(Blog blog, string displayType) {
|
||||
|
||||
IEnumerable<ItemDisplayModel<BlogPost>> blogPosts = null;
|
||||
IEnumerable<ItemViewModel<BlogPost>> blogPosts = null;
|
||||
if (displayType.StartsWith("DetailAdmin")) {
|
||||
blogPosts = _blogPostService.Get(blog)
|
||||
.Select(bp => _contentManager.BuildDisplayModel(bp, "SummaryAdmin"));
|
||||
|
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class AdminBlogsViewModel : AdminViewModel {
|
||||
public IEnumerable<ItemDisplayModel<Blog>> Blogs { get; set; }
|
||||
public IEnumerable<ItemViewModel<Blog>> Blogs { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogEditViewModel : AdminViewModel {
|
||||
public ItemEditorModel<Blog> Blog { get; set; }
|
||||
public ItemViewModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogForAdminViewModel : AdminViewModel {
|
||||
public ItemDisplayModel<Blog> Blog { get; set; }
|
||||
public ItemViewModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogPostEditViewModel : AdminViewModel {
|
||||
public ItemEditorModel<BlogPost> BlogPost { get; set; }
|
||||
public ItemViewModel<BlogPost> BlogPost { get; set; }
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogPostViewModel : BaseViewModel {
|
||||
public Blog Blog { get; set; }
|
||||
public ItemDisplayModel<BlogPost> BlogPost { get; set; }
|
||||
public ItemViewModel<BlogPost> BlogPost { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogViewModel : BaseViewModel {
|
||||
public ItemDisplayModel<Blog> Blog { get; set; }
|
||||
public ItemViewModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogsViewModel : BaseViewModel {
|
||||
public IEnumerable<ItemDisplayModel<Blog>> Blogs { get; set; }
|
||||
public IEnumerable<ItemViewModel<Blog>> Blogs { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class CreateBlogPostViewModel : AdminViewModel {
|
||||
public ItemEditorModel<BlogPost> BlogPost { get; set; }
|
||||
public ItemViewModel<BlogPost> BlogPost { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class CreateBlogViewModel : AdminViewModel {
|
||||
public ItemEditorModel<Blog> Blog { get; set; }
|
||||
public ItemViewModel<Blog> Blog { get; set; }
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%-- todo: (heskew) get what actions we can out of the h2 :| --%>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><%=Html.Link(Html.Encode(Model.Item.Name), Url.Blog(Model.Item.Slug)) %></h3>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><a href="<%=Url.BlogForAdmin(Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Name) %></a></h3>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<Blog>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<div class="manage"><a href="<%=Url.BlogEdit(Model.Item.Slug) %>" class="ibutton edit">edit</a></div>
|
||||
<h1><%=Html.TitleForPage(Model.Item.Name) %></h1>
|
||||
<div><%=Html.Encode(Model.Item.Description) %></div>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Title) %></a></h3>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||
<%@ Import Namespace="Orchard.Core.Common.Models"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<h3><a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Title)%></a></h3>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<div class="manage"><a href="<%=Url.BlogPostEdit(Model.Item.Blog.Slug, Model.Item.Slug) %>" class="ibutton edit">edit</a></div>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemDisplayModel<BlogPost>>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ItemViewModel<BlogPost>>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<%=Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp).ToHtmlString(), "blogPosts contentItems") %>
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<Blog>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<% Html.AddTitleParts(Model.Item.Name); %>
|
||||
<% Html.Zone("primary"); %>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels"%>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<BlogPost>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Blogs.Models"%>
|
||||
<% Html.AddTitleParts(Model.Item.Title); %>
|
||||
<div class="sections">
|
||||
|
@@ -14,9 +14,9 @@ namespace Orchard.DevTools.ViewModels {
|
||||
|
||||
public IEnumerable<Type> PartTypes { get; set; }
|
||||
|
||||
public ItemDisplayModel DisplayModel { get; set; }
|
||||
public ItemViewModel DisplayModel { get; set; }
|
||||
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
public ItemViewModel EditorModel { get; set; }
|
||||
|
||||
public IEnumerable<TemplateViewModel> Displays {
|
||||
get {
|
||||
|
@@ -3,7 +3,7 @@ using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.Controllers {
|
||||
@@ -47,11 +47,11 @@ namespace Orchard.Sandbox.Controllers {
|
||||
PartTemplate(part, "Parts/Sandbox.Page.Title").Location("title"));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ItemEditorModel<SandboxPage> model) {
|
||||
protected override DriverResult Editor(ItemViewModel<SandboxPage> model) {
|
||||
return ItemTemplate("Items/Sandbox.Page");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ItemEditorModel<SandboxPage> model, IUpdateModel updater) {
|
||||
protected override DriverResult Editor(ItemViewModel<SandboxPage> model, IUpdateModel updater) {
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
return ItemTemplate("Items/Sandbox.Page");
|
||||
}
|
||||
|
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageEditViewModel : BaseViewModel {
|
||||
public ItemEditorModel<SandboxPage> Page { get; set; }
|
||||
public ItemViewModel<SandboxPage> Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageIndexViewModel : BaseViewModel {
|
||||
public IEnumerable<ItemDisplayModel<SandboxPage>> Pages { get; set; }
|
||||
public IEnumerable<ItemViewModel<SandboxPage>> Pages { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Sandbox.Models;
|
||||
|
||||
namespace Orchard.Sandbox.ViewModels {
|
||||
public class PageShowViewModel : BaseViewModel {
|
||||
public ItemDisplayModel<SandboxPage> Page { get; set; }
|
||||
public ItemViewModel<SandboxPage> Page { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<SandboxPage>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels" %>
|
||||
|
||||
<div class="item">
|
||||
<% Html.Zone("title"); %>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<SandboxPage>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels" %>
|
||||
<div class="item">
|
||||
<% Html.Zone("first"); %>
|
||||
<div class="title">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<SandboxPage>>" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<SandboxPage>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Sandbox.Models" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels" %>
|
||||
|
||||
<li>
|
||||
<%=Html.LabelFor(m => m.Item.Record.Name)%>
|
||||
|
@@ -1,11 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Tags.ViewModels {
|
||||
public class TagsSearchViewModel : BaseViewModel {
|
||||
public string TagName { get; set; }
|
||||
public IEnumerable<ItemDisplayModel<IContent>> Items { get; set; }
|
||||
public IEnumerable<ItemViewModel<IContent>> Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Models;
|
||||
@@ -20,6 +19,6 @@ namespace Orchard.Users.ViewModels {
|
||||
[Required, DataType(DataType.Password)]
|
||||
public string ConfirmPassword { get; set; }
|
||||
|
||||
public ItemEditorModel<IUser> User { get; set; }
|
||||
public ItemViewModel<IUser> User { get; set; }
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Users.Models;
|
||||
|
||||
@@ -24,6 +23,6 @@ namespace Orchard.Users.ViewModels {
|
||||
set { User.Item.Record.Email = value; }
|
||||
}
|
||||
|
||||
public ItemEditorModel<User> User { get; set; }
|
||||
public ItemViewModel<User> User { get; set; }
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<User>>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.ViewModels" %>
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemViewModel<User>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Users.Models" %>
|
||||
<% Html.ZonesAny(); %>
|
||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement {
|
||||
public static class ContentCreateExtensions {
|
||||
@@ -151,15 +151,15 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
/* Display and editor convenience extension methods */
|
||||
|
||||
public static ItemDisplayModel<T> BuildDisplayModel<T>(this IContentManager manager, int id, string displayType) where T : class, IContent {
|
||||
public static ItemViewModel<T> BuildDisplayModel<T>(this IContentManager manager, int id, string displayType) where T : class, IContent {
|
||||
return manager.BuildDisplayModel(manager.Get<T>(id), displayType);
|
||||
}
|
||||
|
||||
public static ItemEditorModel<T> BuildEditorModel<T>(this IContentManager manager, int id) where T : class, IContent {
|
||||
public static ItemViewModel<T> BuildEditorModel<T>(this IContentManager manager, int id) where T : class, IContent {
|
||||
return manager.BuildEditorModel(manager.Get<T>(id));
|
||||
}
|
||||
|
||||
public static ItemEditorModel<T> UpdateEditorModel<T>(this IContentManager manager, int id, IUpdateModel updater) where T : class, IContent {
|
||||
public static ItemViewModel<T> UpdateEditorModel<T>(this IContentManager manager, int id, IUpdateModel updater) where T : class, IContent {
|
||||
return manager.UpdateEditorModel(manager.Get<T>(id), updater);
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,8 @@ using System.Linq;
|
||||
using Autofac;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Data;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.ContentManagement {
|
||||
@@ -292,8 +292,8 @@ namespace Orchard.ContentManagement {
|
||||
return context.Metadata;
|
||||
}
|
||||
|
||||
public ItemDisplayModel<TContentPart> BuildDisplayModel<TContentPart>(TContentPart content, string displayType) where TContentPart : IContent {
|
||||
var displayModel = new ItemDisplayModel<TContentPart>(content);
|
||||
public ItemViewModel<TContentPart> BuildDisplayModel<TContentPart>(TContentPart content, string displayType) where TContentPart : IContent {
|
||||
var displayModel = new ItemViewModel<TContentPart>(content);
|
||||
var context = new BuildDisplayModelContext(displayModel, displayType);
|
||||
foreach (var handler in Handlers) {
|
||||
handler.BuildDisplayModel(context);
|
||||
@@ -301,8 +301,8 @@ namespace Orchard.ContentManagement {
|
||||
return displayModel;
|
||||
}
|
||||
|
||||
public ItemEditorModel<TContentPart> BuildEditorModel<TContentPart>(TContentPart content) where TContentPart : IContent {
|
||||
var editorModel = new ItemEditorModel<TContentPart>(content);
|
||||
public ItemViewModel<TContentPart> BuildEditorModel<TContentPart>(TContentPart content) where TContentPart : IContent {
|
||||
var editorModel = new ItemViewModel<TContentPart>(content);
|
||||
var context = new BuildEditorModelContext(editorModel);
|
||||
foreach (var handler in Handlers) {
|
||||
handler.BuildEditorModel(context);
|
||||
@@ -310,8 +310,8 @@ namespace Orchard.ContentManagement {
|
||||
return editorModel;
|
||||
}
|
||||
|
||||
public ItemEditorModel<TContentPart> UpdateEditorModel<TContentPart>(TContentPart content, IUpdateModel updater) where TContentPart : IContent {
|
||||
var editorModel = new ItemEditorModel<TContentPart>(content);
|
||||
public ItemViewModel<TContentPart> UpdateEditorModel<TContentPart>(TContentPart content, IUpdateModel updater) where TContentPart : IContent {
|
||||
var editorModel = new ItemViewModel<TContentPart>(content);
|
||||
|
||||
var context = new UpdateEditorModelContext(editorModel, updater);
|
||||
foreach (var handler in Handlers) {
|
||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Drivers {
|
||||
public interface IItemDriver : IEvents {
|
||||
@@ -44,10 +44,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
if (part == null) {
|
||||
return null;
|
||||
}
|
||||
if (context.DisplayModel.GetType() != typeof(ItemDisplayModel<TContent>)) {
|
||||
return Display(new ItemDisplayModel<TContent>(context.DisplayModel), context.DisplayType);
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
return Display(new ItemViewModel<TContent>(context.ViewModel), context.DisplayType);
|
||||
}
|
||||
return Display((ItemDisplayModel<TContent>)context.DisplayModel, context.DisplayType);
|
||||
return Display((ItemViewModel<TContent>)context.ViewModel, context.DisplayType);
|
||||
}
|
||||
|
||||
DriverResult IItemDriver.BuildEditorModel(BuildEditorModelContext context) {
|
||||
@@ -55,10 +55,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
if (part == null) {
|
||||
return null;
|
||||
}
|
||||
if (context.EditorModel.GetType() != typeof(ItemEditorModel<TContent>)) {
|
||||
return Editor(new ItemEditorModel<TContent>(context.EditorModel));
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
return Editor(new ItemViewModel<TContent>(context.ViewModel));
|
||||
}
|
||||
return Editor((ItemEditorModel<TContent>)context.EditorModel);
|
||||
return Editor((ItemViewModel<TContent>)context.ViewModel);
|
||||
}
|
||||
|
||||
DriverResult IItemDriver.UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
@@ -66,10 +66,10 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
if (part == null) {
|
||||
return null;
|
||||
}
|
||||
if (context.EditorModel.GetType() != typeof(ItemEditorModel<TContent>)) {
|
||||
return Editor(new ItemEditorModel<TContent>(context.EditorModel), context.Updater);
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
return Editor(new ItemViewModel<TContent>(context.ViewModel), context.Updater);
|
||||
}
|
||||
return Editor((ItemEditorModel<TContent>)context.EditorModel, context.Updater);
|
||||
return Editor((ItemViewModel<TContent>)context.ViewModel, context.Updater);
|
||||
}
|
||||
|
||||
protected virtual ContentType GetContentType() { return _contentType; }
|
||||
@@ -77,9 +77,9 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
protected virtual RouteValueDictionary GetDisplayRouteValues(TContent item) { return null; }
|
||||
protected virtual RouteValueDictionary GetEditorRouteValues(TContent item) { return null; }
|
||||
|
||||
protected virtual DriverResult Display(ItemDisplayModel<TContent> displayModel, string displayType) { return null; }
|
||||
protected virtual DriverResult Editor(ItemEditorModel<TContent> editorModel) { return null; }
|
||||
protected virtual DriverResult Editor(ItemEditorModel<TContent> editorModel, IUpdateModel updater) { return null; }
|
||||
protected virtual DriverResult Display(ItemViewModel<TContent> viewModel, string displayType) { return null; }
|
||||
protected virtual DriverResult Editor(ItemViewModel<TContent> viewModel) { return null; }
|
||||
protected virtual DriverResult Editor(ItemViewModel<TContent> viewModel, IUpdateModel updater) { return null; }
|
||||
|
||||
public ItemTemplateResult<TContent> ItemTemplate(string templateName) {
|
||||
return new ItemTemplateResult<TContent>(templateName);
|
||||
|
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Drivers {
|
||||
public class ItemTemplateResult<TContent> : DriverResult where TContent : class, IContent {
|
||||
@@ -13,24 +13,24 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
public string TemplateName { get; set; }
|
||||
|
||||
public override void Apply(BuildDisplayModelContext context) {
|
||||
context.DisplayModel.TemplateName = TemplateName;
|
||||
if (context.DisplayModel.GetType() != typeof(ItemDisplayModel<TContent>)) {
|
||||
context.DisplayModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemDisplayModel<TContent>>(
|
||||
context.ViewModel.TemplateName = TemplateName;
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
context.ViewModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemViewModel<TContent>>(
|
||||
html.ViewContext,
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemDisplayModel<TContent>(viewModel)) },
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemViewModel<TContent>(viewModel)) },
|
||||
html.RouteCollection);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(BuildEditorModelContext context) {
|
||||
context.EditorModel.TemplateName = TemplateName;
|
||||
if (context.EditorModel.GetType() != typeof(ItemEditorModel<TContent>)) {
|
||||
context.EditorModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemEditorModel<TContent>>(
|
||||
context.ViewModel.TemplateName = TemplateName;
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
context.ViewModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemViewModel<TContent>>(
|
||||
html.ViewContext,
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemEditorModel<TContent>(viewModel)) },
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemViewModel<TContent>(viewModel)) },
|
||||
html.RouteCollection);
|
||||
};
|
||||
}
|
||||
|
@@ -16,12 +16,12 @@ namespace Orchard.ContentManagement.Drivers {
|
||||
}
|
||||
|
||||
public override void Apply(BuildDisplayModelContext context) {
|
||||
context.DisplayModel.Zones.AddDisplayPart(
|
||||
context.ViewModel.Zones.AddDisplayPart(
|
||||
Zone + ":" + Position, Model, TemplateName, Prefix);
|
||||
}
|
||||
|
||||
public override void Apply(BuildEditorModelContext context) {
|
||||
context.EditorModel.Zones.AddEditorPart(
|
||||
context.ViewModel.Zones.AddEditorPart(
|
||||
Zone + ":" + Position, Model, TemplateName, Prefix);
|
||||
}
|
||||
|
||||
|
@@ -1,21 +1,22 @@
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class BuildDisplayModelContext {
|
||||
public BuildDisplayModelContext(ItemDisplayModel displayModel, string displayType) {
|
||||
ContentItem = displayModel.Item;
|
||||
public BuildDisplayModelContext(ItemViewModel viewModel, string displayType) {
|
||||
ContentItem = viewModel.Item;
|
||||
DisplayType = displayType;
|
||||
DisplayModel = displayModel;
|
||||
ViewModel = viewModel;
|
||||
}
|
||||
|
||||
public ContentItem ContentItem { get; private set; }
|
||||
public string DisplayType { get; private set; }
|
||||
public ItemDisplayModel DisplayModel { get; private set; }
|
||||
public ItemViewModel ViewModel { get; private set; }
|
||||
|
||||
public void AddDisplay(TemplateViewModel display) {
|
||||
//TEMP: (loudej) transition code - from TemplateViewMode to ZoneItem
|
||||
DisplayModel.Zones.AddDisplayPart(
|
||||
ViewModel.Zones.AddDisplayPart(
|
||||
display.ZoneName+":"+display.Position,
|
||||
display.Model,
|
||||
display.TemplateName,
|
||||
|
@@ -1,20 +1,21 @@
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class BuildEditorModelContext {
|
||||
public BuildEditorModelContext(ItemEditorModel editorModel) {
|
||||
ContentItem = editorModel.Item;
|
||||
EditorModel = editorModel;
|
||||
public BuildEditorModelContext(ItemViewModel viewModel) {
|
||||
ContentItem = viewModel.Item;
|
||||
ViewModel = viewModel;
|
||||
}
|
||||
|
||||
public ContentItem ContentItem { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
public ItemViewModel ViewModel { get; set; }
|
||||
|
||||
|
||||
public void AddEditor(TemplateViewModel display) {
|
||||
//TEMP: (loudej) transition code - from TemplateViewMode to ZoneItem
|
||||
EditorModel.Zones.AddEditorPart(
|
||||
ViewModel.Zones.AddEditorPart(
|
||||
display.ZoneName + ":" + display.Position,
|
||||
display.Model,
|
||||
display.TemplateName,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class ContentItemTemplates<TContent> : TemplateFilterBase<TContent> where TContent : class, IContent {
|
||||
@@ -9,7 +9,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
// todo: (heskew) use _prefix?
|
||||
private readonly string _prefix;
|
||||
private readonly string[] _displayTypes;
|
||||
private Action<UpdateEditorModelContext, ItemEditorModel<TContent>> _updater;
|
||||
private Action<UpdateEditorModelContext, ItemViewModel<TContent>> _updater;
|
||||
|
||||
public ContentItemTemplates(string templateName)
|
||||
: this(templateName, "") {
|
||||
@@ -23,18 +23,18 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
protected override void BuildDisplayModel(BuildDisplayModelContext context, TContent instance) {
|
||||
context.DisplayModel.TemplateName = _templateName;
|
||||
context.ViewModel.TemplateName = _templateName;
|
||||
var longestMatch = LongestMatch(context.DisplayType);
|
||||
if (!string.IsNullOrEmpty(longestMatch))
|
||||
context.DisplayModel.TemplateName += "." + longestMatch;
|
||||
context.ViewModel.TemplateName += "." + longestMatch;
|
||||
|
||||
context.DisplayModel.Prefix = _prefix;
|
||||
context.ViewModel.Prefix = _prefix;
|
||||
|
||||
if (context.DisplayModel.GetType() != typeof(ItemDisplayModel<TContent>)) {
|
||||
context.DisplayModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemDisplayModel<TContent>>(
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
context.ViewModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemViewModel<TContent>>(
|
||||
html.ViewContext,
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemDisplayModel<TContent>(viewModel)) },
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemViewModel<TContent>(viewModel)) },
|
||||
html.RouteCollection);
|
||||
};
|
||||
}
|
||||
@@ -55,28 +55,28 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
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>>(
|
||||
context.ViewModel.TemplateName = _templateName;
|
||||
context.ViewModel.Prefix = _prefix;
|
||||
if (context.ViewModel.GetType() != typeof(ItemViewModel<TContent>)) {
|
||||
context.ViewModel.Adaptor = (html, viewModel) => {
|
||||
return new HtmlHelper<ItemViewModel<TContent>>(
|
||||
html.ViewContext,
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemEditorModel<TContent>(viewModel)) },
|
||||
new ViewDataContainer { ViewData = new ViewDataDictionary(new ItemViewModel<TContent>(viewModel)) },
|
||||
html.RouteCollection);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context, TContent instance) {
|
||||
if (context.EditorModel is ItemEditorModel<TContent>)
|
||||
_updater(context, (ItemEditorModel<TContent>)context.EditorModel);
|
||||
if (context.ViewModel is ItemViewModel<TContent>)
|
||||
_updater(context, (ItemViewModel<TContent>)context.ViewModel);
|
||||
else
|
||||
_updater(context, new ItemEditorModel<TContent>(context.EditorModel));
|
||||
context.EditorModel.TemplateName = _templateName;
|
||||
context.EditorModel.Prefix = _prefix;
|
||||
_updater(context, new ItemViewModel<TContent>(context.ViewModel));
|
||||
context.ViewModel.TemplateName = _templateName;
|
||||
context.ViewModel.Prefix = _prefix;
|
||||
}
|
||||
|
||||
public void Updater(Action<UpdateEditorModelContext, ItemEditorModel<TContent>> updater) {
|
||||
public void Updater(Action<UpdateEditorModelContext, ItemViewModel<TContent>> updater) {
|
||||
_updater = updater;
|
||||
}
|
||||
}
|
||||
|
@@ -19,12 +19,12 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context, ContentPart<TRecord> part) {
|
||||
context.EditorModel.Zones.AddEditorPart(_location, part.Record, _templateName, _prefix);
|
||||
context.ViewModel.Zones.AddEditorPart(_location, part.Record, _templateName, _prefix);
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context, ContentPart<TRecord> part) {
|
||||
context.Updater.TryUpdateModel(part.Record, _prefix, null, null);
|
||||
context.EditorModel.Zones.AddEditorPart(_location, part.Record, _templateName, _prefix);
|
||||
context.ViewModel.Zones.AddEditorPart(_location, part.Record, _templateName, _prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class UpdateEditorModelContext : BuildEditorModelContext {
|
||||
public UpdateEditorModelContext(ItemEditorModel editorModel, IUpdateModel updater)
|
||||
: base(editorModel) {
|
||||
public UpdateEditorModelContext(ItemViewModel viewModel, IUpdateModel updater)
|
||||
: base(viewModel) {
|
||||
Updater = updater;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.ContentManagement {
|
||||
public interface IContentManager : IDependency {
|
||||
@@ -21,9 +21,9 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
ContentItemMetadata GetItemMetadata(IContent contentItem);
|
||||
|
||||
ItemDisplayModel<TContent> BuildDisplayModel<TContent>(TContent content, string displayType) where TContent : IContent;
|
||||
ItemEditorModel<TContent> BuildEditorModel<TContent>(TContent content) where TContent : IContent;
|
||||
ItemEditorModel<TContent> UpdateEditorModel<TContent>(TContent content, IUpdateModel updater) where TContent : IContent;
|
||||
ItemViewModel<TContent> BuildDisplayModel<TContent>(TContent content, string displayType) where TContent : IContent;
|
||||
ItemViewModel<TContent> BuildEditorModel<TContent>(TContent content) where TContent : IContent;
|
||||
ItemViewModel<TContent> UpdateEditorModel<TContent>(TContent content, IUpdateModel updater) where TContent : IContent;
|
||||
}
|
||||
|
||||
public class VersionOptions {
|
||||
|
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.ContentManagement.ViewModels {
|
||||
public class ItemDisplayModel : IZoneContainer {
|
||||
private ContentItem _item;
|
||||
|
||||
protected ItemDisplayModel() {
|
||||
Zones = new ZoneCollection();
|
||||
}
|
||||
|
||||
protected ItemDisplayModel(ItemDisplayModel displayModel) {
|
||||
TemplateName = displayModel.TemplateName;
|
||||
Prefix = displayModel.Prefix;
|
||||
Item = displayModel.Item;
|
||||
Zones = displayModel.Zones;
|
||||
}
|
||||
|
||||
public ItemDisplayModel(ContentItem item) {
|
||||
Zones = new ZoneCollection();
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { SetItem(value); }
|
||||
}
|
||||
|
||||
protected virtual void SetItem(ContentItem value) {
|
||||
_item = value;
|
||||
}
|
||||
|
||||
public Func<HtmlHelper, ItemDisplayModel, HtmlHelper> Adaptor { get; set; }
|
||||
public string TemplateName { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public ZoneCollection Zones { get; set; }
|
||||
}
|
||||
|
||||
public class ItemDisplayModel<TPart> : ItemDisplayModel where TPart : IContent {
|
||||
private TPart _item;
|
||||
|
||||
public ItemDisplayModel() {
|
||||
|
||||
}
|
||||
|
||||
public ItemDisplayModel(ItemDisplayModel displayModel)
|
||||
: base(displayModel) {
|
||||
}
|
||||
|
||||
public ItemDisplayModel(TPart part)
|
||||
: base(part.ContentItem) {
|
||||
}
|
||||
|
||||
public new TPart Item {
|
||||
get { return _item; }
|
||||
set { SetItem(value.ContentItem); }
|
||||
}
|
||||
|
||||
protected override void SetItem(ContentItem value) {
|
||||
_item = value.As<TPart>();
|
||||
base.SetItem(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.ContentManagement.ViewModels {
|
||||
public class ItemEditorModel : IZoneContainer {
|
||||
private ContentItem _item;
|
||||
|
||||
protected ItemEditorModel() {
|
||||
Zones = new ZoneCollection();
|
||||
}
|
||||
|
||||
protected ItemEditorModel(ItemEditorModel editorModel) {
|
||||
TemplateName = editorModel.TemplateName;
|
||||
Prefix = editorModel.Prefix;
|
||||
Item = editorModel.Item;
|
||||
Zones = editorModel.Zones;
|
||||
}
|
||||
|
||||
public ItemEditorModel(ContentItem item) {
|
||||
Zones = new ZoneCollection();
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
set { SetItem(value); }
|
||||
}
|
||||
|
||||
protected virtual void SetItem(ContentItem value) {
|
||||
_item = value;
|
||||
}
|
||||
|
||||
public Func<HtmlHelper, ItemEditorModel, HtmlHelper> Adaptor { get; set; }
|
||||
public string TemplateName { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public ZoneCollection Zones { get; set; }
|
||||
}
|
||||
|
||||
public class ItemEditorModel<TPart> : ItemEditorModel where TPart : IContent {
|
||||
private TPart _item;
|
||||
|
||||
|
||||
public ItemEditorModel() {
|
||||
|
||||
}
|
||||
|
||||
public ItemEditorModel(ItemEditorModel editorModel)
|
||||
: base(editorModel) {
|
||||
}
|
||||
|
||||
public ItemEditorModel(TPart content)
|
||||
: base(content.ContentItem) {
|
||||
}
|
||||
|
||||
public new TPart Item {
|
||||
get { return _item; }
|
||||
set { SetItem(value.ContentItem); }
|
||||
}
|
||||
|
||||
protected override void SetItem(ContentItem value) {
|
||||
_item = value.As<TPart>();
|
||||
base.SetItem(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ContentItemExtensions {
|
||||
@@ -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 ItemDisplayModel(content.ContentItem));
|
||||
return html.Partial(string.Format("{0}/{1}", content.ContentItem.ContentType, template), new ItemViewModel(content.ContentItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,15 +2,15 @@ using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ItemDisplayExtensions {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, TItemModel item) where TItemModel : ItemDisplayModel {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, TItemModel item) where TItemModel : ItemViewModel {
|
||||
return html.DisplayForItem(x => item);
|
||||
}
|
||||
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemModel>> expression) where TItemModel : ItemDisplayModel {
|
||||
public static MvcHtmlString DisplayForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemModel>> expression) where TItemModel : ItemViewModel {
|
||||
|
||||
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
|
||||
var model = (TItemModel)metadata.Model;
|
||||
|
@@ -2,14 +2,14 @@ using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ItemEditorExtensions {
|
||||
public static MvcHtmlString EditorForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, TItemModel item) where TItemModel : ItemEditorModel {
|
||||
public static MvcHtmlString EditorForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, TItemModel item) where TItemModel : ItemViewModel {
|
||||
return html.EditorForItem(x => item);
|
||||
}
|
||||
public static MvcHtmlString EditorForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemModel>> expression) where TItemModel : ItemEditorModel {
|
||||
public static MvcHtmlString EditorForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemModel>> expression) where TItemModel : ItemViewModel {
|
||||
|
||||
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
|
||||
var model = (TItemModel)metadata.Model;
|
||||
|
58
src/Orchard/Mvc/ViewModels/ItemViewModel.cs
Normal file
58
src/Orchard/Mvc/ViewModels/ItemViewModel.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.Mvc.ViewModels {
|
||||
public class ItemViewModel : IZoneContainer {
|
||||
private ContentItem _item;
|
||||
|
||||
protected ItemViewModel(ItemViewModel viewModel) {
|
||||
TemplateName = viewModel.TemplateName;
|
||||
Prefix = viewModel.Prefix;
|
||||
Item = viewModel.Item;
|
||||
Zones = viewModel.Zones;
|
||||
}
|
||||
|
||||
public ItemViewModel(ContentItem item) {
|
||||
Zones = new ZoneCollection();
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public ContentItem Item {
|
||||
get { return _item; }
|
||||
private set { SetItem(value); }
|
||||
}
|
||||
|
||||
protected virtual void SetItem(ContentItem value) {
|
||||
_item = value;
|
||||
}
|
||||
|
||||
public Func<HtmlHelper, ItemViewModel, HtmlHelper> Adaptor { get; set; }
|
||||
public string TemplateName { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public ZoneCollection Zones { get; private set; }
|
||||
}
|
||||
|
||||
public class ItemViewModel<TPart> : ItemViewModel where TPart : IContent {
|
||||
private TPart _item;
|
||||
|
||||
|
||||
public ItemViewModel(ItemViewModel viewModel)
|
||||
: base(viewModel) {
|
||||
}
|
||||
|
||||
public ItemViewModel(TPart content)
|
||||
: base(content.ContentItem) {
|
||||
}
|
||||
|
||||
public new TPart Item {
|
||||
get { return _item; }
|
||||
}
|
||||
|
||||
protected override void SetItem(ContentItem value) {
|
||||
_item = value.As<TPart>();
|
||||
base.SetItem(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -177,8 +177,7 @@
|
||||
<Compile Include="ContentManagement\Records\ContentPartVersionRecord.cs" />
|
||||
<Compile Include="ContentManagement\Records\ContentTypeRecord.cs" />
|
||||
<Compile Include="ContentManagement\Records\Utility.cs" />
|
||||
<Compile Include="ContentManagement\ViewModels\ItemDisplayModel.cs" />
|
||||
<Compile Include="ContentManagement\ViewModels\ItemEditorModel.cs" />
|
||||
<Compile Include="Mvc\ViewModels\ItemViewModel.cs" />
|
||||
<Compile Include="ContentManagement\ViewModels\TemplateViewModel.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
|
@@ -1,13 +1,13 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.UI.Zones {
|
||||
public class ItemDisplayZoneItem : ZoneItem {
|
||||
public ItemDisplayModel DisplayModel { get; set; }
|
||||
public ItemViewModel ViewModel { get; set; }
|
||||
|
||||
public override void Execute<TModel>(HtmlHelper<TModel> html) {
|
||||
html.DisplayForItem(DisplayModel);
|
||||
html.DisplayForItem(ViewModel);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.UI.Zones {
|
||||
public interface IZoneContainer {
|
||||
@@ -15,8 +15,8 @@ namespace Orchard.UI.Zones {
|
||||
public void AddRenderPartial(string location, string templateName, object model) {
|
||||
AddZoneItem(location, new RenderPartialZoneItem { Model = model, TemplateName = templateName });
|
||||
}
|
||||
public void AddDisplayItem(string location, ItemDisplayModel displayModel) {
|
||||
AddZoneItem(location, new ItemDisplayZoneItem { DisplayModel = displayModel });
|
||||
public void AddDisplayItem(string location, ItemViewModel viewModel) {
|
||||
AddZoneItem(location, new ItemDisplayZoneItem { ViewModel = viewModel });
|
||||
}
|
||||
public void AddDisplayPart(string location, object model, string templateName, string prefix) {
|
||||
AddZoneItem(location, new PartDisplayZoneItem { Model = model, TemplateName = templateName, Prefix = prefix });
|
||||
|
Reference in New Issue
Block a user