From 24c47801b3503caa5f5f47519911716bbc9ae0b4 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 8 May 2011 21:23:57 -0700 Subject: [PATCH] system/config is now editable --- NzbDrone.Web/Controllers/SystemController.cs | 23 ++++++++++++++ NzbDrone.Web/Views/System/Config.cshtml | 32 +++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Web/Controllers/SystemController.cs b/NzbDrone.Web/Controllers/SystemController.cs index 692f995cd..7d33db5ea 100644 --- a/NzbDrone.Web/Controllers/SystemController.cs +++ b/NzbDrone.Web/Controllers/SystemController.cs @@ -6,6 +6,7 @@ using System.Web.Mvc; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Jobs; +using Telerik.Web.Mvc; namespace NzbDrone.Web.Controllers { @@ -39,5 +40,27 @@ namespace NzbDrone.Web.Controllers } + [GridAction] + public ActionResult _SelectAjaxEditing() + { + return View(new GridModel(_configProvider.All())); + } + + [AcceptVerbs(HttpVerbs.Post)] + [GridAction] + public ActionResult _SaveAjaxEditing(string key, string value) + { + _configProvider.SetValue(key, value); + return View(new GridModel(_configProvider.All())); + } + + [AcceptVerbs(HttpVerbs.Post)] + [GridAction] + public ActionResult _InsertAjaxEditing(string key, string value) + { + + _configProvider.SetValue(key, value); + return View(new GridModel(_configProvider.All())); + } } } diff --git a/NzbDrone.Web/Views/System/Config.cshtml b/NzbDrone.Web/Views/System/Config.cshtml index 3515402d8..2c2aa4d33 100644 --- a/NzbDrone.Web/Views/System/Config.cshtml +++ b/NzbDrone.Web/Views/System/Config.cshtml @@ -1,9 +1,33 @@ @model IEnumerable @section TitleContent{ -Config +Configuration } @section MainContent{ - @{Html.Telerik().Grid(Model).Name("Grid") - .TableHtmlAttributes(new { @class = "Grid" }) - .Render();} + @(Html.Telerik().Grid() + .Name("Grid") + .TableHtmlAttributes(new { @class = "Grid" }) + .DataKeys(keys => + { + keys.Add(p => p.Key); + }) + .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image)) + .DataBinding(dataBinding => + { + dataBinding.Ajax() + .Select("_SelectAjaxEditing", "System") + .Insert("_InsertAjaxEditing", "System") + .Update("_SaveAjaxEditing", "System"); + }) + .Columns(columns => + { + columns.Bound(p => p.Key); + columns.Bound(p => p.Value); + columns.Command(commands => + { + commands.Edit().ButtonType(GridButtonType.Image); + }).Width(0).Title("Actions"); + }) + .Editable(editing => editing.Mode(GridEditMode.InLine)) + .Sortable() +) }