mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 07:22:35 +01:00
SeasonEditor moved to Gird Editor.
This commit is contained in:
parent
b68784060b
commit
08b7b8c3e1
Binary file not shown.
@ -90,7 +90,7 @@ namespace NzbDrone.Web.Controllers
|
||||
|
||||
[AcceptVerbs(HttpVerbs.Post)]
|
||||
[GridAction]
|
||||
public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored, bool seasonFolder, int qualityProfileId, List<SeasonEditModel> seasons)
|
||||
public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored, bool seasonFolder, int qualityProfileId, List<SeasonEditModel> seasonEditor)
|
||||
{
|
||||
var oldSeries = _seriesProvider.GetSeries(id);
|
||||
oldSeries.Path = path;
|
||||
@ -182,25 +182,15 @@ namespace NzbDrone.Web.Controllers
|
||||
return PartialView("SeriesSearchResults", model);
|
||||
}
|
||||
|
||||
[AcceptVerbs(HttpVerbs.Post)]
|
||||
[GridAction]
|
||||
public ActionResult _SaveAjaxEditing(string id)
|
||||
{
|
||||
return RedirectToAction("UnMapped");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult SaveSeasons(List<SeasonEditModel> seasons)
|
||||
public JsonResult SaveSeason(int seriesId, int seasonNumber, bool monitored)
|
||||
{
|
||||
foreach (var season in seasons)
|
||||
if (_episodeProvider.IsIgnored(seriesId, seasonNumber) == monitored)
|
||||
{
|
||||
if (_episodeProvider.IsIgnored(season.SeriesId, season.SeasonNumber) != !season.Monitored)
|
||||
{
|
||||
_episodeProvider.SetSeasonIgnore(season.SeriesId, season.SeasonNumber, !season.Monitored);
|
||||
}
|
||||
_episodeProvider.SetSeasonIgnore(seriesId, seasonNumber, !monitored);
|
||||
}
|
||||
|
||||
return Content("Saved");
|
||||
return new JsonResult { Data = "ok" };
|
||||
}
|
||||
|
||||
public ActionResult Details(int seriesId)
|
||||
@ -284,6 +274,7 @@ namespace NzbDrone.Web.Controllers
|
||||
QualityProfileName = s.QualityProfile.Name,
|
||||
SeasonFolder = s.SeasonFolder,
|
||||
Status = s.Status,
|
||||
SeasonsCount = _episodeProvider.GetSeasons(s.SeriesId).Where(n => n != 0).Count()
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ namespace NzbDrone.Web.Helpers
|
||||
string.Format("<input type=\"hidden\" name=\"{0}.index\" autocomplete=\"off\" value=\"{1}\" />",
|
||||
collectionName, itemIndex));
|
||||
|
||||
html.ViewContext.Writer.WriteLine(
|
||||
string.Format("<input type=\"hidden\" name=\"{0}_collection\" autocomplete=\"off\" value=\"{1}\" />",
|
||||
collectionName, itemIndex));
|
||||
|
||||
return BeginHtmlFieldPrefixScope(html, string.Format("{0}[{1}]", collectionName, itemIndex));
|
||||
}
|
||||
|
||||
|
27
NzbDrone.Web/Helpers/ValueExtension.cs
Normal file
27
NzbDrone.Web/Helpers/ValueExtension.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace NzbDrone.Web.Helpers
|
||||
{
|
||||
public static class ValueExtension
|
||||
{
|
||||
public static object ValueFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
|
||||
{
|
||||
var memberEx = expression.Body as MemberExpression;
|
||||
|
||||
if (memberEx == null)
|
||||
throw new ArgumentException("Body not a member-expression.");
|
||||
|
||||
string name = memberEx.Member.Name;
|
||||
var model = html.ViewData.Model;
|
||||
var value = model.GetType().GetProperty(name).GetValue(model, null);
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
@ -35,5 +35,8 @@ namespace NzbDrone.Web.Models
|
||||
|
||||
[DisplayName("Monitored")]
|
||||
public bool Monitored { get; set; }
|
||||
|
||||
[DisplayName("Season Editor")]
|
||||
public List<SeasonEditModel> SeasonEditor { get; set; }
|
||||
}
|
||||
}
|
@ -252,6 +252,7 @@
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helpers\ValueExtension.cs" />
|
||||
<Compile Include="Helpers\DescriptionExtension.cs" />
|
||||
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />
|
||||
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
<div style="width: 435px; margin: 10px;">
|
||||
|
||||
@Html.HiddenFor(m => m.SeriesId)
|
||||
|
||||
<div class="edit-group">
|
||||
<div class="config-title">@Html.LabelFor(m => m.Path)</div>
|
||||
<div class="config-value">@Html.TextBoxFor(m => m.Path, new { style = "width: 300" })</div>
|
||||
@ -27,4 +29,9 @@
|
||||
<b>@Html.LabelFor(m => m.QualityProfileId)</b>
|
||||
@Html.DropDownListFor(model => model.QualityProfileId, (SelectList)ViewData["SelectList"], new { style = "margin-left:40px" })
|
||||
</div>
|
||||
|
||||
<div id="seasonEditorSection">
|
||||
<div style="font-weight: bold; padding-right: 15px; padding-bottom: 5px;">@Html.LabelFor(m => m.SeasonEditor)</div>
|
||||
<div id="season-editor"></div>
|
||||
</div>
|
||||
</div>
|
@ -109,8 +109,7 @@
|
||||
.ClientTemplate("<a href=" +
|
||||
Url.Action("Details", "Series", new {seriesId = "<#= SeriesId #>"}) +
|
||||
"><#= Title #></a>");
|
||||
columns.Bound(o => o.SeasonsCount).Title("Seasons")
|
||||
.ClientTemplate("<a href=# onclick=\"openSeasonEditor(<#= SeriesId #>, \'<#= Title #>\'); return false;\"><#= SeasonsCount #></a>");
|
||||
columns.Bound(o => o.SeasonsCount).Title("Seasons");
|
||||
columns.Bound(o => o.QualityProfileName).Title("Quality");
|
||||
columns.Bound(o => o.Status);
|
||||
columns.Bound(o => o.AirsDayOfWeek);
|
||||
@ -133,6 +132,7 @@
|
||||
.Sortable(sort => sort.OrderBy(order => order.Add(o => o.Title).Ascending()).Enabled(true))
|
||||
.DetailView(detailView => detailView.ClientTemplate("<div style=\"width:95%\"><#= Overview #></div>"))
|
||||
.ClientEvents(clientEvents => { clientEvents.OnEdit("grid_edit");
|
||||
clientEvents.OnSave("grid_save");
|
||||
clientEvents.OnDataBinding("grid_bind");
|
||||
clientEvents.OnDataBound("grid_bound");
|
||||
clientEvents.OnRowDataBound("grid_rowBound");
|
||||
@ -150,6 +150,33 @@
|
||||
.closest(".t-window")
|
||||
.data("tWindow")
|
||||
.center();
|
||||
|
||||
var seriesId = args.dataItem.SeriesId;
|
||||
var url = '@Url.Action("SeasonEditor", "Series")';
|
||||
$('#season-editor').load(url, { seriesId: seriesId });
|
||||
}
|
||||
|
||||
function grid_save(e) {
|
||||
var seasonEditor = e.form.SeasonEditor_collection;
|
||||
var saveSeasonEditUrl = '@Url.Action("SaveSeason", "Series")';
|
||||
|
||||
jQuery.each(seasonEditor, function() {
|
||||
var guid = $(this).val();
|
||||
var prefix = '#SeasonEditor_' + guid + '__';
|
||||
var seriesId = $(prefix + 'SeriesId').val();
|
||||
var seasonNumber = $(prefix + 'SeasonNumber').val();
|
||||
var monitored = $(prefix + 'Monitored').attr('checked');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: saveSeasonEditUrl,
|
||||
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber, monitored: monitored }),
|
||||
error: function(req, status, error) {
|
||||
alert("Sorry! We could save season changes at this time. " + error);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) { }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function grid_rowBound(e) {
|
||||
@ -188,27 +215,4 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function openSeasonEditor(seriesId, seriesName) {
|
||||
windowElement = null;
|
||||
windowElement = $.telerik.window.create({
|
||||
title: "<b>Season Editor: " + seriesName + "</b>",
|
||||
contentUrl: '@Url.Action("SeasonEditor", "Series")' + '/?seriesId=' + seriesId,
|
||||
width: 360,
|
||||
height: 400,
|
||||
modal: true,
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
scrollable: true
|
||||
});
|
||||
|
||||
windowElement.data('tWindow').center();
|
||||
}
|
||||
|
||||
function closeSeasonEditor() {
|
||||
$('#form').remove();
|
||||
var window = windowElement.data("tWindow");
|
||||
window.close();
|
||||
}
|
||||
</script>
|
@ -5,46 +5,12 @@
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
var options = {
|
||||
target: '#result',
|
||||
//beforeSubmit: showRequest,
|
||||
success: showResponse,
|
||||
type: 'post',
|
||||
resetForm: false
|
||||
};
|
||||
$('#form').ajaxForm(options);
|
||||
$('#save_button').attr('disabled', '');
|
||||
});
|
||||
|
||||
function showRequest(formData, jqForm, options) {
|
||||
$("#result").empty().html('Saving...');
|
||||
$("#form :input").attr("disabled", true);
|
||||
}
|
||||
|
||||
function showResponse(responseText, statusText, xhr, $form) {
|
||||
//$("#result").empty().html(responseText);
|
||||
$("#form :input").attr("disabled", false);
|
||||
closeSeasonEditor();
|
||||
}
|
||||
</script>
|
||||
|
||||
@using (Html.BeginForm("SaveSeasons", "Series", FormMethod.Post, new { id = "form" }))
|
||||
{
|
||||
<div style="vertical-align: middle">
|
||||
<div style="vertical-align: middle">
|
||||
@foreach (var season in Model)
|
||||
{
|
||||
Html.RenderAction("GetSingleSeasonView", "Series", season);
|
||||
}
|
||||
</div>
|
||||
|
||||
<div id="buttons" style="padding-top: 20px; position: absolute; bottom: 5;">
|
||||
<button type="submit" class="t-button t-state-default">Save</button>
|
||||
<button type="button" class="t-button t-state-default" onclick="closeSeasonEditor()">Cancel</button>
|
||||
</div>
|
||||
}
|
||||
<div id="result"></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var lastChecked = null;
|
||||
@ -68,4 +34,4 @@
|
||||
lastChecked = this;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
@ -2,14 +2,18 @@
|
||||
@using NzbDrone.Web.Models;
|
||||
@model SeasonEditModel
|
||||
|
||||
@using (Html.BeginCollectionItem("seasons"))
|
||||
@using (Html.BeginCollectionItem("SeasonEditor"))
|
||||
{
|
||||
<fieldset style="display: inline; border-color: lightgrey; width: 26%; margin-bottom: 2px; padding-bottom: 1px; padding-top: 1px;">
|
||||
var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_');
|
||||
|
||||
<fieldset style="display: inline; border-color: lightgrey; width: 20%; margin-bottom: 2px; margin-right: 0px; margin-left: 0px; padding-bottom: 1px; padding-top: 1px;">
|
||||
|
||||
@Html.DisplayFor(m => m.SeasonString)
|
||||
<span style="float: right;">@Html.CheckBoxFor(m => m.Monitored, new { @class = "chkbox" })</span>
|
||||
|
||||
@Html.HiddenFor(m => m.SeriesId)
|
||||
@Html.HiddenFor(m => m.SeasonNumber)
|
||||
@Html.HiddenFor(m => m.SeasonNumber)
|
||||
@Html.Hidden(idClean, new { @class = "cleanId", })
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user