From f8c6994b1cb600cccfaca9f6c4988f2ff6ee010a Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Mon, 21 Mar 2011 12:41:28 -0700 Subject: [PATCH] Some more global widget management work - added "remove" widget link if the widget is in the current layer - added "move to current layer" link if the widgets is in a different layer - added an interim visual cue for widgets in the current layer --HG-- branch : dev --- .../Controllers/AdminController.cs | 14 +++++++++++-- .../Services/IWidgetsService.cs | 2 ++ .../Services/WidgetsService.cs | 16 +++++++++++++++ .../Styles/orchard-widgets-admin.css | 9 ++++++++- .../Orchard.Widgets/Views/Admin/Index.cshtml | 11 +++++++++- .../Themes/TheAdmin/Styles/site.css | 20 ++++++++++++++++--- 6 files changed, 65 insertions(+), 7 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs index 6d7193a7e..d2dc94731 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs @@ -69,7 +69,10 @@ namespace Orchard.Widgets.Controllers { } [HttpPost, ActionName("Index")] - public ActionResult IndexWidgetPOST(int? moveUp, int? moveDown, string returnUrl) { + public ActionResult IndexWidgetPOST(int? layerId, int? moveUp, int? moveDown, int? moveHere, int? moveOut, string returnUrl) { + if (moveOut.HasValue) + return DeleteWidget(moveOut.Value, returnUrl); + if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) return new HttpUnauthorizedResult(); @@ -78,6 +81,8 @@ namespace Orchard.Widgets.Controllers { _widgetsService.MoveWidgetUp(moveUp.Value); if (moveDown.HasValue) _widgetsService.MoveWidgetDown(moveDown.Value); + if (moveHere.HasValue) + _widgetsService.MoveWidgetToLayer(moveHere.Value, layerId); } catch (Exception exception) { this.Error(exception, T("Moving widget failed: {0}", exception.Message), Logger, Services.Notifier); @@ -86,6 +91,7 @@ namespace Orchard.Widgets.Controllers { return this.RedirectLocal(returnUrl, () => RedirectToAction("Index")); } + public ActionResult ChooseWidget(int layerId, string zone, string returnUrl) { if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) return new HttpUnauthorizedResult(); @@ -333,6 +339,9 @@ namespace Orchard.Widgets.Controllers { [HttpPost, ActionName("EditWidget")] [FormValueRequired("submit.Delete")] public ActionResult EditWidgetDeletePOST(int id, string returnUrl) { + return DeleteWidget(id, returnUrl); + } + private ActionResult DeleteWidget(int id, string returnUrl) { if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) return new HttpUnauthorizedResult(); @@ -344,7 +353,8 @@ namespace Orchard.Widgets.Controllers { _widgetsService.DeleteWidget(widgetPart.Id); Services.Notifier.Information(T("Widget was successfully deleted")); - } catch (Exception exception) { + } + catch (Exception exception) { this.Error(exception, T("Removing Widget failed: {0}", exception.Message), Logger, Services.Notifier); } diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Services/IWidgetsService.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Services/IWidgetsService.cs index 0fdfc3a58..3d9cd9e7e 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Services/IWidgetsService.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Services/IWidgetsService.cs @@ -26,6 +26,8 @@ namespace Orchard.Widgets.Services { bool MoveWidgetUp(WidgetPart widgetPart); bool MoveWidgetDown(int widgetId); bool MoveWidgetDown(WidgetPart widgetPart); + bool MoveWidgetToLayer(int widgetId, int? layerId); + bool MoveWidgetToLayer(WidgetPart widgetPart, int? layerId); void MakeRoomForWidgetPosition(int widgetId); void MakeRoomForWidgetPosition(WidgetPart widgetPart); } diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Services/WidgetsService.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Services/WidgetsService.cs index 50e1b5822..d38a59846 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Services/WidgetsService.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Services/WidgetsService.cs @@ -153,6 +153,22 @@ namespace Orchard.Widgets.Services { return false; } + public bool MoveWidgetToLayer(int widgetId, int? layerId) { + return MoveWidgetToLayer(GetWidget(widgetId), layerId); + } + public bool MoveWidgetToLayer(WidgetPart widgetPart, int? layerId) { + LayerPart layer = layerId.HasValue + ? GetLayer(layerId.Value) + : GetLayers().FirstOrDefault(); + + if (layer != null) { + widgetPart.LayerPart = layer; + return true; + } + + return false; + } + public void MakeRoomForWidgetPosition(int widgetId) { MakeRoomForWidgetPosition(GetWidget(widgetId)); } diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Styles/orchard-widgets-admin.css b/src/Orchard.Web/Modules/Orchard.Widgets/Styles/orchard-widgets-admin.css index 43937b64d..fd985c0f0 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Styles/orchard-widgets-admin.css +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Styles/orchard-widgets-admin.css @@ -57,8 +57,15 @@ color:#333; #widgets-zones li li { background:#F3F4F5; border:0; +border-left:3px solid #EAEAEA; margin:10px 0; -padding:5px 10px 5px 25px; +padding:5px 100px 5px 25px; +} +#widgets-zones li li.widgets-this-layer { +border-color:#898989; +} +#widgets-zones li li.widgets-this-layer:hover { +border-color:#bfd3a7; } #widgets-zones .widgets-mover { margin-left:-18px; diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Admin/Index.cshtml index abeead617..3b547b312 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Admin/Index.cshtml @@ -48,11 +48,20 @@ @if (count > 0) { int i = 0; foreach (WidgetPart widget in widgets.Where(w => w.Zone == zone).OrderBy(w => w.Position, new Orchard.UI.FlatPositionComparer())) { -
  • +
  • @Html.ActionLink(HasText(widget.Title) ? widget.Title : widget.TypeDefinition.DisplayName, "EditWidget", new { @widget.Id, returnUrl })

    +
    + @if (widget.LayerId != Model.CurrentLayer.Id) { + + } + else { /* it could be useful to remove the widget regardless of the layer it's on but there's no place in the current UI for this and "Move to current layer" */ + + } +
    + @Html.Hidden("returnUrl", returnUrl)
  • } diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css index e22eeb303..8953950e9 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css +++ b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css @@ -224,18 +224,18 @@ number of columns: 24; actual width: 946; column width: 26; gutter width:14 /* Links ***************************************************************/ a, a:link, a:visited, -form.link button { +form.link button, button.link, button.link:hover { color:#1e5d7d; text-decoration:none; } -form.link button { +form.link button, button.link { height:1.3em; } a:hover, a:active, a:focus { color:#1e5d7d; text-decoration:none; } -form.link button:hover { +form.link button:hover, button.link:hover { border-bottom:1px solid #1e5d7d; } @@ -757,6 +757,20 @@ button:active, .buton:active, a.button:active { button:focus::-moz-focus-inner, .button:focus::-moz-focus-inner { border: 1px dotted transparent; } +/* and allow all of that button style to be undone and beyond - to look like a link */ +button.link { + background:none; + border:0; + padding:inherit; + text-shadow:none; + -webkit-box-shadow:none; + -moz-box-shadow:none; + box-shadow:none; + filter:none; + -webkit-border-radius:0; + -moz-border-radius:0; + border-radius:0; +} .cancel { margin:0 0 0 .93em; }