diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 7971efc38..d01c41593 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -127,7 +127,7 @@ namespace NzbDrone.Web.Controllers public ActionResult Quality() { - var profiles = _qualityProvider.All().ToList(); + var profiles = _qualityProvider.All(); var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile); var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name"); @@ -272,7 +272,7 @@ namespace NzbDrone.Web.Controllers return GetQualityProfileView(qualityProfile); } - public PartialViewResult GetQualityProfileView(QualityProfile profile) + public PartialViewResult GetQualityProfileView(QualityProfile profile) { var model = new QualityProfileModel(); model.QualityProfileId = profile.QualityProfileId; @@ -284,7 +284,14 @@ namespace NzbDrone.Web.Controllers model.Webdl = profile.Allowed.Contains(QualityTypes.WEBDL); model.Bluray720p = profile.Allowed.Contains(QualityTypes.Bluray720p); model.Bluray1080p = profile.Allowed.Contains(QualityTypes.Bluray1080p); - model.Cutoff = profile.Cutoff; + model.Cutoff = (int)profile.Cutoff; + + model.SdtvId = QualityTypes.SDTV.Id; + model.DvdId = QualityTypes.DVD.Id; + model.HdtvId = QualityTypes.HDTV.Id; + model.WebdlId = QualityTypes.WEBDL.Id; + model.Bluray720pId = QualityTypes.Bluray720p.Id; + model.Bluray1080pId = QualityTypes.Bluray1080p.Id; return PartialView("QualityProfileItem", model); } @@ -473,7 +480,7 @@ namespace NzbDrone.Web.Controllers var profile = new QualityProfile(); profile.QualityProfileId = profileModel.QualityProfileId; profile.Name = profileModel.Name; - profile.Cutoff = profileModel.Cutoff; + profile.Cutoff = (QualityTypes)profileModel.Cutoff; profile.Allowed = new List(); diff --git a/NzbDrone.Web/Models/QualityProfileModel.cs b/NzbDrone.Web/Models/QualityProfileModel.cs index 0d7db88b2..4b70bee07 100644 --- a/NzbDrone.Web/Models/QualityProfileModel.cs +++ b/NzbDrone.Web/Models/QualityProfileModel.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Web.Models [DisplayName("Cut-off")] [Required(ErrorMessage = "Valid Cut-off is Required")] - public QualityTypes Cutoff { get; set; } + public int Cutoff { get; set; } [DisplayName("Allowed Qualities")] public List Allowed { get; set; } @@ -26,20 +26,26 @@ namespace NzbDrone.Web.Models //Quality Booleans [DisplayName("SDTV")] public bool Sdtv { get; set; } + public int SdtvId { get; set; } [DisplayName("DVD")] public bool Dvd { get; set; } + public int DvdId { get; set; } [DisplayName("HDTV")] public bool Hdtv { get; set; } + public int HdtvId { get; set; } [DisplayName("WEBDL")] public bool Webdl { get; set; } + public int WebdlId { get; set; } [DisplayName("Bluray720p")] public bool Bluray720p { get; set; } + public int Bluray720pId { get; set; } [DisplayName("Bluray1080p")] public bool Bluray1080p { get; set; } + public int Bluray1080pId { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js b/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js index c222a2e4a..869ea62e9 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js +++ b/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js @@ -70,21 +70,19 @@ $(document).on('click', '.quality-selectee', function () { var cleanId = getCleanId(this); var cutoff = '#' + cleanId + '_Cutoff'; var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text(); + var qualityId = $(this).attr('data-quality-id'); //Remove 'Unknown' $(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); }); //Add option to cutoff SelectList if ($(this).attr('checked')) { - $('').appendTo(cutoff); + $('').val(qualityId).appendTo(cutoff); } //Remove option from cutoff SelectList else { - $(cutoff + ' option').each(function () { - if ($(this).text().indexOf(name) > -1) - $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); - }); + $(cutoff).find('option[value="' + qualityId + '"]').remove(); } }); diff --git a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml index c857da0dc..dee11f013 100644 --- a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml +++ b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml @@ -20,20 +20,20 @@ @Html.LabelFor(x => x.Name) @Html.TextBoxFor(x => x.Name, new { @class = "profileName_textbox" }) @Html.LabelFor(x => x.Cutoff) - @Html.DropDownListFor(m => m.Cutoff, new SelectList(Model.Allowed, Model.Cutoff)) + @Html.DropDownListFor(m => m.Cutoff, new SelectList(Model.Allowed, "Id", "Name", Model.Cutoff))
- @Html.CheckBoxFor(m => m.Sdtv, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Sdtv, new { @class = "quality-selectee", data_quality_id = Model.SdtvId }) @Html.LabelFor(m => m.Sdtv) - @Html.CheckBoxFor(m => m.Dvd, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Dvd, new { @class = "quality-selectee", data_quality_id = Model.DvdId }) @Html.LabelFor(m => m.Dvd) - @Html.CheckBoxFor(m => m.Hdtv, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Hdtv, new { @class = "quality-selectee", data_quality_id = Model.HdtvId }) @Html.LabelFor(m => m.Hdtv) - @Html.CheckBoxFor(m => m.Webdl, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Webdl, new { @class = "quality-selectee", data_quality_id = Model.WebdlId }) @Html.LabelFor(m => m.Webdl) - @Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee", data_quality_id = Model.Bluray720p }) @Html.LabelFor(m => m.Bluray720p) - @Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee" }) + @Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee", data_quality_id = Model.Bluray1080pId }) @Html.LabelFor(m => m.Bluray1080p)
@Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" })