mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#19094: Moving "Content Types" and "Content Parts" tabs from "Content" into a new admin menu which has two tabs: Content Types and Content Parts.
Work Item: 19094 --HG-- branch : 1.x extra : rebase_source : 7ac0edb9f01094222e52b82f5f8eda9f3f6d926a
This commit is contained in:
@@ -7,13 +7,14 @@ namespace Orchard.ContentTypes {
|
|||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
public string MenuName { get { return "admin"; } }
|
public string MenuName { get { return "admin"; } }
|
||||||
|
|
||||||
public void GetNavigation(NavigationBuilder builder)
|
public void GetNavigation(NavigationBuilder builder) {
|
||||||
{
|
builder.AddImageSet("contenttypes");
|
||||||
builder.Add(T("Content"),
|
builder.Add(T("Content Schema"), "1.4.1", menu => {
|
||||||
menu => menu
|
menu.LinkToFirstChild(true);
|
||||||
.Add(T("Content Types"), "3", item => item.Action("Index", "Admin", new {area = "Orchard.ContentTypes"}).LocalNav())
|
|
||||||
.Add(T("Content Parts"), "4", item => item.Action("ListParts", "Admin", new {area = "Orchard.ContentTypes"}).LocalNav()));
|
|
||||||
|
|
||||||
|
menu.Add(T("Content Types"), "1", item => item.Action("Index", "Admin", new { area = "Orchard.ContentTypes" }).LocalNav());
|
||||||
|
menu.Add(T("Content Parts"), "2", item => item.Action("ListParts", "Admin", new { area = "Orchard.ContentTypes" }).LocalNav());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -64,8 +64,11 @@
|
|||||||
<Compile Include="ResourceManifest.cs" />
|
<Compile Include="ResourceManifest.cs" />
|
||||||
<Compile Include="Extensions\StringExtensions.cs" />
|
<Compile Include="Extensions\StringExtensions.cs" />
|
||||||
<Compile Include="Services\ContentTypePlacementStrategy.cs" />
|
<Compile Include="Services\ContentTypePlacementStrategy.cs" />
|
||||||
|
<Compile Include="Services\DefaultStereotypesProvider.cs" />
|
||||||
<Compile Include="Services\IPlacementService.cs" />
|
<Compile Include="Services\IPlacementService.cs" />
|
||||||
|
<Compile Include="Services\IStereotypesProvider.cs" />
|
||||||
<Compile Include="Services\PlacementService.cs" />
|
<Compile Include="Services\PlacementService.cs" />
|
||||||
|
<Compile Include="Services\StereotypeService.cs" />
|
||||||
<Compile Include="Settings\EditorEvents.cs" />
|
<Compile Include="Settings\EditorEvents.cs" />
|
||||||
<Compile Include="Settings\PlacementSettings.cs" />
|
<Compile Include="Settings\PlacementSettings.cs" />
|
||||||
<Compile Include="ViewModels\AddPartsViewModel.cs" />
|
<Compile Include="ViewModels\AddPartsViewModel.cs" />
|
||||||
@@ -93,7 +96,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
|
<Content Include="Styles\Images\menu.contenttypes.png" />
|
||||||
<Content Include="Styles\Images\move.gif" />
|
<Content Include="Styles\Images\move.gif" />
|
||||||
|
<Content Include="Styles\menu.contenttypes-admin.css" />
|
||||||
<Content Include="Styles\orchard-contenttypes-admin.css" />
|
<Content Include="Styles\orchard-contenttypes-admin.css" />
|
||||||
<Content Include="Views\Admin\AddFieldTo.cshtml" />
|
<Content Include="Views\Admin\AddFieldTo.cshtml" />
|
||||||
<Content Include="Views\Admin\AddPartsTo.cshtml" />
|
<Content Include="Views\Admin\AddPartsTo.cshtml" />
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Orchard.ContentTypes.Services {
|
||||||
|
public class DefaultStereotypesProvider : IStereotypesProvider {
|
||||||
|
private readonly Lazy<IContentDefinitionService> _contentDefinitionService;
|
||||||
|
public DefaultStereotypesProvider(Lazy<IContentDefinitionService> contentDefinitionService) {
|
||||||
|
_contentDefinitionService = contentDefinitionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<StereotypeDescription> GetStereotypes() {
|
||||||
|
// Harvest all available stereotypes by finding out about the stereotype of all content types
|
||||||
|
var stereotypes = _contentDefinitionService.Value.GetTypes().Where(x => x.Settings.ContainsKey("Stereotype")).Select(x => x.Settings["Stereotype"]).Distinct();
|
||||||
|
return stereotypes.Select(x => new StereotypeDescription {DisplayName = x, Stereotype = x});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Orchard.ContentTypes.Services {
|
||||||
|
public interface IStereotypesProvider : IDependency {
|
||||||
|
IEnumerable<StereotypeDescription> GetStereotypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StereotypeDescription {
|
||||||
|
public string Stereotype { get; set; }
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Orchard.Caching;
|
||||||
|
using Orchard.Services;
|
||||||
|
|
||||||
|
namespace Orchard.ContentTypes.Services {
|
||||||
|
public interface IStereotypeService : IDependency {
|
||||||
|
IEnumerable<StereotypeDescription> GetStereotypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StereotypeService : IStereotypeService {
|
||||||
|
private readonly IEnumerable<IStereotypesProvider> _providers;
|
||||||
|
private readonly ICacheManager _cacheManager;
|
||||||
|
private readonly ISignals _signals;
|
||||||
|
private readonly IClock _clock;
|
||||||
|
|
||||||
|
public StereotypeService(IEnumerable<IStereotypesProvider> providers, ICacheManager cacheManager, ISignals signals, IClock clock) {
|
||||||
|
_providers = providers;
|
||||||
|
_cacheManager = cacheManager;
|
||||||
|
_signals = signals;
|
||||||
|
_clock = clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<StereotypeDescription> GetStereotypes() {
|
||||||
|
return _cacheManager.Get("ContentType.Stereotypes", context => {
|
||||||
|
|
||||||
|
// TODO: Implement a signal in ContentDefinitionManager that gets raised whenever a type definition is updated.
|
||||||
|
// For now, we'll just cache the stereotypes for 1 minute.
|
||||||
|
//context.Monitor(_signals.When("ContentType.Stereotypes"));
|
||||||
|
context.Monitor(_clock.WhenUtc(_clock.UtcNow.AddMinutes(1)));
|
||||||
|
return _providers.SelectMany(x => x.GetStereotypes());
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
.navicon-content-schema {
|
||||||
|
background-image:url(images/menu.contenttypes.png) !important;
|
||||||
|
}
|
||||||
|
.navicon-content-schema:hover {
|
||||||
|
background-position:0 -30px !important;
|
||||||
|
}
|
@@ -3,6 +3,14 @@
|
|||||||
border-bottom:1px solid #ccc;
|
border-bottom:1px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.orchard-contenttypes .summary .properties h3 {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.orchard-contenttypes .summary .properties .stereotype {
|
||||||
|
color: #7c7c7c;
|
||||||
|
}
|
||||||
|
|
||||||
#main .properties p {
|
#main .properties p {
|
||||||
margin:0;
|
margin:0;
|
||||||
}
|
}
|
||||||
@@ -68,7 +76,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.manage-part .description {
|
.manage-part .description {
|
||||||
color: #333;
|
color: #7c7c7c;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,13 @@
|
|||||||
@model Orchard.ContentTypes.ViewModels.EditTypeViewModel
|
@model Orchard.ContentTypes.ViewModels.EditTypeViewModel
|
||||||
@using Orchard.Core.Contents.Settings;
|
@using Orchard.Core.Contents.Settings;
|
||||||
|
@{
|
||||||
|
var settings = Model.Settings.GetModel<ContentTypeSettings>();
|
||||||
|
var creatable = settings.Creatable;
|
||||||
|
var stereotype = Model.Settings.ContainsKey("Stereotype") ? Model.Settings["Stereotype"] : default(string);
|
||||||
|
}
|
||||||
<div class="summary">
|
<div class="summary">
|
||||||
<div class="properties">
|
<div class="properties">
|
||||||
<h3>@Model.DisplayName</h3>@{ var creatable = Model.Settings.GetModel<ContentTypeSettings>().Creatable; }
|
<h3>@Model.DisplayName</h3> @if (!string.IsNullOrWhiteSpace(stereotype)) { <text><span class="stereotype" title="Stereotype">- @stereotype</span></text>}
|
||||||
@if (creatable) {
|
@if (creatable) {
|
||||||
<p class="pageStatus">@Html.ActionLink(T("Create New {0}", Model.DisplayName).Text, "Create", new {area = "Contents", id = Model.Name})</p>
|
<p class="pageStatus">@Html.ActionLink(T("Create New {0}", Model.DisplayName).Text, "Create", new {area = "Contents", id = Model.Name})</p>
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user