mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +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())
|
.Widgets(_widgetsService.GetWidgets())
|
||||||
.Zones(currentThemesZones)
|
.Zones(currentThemesZones)
|
||||||
.OrphanZones(allZones.Except(currentThemesZones))
|
.OrphanZones(allZones.Except(currentThemesZones))
|
||||||
|
.OrphanWidgets(_widgetsService.GetOrphanedWidgets())
|
||||||
.ZonePreviewImage(zonePreviewImage);
|
.ZonePreviewImage(zonePreviewImage);
|
||||||
|
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// 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 IContentManager _contentManager;
|
||||||
private readonly IWorkContextAccessor _workContextAccessor;
|
private readonly IWorkContextAccessor _workContextAccessor;
|
||||||
private readonly IRuleManager _ruleManager;
|
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;
|
_contentManager = contentManager;
|
||||||
_workContextAccessor = workContextAccessor;
|
_workContextAccessor = workContextAccessor;
|
||||||
_ruleManager = ruleManager;
|
_ruleManager = ruleManager;
|
||||||
|
_widgetsService = widgetsService;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
@@ -44,7 +46,7 @@ namespace Orchard.Widgets.Filters {
|
|||||||
|
|
||||||
// Once the Rule Engine is done:
|
// Once the Rule Engine is done:
|
||||||
// Get Layers and filter by zone and rule
|
// 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();
|
IEnumerable<LayerPart> activeLayers = _contentManager.Query<LayerPart, LayerPartRecord>().List();
|
||||||
|
|
||||||
var activeLayerIds = new List<int>();
|
var activeLayerIds = new List<int>();
|
||||||
|
|||||||
@@ -162,6 +162,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\WidgetPlacement.Zones.cshtml" />
|
<Content Include="Views\WidgetPlacement.Zones.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Views\WidgetPlacement.Orphans.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.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.
|
<!-- 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<Tuple<string, string>> GetWidgetTypes();
|
||||||
IEnumerable<string> GetWidgetTypeNames();
|
IEnumerable<string> GetWidgetTypeNames();
|
||||||
IEnumerable<WidgetPart> GetWidgets();
|
IEnumerable<WidgetPart> GetWidgets();
|
||||||
|
IEnumerable<WidgetPart> GetOrphanedWidgets();
|
||||||
IEnumerable<WidgetPart> GetWidgets(int layerId);
|
IEnumerable<WidgetPart> GetWidgets(int layerId);
|
||||||
|
|
||||||
WidgetPart GetWidget(int widgetId);
|
WidgetPart GetWidget(int widgetId);
|
||||||
|
|||||||
@@ -46,12 +46,25 @@ namespace Orchard.Widgets.Services {
|
|||||||
.List();
|
.List();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<WidgetPart> GetWidgets() {
|
private IEnumerable<WidgetPart> GetAllWidgets() {
|
||||||
return _contentManager
|
return _contentManager
|
||||||
.Query<WidgetPart, WidgetPartRecord>()
|
.Query<WidgetPart, WidgetPartRecord>()
|
||||||
.List();
|
.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() {
|
public IEnumerable<string> GetZones() {
|
||||||
return _featureManager.GetEnabledFeatures()
|
return _featureManager.GetEnabledFeatures()
|
||||||
.Select(x => x.Extension)
|
.Select(x => x.Extension)
|
||||||
@@ -86,10 +99,6 @@ namespace Orchard.Widgets.Services {
|
|||||||
return zones;
|
return zones;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<WidgetPart> GetWidgets(int layerId) {
|
|
||||||
return GetWidgets().Where(widgetPart => widgetPart.As<ICommonPart>().Container.ContentItem.Id == layerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LayerPart GetLayer(int layerId) {
|
public LayerPart GetLayer(int layerId) {
|
||||||
return GetLayers().FirstOrDefault(layer => layer.Id == layerId);
|
return GetLayers().FirstOrDefault(layer => layer.Id == layerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,15 +37,19 @@ vertical-align:middle;
|
|||||||
margin-left:10px;
|
margin-left:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#widgets-zones, #widgets-available {
|
#widgets-zones, #widgets-zones-orphans, #widgets-available {
|
||||||
background:#F3F4F5;
|
background:#F3F4F5;
|
||||||
border:1px solid #E4E5E6;
|
border:1px solid #E4E5E6;
|
||||||
padding:5px;
|
padding:5px;
|
||||||
}
|
}
|
||||||
#widgets-zones-orphans {
|
#widgets-orphans {
|
||||||
|
margin:20px 10px 10px;
|
||||||
|
padding:5px;
|
||||||
|
}
|
||||||
|
#widgets-zones-orphans-container {
|
||||||
margin-top:40px;
|
margin-top:40px;
|
||||||
}
|
}
|
||||||
#widgets-zones-orphans p {
|
#widgets-zones-orphans-container p {
|
||||||
margin-bottom:10px;
|
margin-bottom:10px;
|
||||||
}
|
}
|
||||||
/* The number seems slightly meaningless. Leaving it out for now. * /
|
/* The number seems slightly meaningless. Leaving it out for now. * /
|
||||||
@@ -53,10 +57,13 @@ margin-bottom:10px;
|
|||||||
list-style:decimal inside;
|
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;
|
background:#FFF;
|
||||||
color:#AEC3CE;
|
color:#AEC3CE;
|
||||||
border:1px solid #EAEAEA;
|
border:1px solid #EAEAEA;
|
||||||
@@ -64,22 +71,25 @@ margin:0 0 5px;
|
|||||||
padding:0 10px;
|
padding:0 10px;
|
||||||
position:relative;
|
position:relative;
|
||||||
}
|
}
|
||||||
|
#widgets-orphans li {
|
||||||
|
padding:5px 10px;
|
||||||
|
}
|
||||||
#widgets-available li {
|
#widgets-available li {
|
||||||
margin:5px 0;
|
margin:5px 0;
|
||||||
}
|
}
|
||||||
#widgets-zones li.last {
|
.widgets-listed li.last {
|
||||||
margin:0;
|
margin:0;
|
||||||
}
|
}
|
||||||
#widgets-zones li:hover, #widgets-zones li.on {
|
.widgets-listed li:hover, .widgets-listed li.on {
|
||||||
border-color:#bfd3a7;
|
border-color:#bfd3a7;
|
||||||
}
|
}
|
||||||
#widgets-available h2 {
|
#widgets-available h2 {
|
||||||
font-size:1.231em;
|
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;
|
color:#333;
|
||||||
}
|
}
|
||||||
#widgets-zones li li, #widgets-layer-visibility li {
|
.widgets-listed li li, #widgets-layer-visibility li {
|
||||||
background:#F3F4F5;
|
background:#F3F4F5;
|
||||||
border:0;
|
border:0;
|
||||||
border-left:3px solid #EAEAEA;
|
border-left:3px solid #EAEAEA;
|
||||||
@@ -89,32 +99,32 @@ padding:5px 100px 5px 25px;
|
|||||||
#widgets-layer-visibility li {
|
#widgets-layer-visibility li {
|
||||||
margin:1px 0 0;
|
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;
|
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;
|
border-color:#bfd3a7;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-mover {
|
.widgets-listed .widgets-mover {
|
||||||
margin-left:-18px;
|
margin-left:-18px;
|
||||||
vertical-align:-2px;
|
vertical-align:-2px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-actions {
|
.widgets-listed .widgets-actions {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
right:10px;
|
right:10px;
|
||||||
top:5px;
|
top:5px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-zone-widgets li {
|
.widgets-listed .widgets-zone-widgets li {
|
||||||
position:relative;
|
position:relative;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-zone-widgets .widgets-move-somewhere {
|
.widgets-listed .widgets-zone-widgets .widgets-move-somewhere {
|
||||||
left:3px;
|
left:3px;
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:1px;
|
top:1px;
|
||||||
width:20px;
|
width:20px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-move {
|
.widgets-listed .widgets-move {
|
||||||
background:url(images/arrows.png) 7px -31px no-repeat;
|
background:url(images/arrows.png) 7px -31px no-repeat;
|
||||||
border:0;
|
border:0;
|
||||||
webkit-border-radius:0;
|
webkit-border-radius:0;
|
||||||
@@ -130,21 +140,21 @@ padding:0;
|
|||||||
text-indent:-9999em;
|
text-indent:-9999em;
|
||||||
width:20px;
|
width:20px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-move-down {
|
.widgets-listed .widgets-move-down {
|
||||||
background-position:7px -58px;
|
background-position:7px -58px;
|
||||||
margin-top:1px;
|
margin-top:1px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-move-up:hover {
|
.widgets-listed .widgets-move-up:hover {
|
||||||
background-position:7px -71px;
|
background-position:7px -71px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-move-down:hover {
|
.widgets-listed .widgets-move-down:hover {
|
||||||
background-position:7px -98px;
|
background-position:7px -98px;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-move-up[disabled] {
|
.widgets-listed .widgets-move-up[disabled] {
|
||||||
background-position:7px 9px;
|
background-position:7px 9px;
|
||||||
cursor:default;
|
cursor:default;
|
||||||
}
|
}
|
||||||
#widgets-zones .widgets-move-down[disabled] {
|
.widgets-listed .widgets-move-down[disabled] {
|
||||||
background-position:7px -18px;
|
background-position:7px -18px;
|
||||||
cursor:default;
|
cursor:default;
|
||||||
}
|
}
|
||||||
@@ -184,6 +194,9 @@ background-position:5px 11px;
|
|||||||
background-repeat:no-repeat;
|
background-repeat:no-repeat;
|
||||||
cursor:pointer;
|
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-this-layer {cursor:default;}
|
||||||
#widgets-layer-visibility .widgets-other-layer.off, #widgets-layer-visibility .widgets-other-layer.off:hover {
|
#widgets-layer-visibility .widgets-other-layer.off, #widgets-layer-visibility .widgets-other-layer.off:hover {
|
||||||
background-position:5px -17px;
|
background-position:5px -17px;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
Style.Require("WidgetsAdmin");
|
Style.Require("WidgetsAdmin");
|
||||||
Layout.Title = T("Manage Widgets").ToString();
|
Layout.Title = T("Manage Widgets").ToString();
|
||||||
}
|
}
|
||||||
|
@Display.WidgetPlacement_Orphans(OrphanWidgets: Model.OrphanWidgets)
|
||||||
<div id="widgets" class="group">
|
<div id="widgets" class="group">
|
||||||
@Display.WidgetLayersControl(Layers: Model.Layers, CurrentLayer: Model.CurrentLayer)
|
@Display.WidgetLayersControl(Layers: Model.Layers, CurrentLayer: Model.CurrentLayer)
|
||||||
<div id="layout-widgets-placement">
|
<div id="layout-widgets-placement">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
layer.data("widgets", layersWidgets);
|
layer.data("widgets", layersWidgets);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
visContainer.append(layer);
|
||||||
|
|||||||
@@ -9,16 +9,16 @@
|
|||||||
}
|
}
|
||||||
<div id="widgets-placement">
|
<div id="widgets-placement">
|
||||||
<div id="widgets-layers" class="widgets-container detail-view switchable">
|
<div id="widgets-layers" class="widgets-container detail-view switchable">
|
||||||
<div id="widgets-zones">
|
<div id="widgets-zones" class="widgets-listed">
|
||||||
@using (Html.BeginFormAntiForgeryPost()) {
|
@using (Html.BeginFormAntiForgeryPost()) {
|
||||||
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.Zones, CurrentLayer: Model.CurrentLayer)
|
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.Zones, CurrentLayer: Model.CurrentLayer)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (orphanZones.Count() > 0) {
|
@if (orphanZones.Count() > 0) {
|
||||||
<div id="widgets-zones-orphans">
|
<div id="widgets-zones-orphans-container">
|
||||||
<h3>@T("Zones for other enabled themes.")</h3>
|
<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>
|
<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()) {
|
@using (Html.BeginFormAntiForgeryPost()) {
|
||||||
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.OrphanZones, CurrentLayer: Model.CurrentLayer)
|
@Display.WidgetPlacement_Zones(Widgets: Model.Widgets, Zones: Model.OrphanZones, CurrentLayer: Model.CurrentLayer)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user