diff --git a/src/Orchard.Web/Modules/Orchard.Search/Controllers/SearchController.cs b/src/Orchard.Web/Modules/Orchard.Search/Controllers/SearchController.cs index fc8226ac6..b52263e10 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Controllers/SearchController.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Controllers/SearchController.cs @@ -54,7 +54,7 @@ namespace Orchard.Search.Controllers { var searchViewModel = new SearchViewModel { Query = q, - DefaultPageSize = 10, // <- yeah, I know :| + DefaultPageSize = 10, // TODO: sebastien <- yeah, I know :| PageOfResults = pageOfItems }; diff --git a/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs index 5273c3e00..5a9748a31 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Migrations.cs @@ -24,7 +24,7 @@ namespace Orchard.Search { .WithSetting("Stereotype", "Widget") ); - return 5; + return 2; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Search/Models/SearchFormPart.cs b/src/Orchard.Web/Modules/Orchard.Search/Models/SearchFormPart.cs index da21fddca..4c804773e 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Models/SearchFormPart.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Models/SearchFormPart.cs @@ -2,7 +2,7 @@ namespace Orchard.Search.Models { /// - /// Cotnent part for the search form widget + /// Content part for the search form widget /// public class SearchFormPart : ContentPart { } diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs index 018e9779a..59f07e6ea 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs @@ -106,7 +106,7 @@ namespace Orchard.Widgets.Controllers { } catch (Exception exception) { Services.Notifier.Error(T("Creating widget failed: {0}", exception.Message)); - return RedirectToAction("Index"); + return RedirectToAction("Index", "Admin", new { id = layerId }); } } @@ -128,12 +128,12 @@ namespace Orchard.Widgets.Controllers { } Services.Notifier.Information(T("Your {0} has been created.", widgetPart.TypeDefinition.DisplayName)); - return RedirectToAction("Index"); } catch (Exception exception) { Services.Notifier.Error(T("Creating widget failed: {0}", exception.Message)); - return RedirectToAction("Index"); } + + return RedirectToAction("Index", "Admin", new { id = layerId }); } public ActionResult AddLayer() { @@ -171,7 +171,7 @@ namespace Orchard.Widgets.Controllers { } Services.Notifier.Information(T("Your {0} has been created.", layerPart.TypeDefinition.DisplayName)); - return RedirectToAction("Index"); + return RedirectToAction("Index", "Admin", new { id = layerPart.Id }); } catch (Exception exception) { Services.Notifier.Error(T("Creating layer failed: {0}", exception.Message)); @@ -194,7 +194,7 @@ namespace Orchard.Widgets.Controllers { } catch (Exception exception) { Services.Notifier.Error(T("Editing layer failed: {0}", exception.Message)); - return RedirectToAction("Index"); + return RedirectToAction("Index", "Admin", new { id }); } } @@ -216,12 +216,12 @@ namespace Orchard.Widgets.Controllers { } Services.Notifier.Information(T("Your {0} has been saved.", layerPart.TypeDefinition.DisplayName)); - return RedirectToAction("Index"); } catch (Exception exception) { Services.Notifier.Error(T("Editing layer failed: {0}", exception.Message)); - return RedirectToAction("Index"); } + + return RedirectToAction("Index", "Admin", new { id }); } [HttpPost, ActionName("EditLayer")] @@ -238,15 +238,16 @@ namespace Orchard.Widgets.Controllers { Services.Notifier.Error(T("Removing Layer failed: {0}", exception.Message)); } - return RedirectToAction("Index"); + return RedirectToAction("Index", "Admin", new { id }); } public ActionResult EditWidget(int id) { if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) return new HttpUnauthorizedResult(); + WidgetPart widgetPart = null; try { - WidgetPart widgetPart = _widgetsService.GetWidget(id); + widgetPart = _widgetsService.GetWidget(id); if (widgetPart == null) { Services.Notifier.Error(T("Widget not found: {1}", id)); return RedirectToAction("Index"); @@ -257,6 +258,10 @@ namespace Orchard.Widgets.Controllers { } catch (Exception exception) { Services.Notifier.Error(T("Editing widget failed: {0}", exception.Message)); + + if (widgetPart != null) + return RedirectToAction("Index", "Admin", new { id = widgetPart.LayerPart.Id }); + return RedirectToAction("Index"); } } @@ -267,11 +272,12 @@ namespace Orchard.Widgets.Controllers { if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) return new HttpUnauthorizedResult(); + WidgetPart widgetPart = null; try { - WidgetPart widgetPart = _widgetsService.GetWidget(id); + widgetPart = _widgetsService.GetWidget(id); if (widgetPart == null) return new NotFoundResult(); - + var model = Services.ContentManager.UpdateEditor(widgetPart, this); if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); @@ -279,12 +285,14 @@ namespace Orchard.Widgets.Controllers { } Services.Notifier.Information(T("Your {0} has been saved.", widgetPart.TypeDefinition.DisplayName)); - return RedirectToAction("Index"); } catch (Exception exception) { Services.Notifier.Error(T("Editing widget failed: {0}", exception.Message)); - return RedirectToAction("Index"); } + + return widgetPart != null ? + RedirectToAction("Index", "Admin", new { id = widgetPart.LayerPart.Id }) : + RedirectToAction("Index"); } [HttpPost, ActionName("EditWidget")] @@ -293,15 +301,22 @@ namespace Orchard.Widgets.Controllers { if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) return new HttpUnauthorizedResult(); + WidgetPart widgetPart = null; try { - _widgetsService.DeleteWidget(id); + widgetPart = _widgetsService.GetWidget(id); + if (widgetPart == null) + return new NotFoundResult(); + + _widgetsService.DeleteWidget(widgetPart.Id); Services.Notifier.Information(T("Widget was successfully deleted")); } catch (Exception exception) { Services.Notifier.Error(T("Removing Widget failed: {0}", exception.Message)); } - return RedirectToAction("Index"); + return widgetPart != null ? + RedirectToAction("Index", "Admin", new { id = widgetPart.LayerPart.Id }) : + RedirectToAction("Index"); } bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { 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 2e4997bc5..758fb276e 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Admin/Index.cshtml @@ -11,83 +11,83 @@ Html.ValidationSummary(); - - - - Available Widgets + - - - - - - - - - @T("Name") - - - - @foreach (string widget in Model.WidgetTypes) { - - @widget - @Html.ActionLink(T("Add").ToString(), "AddWidget", new { layerId = Model.CurrentLayer.Id, widgetType = widget }) - - } - + + Available Widgets - - + + + + + + + + + @T("Name") + + + + @foreach (string widget in Model.WidgetTypes) { + + @widget + @Html.ActionLink(T("Add").ToString(), "AddWidget", new { layerId = Model.CurrentLayer.Id, widgetType = widget }) + + } + - - Widget Zones + + - - - - @foreach (string zone in Model.Zones) { - - @zone - - @foreach (WidgetPart widget in Model.CurrentLayerWidgets.Where(widgetPart => widgetPart.Zone == zone).OrderBy(widgetPart => widgetPart.Position, new Orchard.UI.FlatPositionComparer())) { - - @if (widget.Position != "1") { - - } - @if (int.Parse(widget.Position) < Model.CurrentLayerWidgets.Where(widgetPart => widgetPart.Zone == zone).Count()) { - - } - @Html.ActionLink(@widget.Title, "EditWidget", new { @widget.Id }) - - } - - - } - - + + Widget Zones - - - @foreach (var layer in Model.Layers) { - if (layer.Id == Model.CurrentLayer.Id) { - - @Html.ActionLink(@layer.Name, "Index", new { @layer.Id }) - - - - - } else { - - @Html.ActionLink(@layer.Name, "Index", new { @layer.Id }) - - - - - } - } - - - - - + + + + @foreach (string zone in Model.Zones) { + + @zone + + @foreach (WidgetPart widget in Model.CurrentLayerWidgets.Where(widgetPart => widgetPart.Zone == zone).OrderBy(widgetPart => widgetPart.Position, new Orchard.UI.FlatPositionComparer())) { + + @if (widget.Position != "1") { + + } + @if (int.Parse(widget.Position) < Model.CurrentLayerWidgets.Where(widgetPart => widgetPart.Zone == zone).Count()) { + + } + @Html.ActionLink(@widget.Title, "EditWidget", new { @widget.Id }) + + } + + + } + + + + + + @foreach (var layer in Model.Layers) { + if (layer.Id == Model.CurrentLayer.Id) { + + @Html.ActionLink(@layer.Name, "Index", new { @layer.Id }) + + + + + } else { + + @Html.ActionLink(@layer.Name, "Index", new { @layer.Id }) + + + + + } + } + + + + + } \ No newline at end of file