From 7c23b3075fb1840010eaa837be9567590eab6b1c Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Fri, 5 Nov 2010 16:09:04 -0700 Subject: [PATCH] Updating the role management UI to link up the role name to the edit page and implement & remove some removes --HG-- branch : dev --- src/Orchard.Web/Core/Shapes/Scripts/base.js | 11 ++++++----- .../Orchard.Roles/Controllers/AdminController.cs | 9 +++++++++ .../Modules/Orchard.Roles/Views/Admin/Edit.cshtml | 10 +++++++++- .../Modules/Orchard.Roles/Views/Admin/Index.cshtml | 14 ++++++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/Orchard.Web/Core/Shapes/Scripts/base.js b/src/Orchard.Web/Core/Shapes/Scripts/base.js index 41a34f23c..1d2571d2d 100644 --- a/src/Orchard.Web/Core/Shapes/Scripts/base.js +++ b/src/Orchard.Web/Core/Shapes/Scripts/base.js @@ -103,14 +103,14 @@ _controllees.hide(); // <- unhook this when the following comment applies $(_controllees.show()[0]).find("input").focus(); // <- aaaand a slideDown there...eventually } else if (!(_this.is(":checked") && _controlleesAreHidden)) { - //_controllees.slideUp(200); <- hook this back up when chrome behaves, or when I care less + //_controllees.slideUp(200); <- hook this back up when chrome behaves, or when I care less...or when chrome behaves _controllees.hide() } return this; } }); // collapsable areas - anything with a data-controllerid attribute has its visibility controlled by the id-ed radio/checkbox - (function () { + $(function () { $("[data-controllerid]").each(function () { var controller = $("#" + $(this).attr("data-controllerid")); if (controller.data("isControlling")) { @@ -126,11 +126,12 @@ $("[name=" + controller.attr("name") + "]").click(function () { $("[name=" + $(this).attr("name") + "]").each($(this).toggleWhatYouControl); }); } }); - })(); + }); // inline form link buttons (form.inline.link button) swapped out for a link that submits said form - (function () { + $(function () { $("form.inline.link").each(function () { var _this = $(this); + console.log(_this.html()) var link = $(""); var button = _this.children("button").first(); link.text(button.text()) @@ -141,7 +142,7 @@ _this.css({ "position": "absolute", "left": "-9999em" }); $("body").append(_this); }); - })(); + }); // (do) a little better autofocus $(function () { $("body").helpfullyFocus(); diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs index e611021c6..198fa1eb2 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs @@ -148,6 +148,11 @@ namespace Orchard.Roles.Controllers { [HttpPost, ActionName("Edit")] [FormValueRequired("submit.Delete")] public ActionResult EditDeletePOST(int id) { + return Delete(id, null); + } + + [HttpPost] + public ActionResult Delete(int id, string returnUrl) { if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles"))) return new HttpUnauthorizedResult(); @@ -155,6 +160,10 @@ namespace Orchard.Roles.Controllers { _roleService.DeleteRole(id); Services.Notifier.Information(T("Role was successfully deleted.")); + + if (!string.IsNullOrWhiteSpace(returnUrl)) + return Redirect(returnUrl); + return RedirectToAction("Index"); } catch (Exception exception) { Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message)); diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml index 0ae63895a..9d4fe1d78 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Edit.cshtml @@ -6,7 +6,13 @@
@T("Information") - + @if (Model.Name == "Administrator") { // the one special case + + + } + else { + + }
@@ -51,6 +57,8 @@
+ @if (Model.Name != "Administrator") { + }
} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Index.cshtml index 4be71652f..6cfd5027a 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Index.cshtml @@ -1,5 +1,9 @@ @model RolesIndexViewModel @using Orchard.Roles.ViewModels; +@using Orchard.Utility.Extensions; +@{ + Script.Require("ShapesBase"); +}

@Html.TitleForPage(T("Manage Roles").ToString())

@using(Html.BeginFormAntiForgeryPost()) { @@ -29,8 +33,14 @@ @foreach (var row in Model.Rows) { - @row.Name - @Html.ActionLink(T("Edit").ToString(), "Edit", new { row.Id }) + @Html.ActionLink(row.Name, "Edit", new { row.Id }) + + @Html.ActionLink(T("Edit").ToString(), "Edit", new { row.Id }) + @if (row.Name != "Administrator") { + @T(" | ") +
@T("Remove") + } + }