mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Having the global widget management UI not blow up if a widget has no CommonPart.
Also added something in the UI to show prominantly widgets which really have problems. Currently problems == no CommonPart. work item: 17381 --HG-- branch : 1.x
This commit is contained in:
@@ -80,6 +80,7 @@ namespace Orchard.Widgets.Controllers {
|
||||
.Widgets(_widgetsService.GetWidgets())
|
||||
.Zones(currentThemesZones)
|
||||
.OrphanZones(allZones.Except(currentThemesZones))
|
||||
.OrphanWidgets(_widgetsService.GetOrphanedWidgets())
|
||||
.ZonePreviewImage(zonePreviewImage);
|
||||
|
||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||
|
@@ -15,11 +15,13 @@ namespace Orchard.Widgets.Filters {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IRuleManager _ruleManager;
|
||||
private readonly IWidgetsService _widgetsService;
|
||||
|
||||
public WidgetFilter(IContentManager contentManager, IWorkContextAccessor workContextAccessor, IRuleManager ruleManager) {
|
||||
public WidgetFilter(IContentManager contentManager, IWorkContextAccessor workContextAccessor, IRuleManager ruleManager, IWidgetsService widgetsService) {
|
||||
_contentManager = contentManager;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_ruleManager = ruleManager;
|
||||
_widgetsService = widgetsService;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -44,7 +46,7 @@ namespace Orchard.Widgets.Filters {
|
||||
|
||||
// Once the Rule Engine is done:
|
||||
// Get Layers and filter by zone and rule
|
||||
IEnumerable<WidgetPart> widgetParts = _contentManager.Query<WidgetPart, WidgetPartRecord>().List();
|
||||
IEnumerable<WidgetPart> widgetParts = _widgetsService.GetWidgets();
|
||||
IEnumerable<LayerPart> activeLayers = _contentManager.Query<LayerPart, LayerPartRecord>().List();
|
||||
|
||||
var activeLayerIds = new List<int>();
|
||||
|
@@ -162,6 +162,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\WidgetPlacement.Zones.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\WidgetPlacement.Orphans.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -14,6 +14,7 @@ namespace Orchard.Widgets.Services {
|
||||
IEnumerable<Tuple<string, string>> GetWidgetTypes();
|
||||
IEnumerable<string> GetWidgetTypeNames();
|
||||
IEnumerable<WidgetPart> GetWidgets();
|
||||
IEnumerable<WidgetPart> GetOrphanedWidgets();
|
||||
IEnumerable<WidgetPart> GetWidgets(int layerId);
|
||||
|
||||
WidgetPart GetWidget(int widgetId);
|
||||
|
@@ -46,12 +46,25 @@ namespace Orchard.Widgets.Services {
|
||||
.List();
|
||||
}
|
||||
|
||||
public IEnumerable<WidgetPart> GetWidgets() {
|
||||
private IEnumerable<WidgetPart> GetAllWidgets() {
|
||||
return _contentManager
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.List();
|
||||
}
|
||||
|
||||
public IEnumerable<WidgetPart> GetWidgets() {
|
||||
return GetAllWidgets().Where(w => w.Has<ICommonPart>());
|
||||
}
|
||||
|
||||
// info: (heskew) Just including invalid widgets for now. Eventually need to include any in a layer which no longer exists if possible.
|
||||
public IEnumerable<WidgetPart> GetOrphanedWidgets() {
|
||||
return GetAllWidgets().Where(w => !w.Has<ICommonPart>());
|
||||
}
|
||||
|
||||
public IEnumerable<WidgetPart> GetWidgets(int layerId) {
|
||||
return GetWidgets().Where(widgetPart => widgetPart.As<ICommonPart>().Container.ContentItem.Id == layerId);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetZones() {
|
||||
return _featureManager.GetEnabledFeatures()
|
||||
.Select(x => x.Extension)
|
||||
@@ -86,10 +99,6 @@ namespace Orchard.Widgets.Services {
|
||||
return zones;
|
||||
}
|
||||
|
||||
public IEnumerable<WidgetPart> GetWidgets(int layerId) {
|
||||
return GetWidgets().Where(widgetPart => widgetPart.As<ICommonPart>().Container.ContentItem.Id == layerId);
|
||||
}
|
||||
|
||||
public LayerPart GetLayer(int layerId) {
|
||||
return GetLayers().FirstOrDefault(layer => layer.Id == layerId);
|
||||
}
|
||||
|
@@ -37,15 +37,19 @@ vertical-align:middle;
|
||||
margin-left:10px;
|
||||
}
|
||||
|
||||
#widgets-zones, #widgets-available {
|
||||
#widgets-zones, #widgets-zones-orphans, #widgets-available {
|
||||
background:#F3F4F5;
|
||||
border:1px solid #E4E5E6;
|
||||
padding:5px;
|
||||
}
|
||||
#widgets-zones-orphans {
|
||||
#widgets-orphans {
|
||||
margin:20px 10px 10px;
|
||||
padding:5px;
|
||||
}
|
||||
#widgets-zones-orphans-container {
|
||||
margin-top:40px;
|
||||
}
|
||||
#widgets-zones-orphans p {
|
||||
#widgets-zones-orphans-container p {
|
||||
margin-bottom:10px;
|
||||
}
|
||||
/* The number seems slightly meaningless. Leaving it out for now. * /
|
||||
@@ -53,10 +57,13 @@ margin-bottom:10px;
|
||||
list-style:decimal inside;
|
||||
}
|
||||
*/
|
||||
#widgets-zones ol {
|
||||
.widgets-listed ol {
|
||||
|
||||
}
|
||||
#widgets-zones li, #widgets-available li {
|
||||
#widgets-orphans ul {
|
||||
margin-top:10px;
|
||||
}
|
||||
.widgets-listed li, #widgets-available li {
|
||||
background:#FFF;
|
||||
color:#AEC3CE;
|
||||
border:1px solid #EAEAEA;
|
||||
@@ -64,22 +71,25 @@ margin:0 0 5px;
|
||||
padding:0 10px;
|
||||
position:relative;
|
||||
}
|
||||
#widgets-orphans li {
|
||||
padding:5px 10px;
|
||||
}
|
||||
#widgets-available li {
|
||||
margin:5px 0;
|
||||
}
|
||||
#widgets-zones li.last {
|
||||
.widgets-listed li.last {
|
||||
margin:0;
|
||||
}
|
||||
#widgets-zones li:hover, #widgets-zones li.on {
|
||||
.widgets-listed li:hover, .widgets-listed li.on {
|
||||
border-color:#bfd3a7;
|
||||
}
|
||||
#widgets-available h2 {
|
||||
font-size:1.231em;
|
||||
}
|
||||
#widgets-zones h2, #widgets-zones li li, #widgets-layer-visibility li {
|
||||
.widgets-listed h2, .widgets-listed li li, #widgets-layer-visibility li {
|
||||
color:#333;
|
||||
}
|
||||
#widgets-zones li li, #widgets-layer-visibility li {
|
||||
.widgets-listed li li, #widgets-layer-visibility li {
|
||||
background:#F3F4F5;
|
||||
border:0;
|
||||
border-left:3px solid #EAEAEA;
|
||||
@@ -89,32 +99,32 @@ padding:5px 100px 5px 25px;
|
||||
#widgets-layer-visibility li {
|
||||
margin:1px 0 0;
|
||||
}
|
||||
#widgets-zones li li.widgets-this-layer, #widgets-layer-visibility li.widgets-this-layer, #widgets-layer-visibility li.widgets-this-layer:hover {
|
||||
.widgets-listed li li.widgets-this-layer, #widgets-layer-visibility li.widgets-this-layer, #widgets-layer-visibility li.widgets-this-layer:hover {
|
||||
border-color:#898989;
|
||||
}
|
||||
#widgets-zones li li.widgets-this-layer:hover, #widgets-layer-visibility li:hover {
|
||||
.widgets-listed li li.widgets-this-layer:hover, #widgets-layer-visibility li:hover {
|
||||
border-color:#bfd3a7;
|
||||
}
|
||||
#widgets-zones .widgets-mover {
|
||||
.widgets-listed .widgets-mover {
|
||||
margin-left:-18px;
|
||||
vertical-align:-2px;
|
||||
}
|
||||
#widgets-zones .widgets-actions {
|
||||
.widgets-listed .widgets-actions {
|
||||
position:absolute;
|
||||
right:10px;
|
||||
top:5px;
|
||||
}
|
||||
#widgets-zones .widgets-zone-widgets li {
|
||||
.widgets-listed .widgets-zone-widgets li {
|
||||
position:relative;
|
||||
}
|
||||
#widgets-zones .widgets-zone-widgets .widgets-move-somewhere {
|
||||
.widgets-listed .widgets-zone-widgets .widgets-move-somewhere {
|
||||
left:3px;
|
||||
overflow:hidden;
|
||||
position:absolute;
|
||||
top:1px;
|
||||
width:20px;
|
||||
}
|
||||
#widgets-zones .widgets-move {
|
||||
.widgets-listed .widgets-move {
|
||||
background:url(images/arrows.png) 7px -31px no-repeat;
|
||||
border:0;
|
||||
webkit-border-radius:0;
|
||||
@@ -130,21 +140,21 @@ padding:0;
|
||||
text-indent:-9999em;
|
||||
width:20px;
|
||||
}
|
||||
#widgets-zones .widgets-move-down {
|
||||
.widgets-listed .widgets-move-down {
|
||||
background-position:7px -58px;
|
||||
margin-top:1px;
|
||||
}
|
||||
#widgets-zones .widgets-move-up:hover {
|
||||
.widgets-listed .widgets-move-up:hover {
|
||||
background-position:7px -71px;
|
||||
}
|
||||
#widgets-zones .widgets-move-down:hover {
|
||||
.widgets-listed .widgets-move-down:hover {
|
||||
background-position:7px -98px;
|
||||
}
|
||||
#widgets-zones .widgets-move-up[disabled] {
|
||||
.widgets-listed .widgets-move-up[disabled] {
|
||||
background-position:7px 9px;
|
||||
cursor:default;
|
||||
}
|
||||
#widgets-zones .widgets-move-down[disabled] {
|
||||
.widgets-listed .widgets-move-down[disabled] {
|
||||
background-position:7px -18px;
|
||||
cursor:default;
|
||||
}
|
||||
@@ -184,6 +194,9 @@ background-position:5px 11px;
|
||||
background-repeat:no-repeat;
|
||||
cursor:pointer;
|
||||
}
|
||||
#widgets-layer-visibility .widgets-this-layer.widgets-empty-layer {
|
||||
background-image:none;
|
||||
}
|
||||
#widgets-layer-visibility .widgets-this-layer {cursor:default;}
|
||||
#widgets-layer-visibility .widgets-other-layer.off, #widgets-layer-visibility .widgets-other-layer.off:hover {
|
||||
background-position:5px -17px;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
Style.Require("WidgetsAdmin");
|
||||
Layout.Title = T("Manage Widgets").ToString();
|
||||
}
|
||||
@Display.WidgetPlacement_Orphans(OrphanWidgets: Model.OrphanWidgets)
|
||||
<div id="widgets" class="group">
|
||||
@Display.WidgetLayersControl(Layers: Model.Layers, CurrentLayer: Model.CurrentLayer)
|
||||
<div id="layout-widgets-placement">
|
||||
|
@@ -32,7 +32,7 @@
|
||||
layer.data("widgets", layersWidgets);
|
||||
}
|
||||
else {
|
||||
layer = $("<li class=\"widgets-empty-layer\">" + layers[i].name + " <span>[empty]<span></li>");
|
||||
layer = $("<li class=\"widgets-empty-layer" + ((layers[i].id == currentLayerId && " widgets-this-layer") || "") + "\">" + layers[i].name + " <span>[empty]<span></li>");
|
||||
}
|
||||
|
||||
visContainer.append(layer);
|
||||
|
@@ -9,16 +9,16 @@
|
||||
}
|
||||
<div id="widgets-placement">
|
||||
<div id="widgets-layers" class="widgets-container detail-view switchable">
|
||||
<div id="widgets-zones">
|
||||
<div id="widgets-zones" class="widgets-listed">
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.Zones, CurrentLayer: Model.CurrentLayer)
|
||||
}
|
||||
</div>
|
||||
@if (orphanZones.Count() > 0) {
|
||||
<div id="widgets-zones-orphans">
|
||||
<div id="widgets-zones-orphans-container">
|
||||
<h3>@T("Zones for other enabled themes.")</h3>
|
||||
<p>@T("Widgets in these zones will not appear anywhere when your currently active theme is applied. They might still appear in selectively applied (e.g. mobile) themes.")</p>
|
||||
<div id="widgets-zones">
|
||||
<div id="widgets-zones-orphans" class="widgets-listed">
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.OrphanZones, CurrentLayer: Model.CurrentLayer)
|
||||
}
|
||||
|
Reference in New Issue
Block a user