Fixed quality settings

pull/2/head
Mark McDowall 12 years ago
parent 2a1bb8989f
commit 5f217f5720

@ -127,7 +127,7 @@ namespace NzbDrone.Web.Controllers
public ActionResult Quality() public ActionResult Quality()
{ {
var profiles = _qualityProvider.All().ToList(); var profiles = _qualityProvider.All();
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile); var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile);
var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name"); var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name");
@ -284,7 +284,14 @@ namespace NzbDrone.Web.Controllers
model.Webdl = profile.Allowed.Contains(QualityTypes.WEBDL); model.Webdl = profile.Allowed.Contains(QualityTypes.WEBDL);
model.Bluray720p = profile.Allowed.Contains(QualityTypes.Bluray720p); model.Bluray720p = profile.Allowed.Contains(QualityTypes.Bluray720p);
model.Bluray1080p = profile.Allowed.Contains(QualityTypes.Bluray1080p); 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); return PartialView("QualityProfileItem", model);
} }
@ -473,7 +480,7 @@ namespace NzbDrone.Web.Controllers
var profile = new QualityProfile(); var profile = new QualityProfile();
profile.QualityProfileId = profileModel.QualityProfileId; profile.QualityProfileId = profileModel.QualityProfileId;
profile.Name = profileModel.Name; profile.Name = profileModel.Name;
profile.Cutoff = profileModel.Cutoff; profile.Cutoff = (QualityTypes)profileModel.Cutoff;
profile.Allowed = new List<QualityTypes>(); profile.Allowed = new List<QualityTypes>();

@ -18,7 +18,7 @@ namespace NzbDrone.Web.Models
[DisplayName("Cut-off")] [DisplayName("Cut-off")]
[Required(ErrorMessage = "Valid Cut-off is Required")] [Required(ErrorMessage = "Valid Cut-off is Required")]
public QualityTypes Cutoff { get; set; } public int Cutoff { get; set; }
[DisplayName("Allowed Qualities")] [DisplayName("Allowed Qualities")]
public List<QualityTypes> Allowed { get; set; } public List<QualityTypes> Allowed { get; set; }
@ -26,20 +26,26 @@ namespace NzbDrone.Web.Models
//Quality Booleans //Quality Booleans
[DisplayName("SDTV")] [DisplayName("SDTV")]
public bool Sdtv { get; set; } public bool Sdtv { get; set; }
public int SdtvId { get; set; }
[DisplayName("DVD")] [DisplayName("DVD")]
public bool Dvd { get; set; } public bool Dvd { get; set; }
public int DvdId { get; set; }
[DisplayName("HDTV")] [DisplayName("HDTV")]
public bool Hdtv { get; set; } public bool Hdtv { get; set; }
public int HdtvId { get; set; }
[DisplayName("WEBDL")] [DisplayName("WEBDL")]
public bool Webdl { get; set; } public bool Webdl { get; set; }
public int WebdlId { get; set; }
[DisplayName("Bluray720p")] [DisplayName("Bluray720p")]
public bool Bluray720p { get; set; } public bool Bluray720p { get; set; }
public int Bluray720pId { get; set; }
[DisplayName("Bluray1080p")] [DisplayName("Bluray1080p")]
public bool Bluray1080p { get; set; } public bool Bluray1080p { get; set; }
public int Bluray1080pId { get; set; }
} }
} }

@ -70,21 +70,19 @@ $(document).on('click', '.quality-selectee', function () {
var cleanId = getCleanId(this); var cleanId = getCleanId(this);
var cutoff = '#' + cleanId + '_Cutoff'; var cutoff = '#' + cleanId + '_Cutoff';
var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text(); var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text();
var qualityId = $(this).attr('data-quality-id');
//Remove 'Unknown' //Remove 'Unknown'
$(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); }); $(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); });
//Add option to cutoff SelectList //Add option to cutoff SelectList
if ($(this).attr('checked')) { if ($(this).attr('checked')) {
$('<option>' + name + '</option>').appendTo(cutoff); $('<option>' + name + '</option>').val(qualityId).appendTo(cutoff);
} }
//Remove option from cutoff SelectList //Remove option from cutoff SelectList
else { else {
$(cutoff + ' option').each(function () { $(cutoff).find('option[value="' + qualityId + '"]').remove();
if ($(this).text().indexOf(name) > -1)
$(cutoff + ' option').remove(':contains("' + $(this).text() + '")');
});
} }
}); });

@ -20,20 +20,20 @@
@Html.LabelFor(x => x.Name) @Html.LabelFor(x => x.Name)
@Html.TextBoxFor(x => x.Name, new { @class = "profileName_textbox" }) @Html.TextBoxFor(x => x.Name, new { @class = "profileName_textbox" })
@Html.LabelFor(x => x.Cutoff) @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))
</div> </div>
<div class="qualitySelectees"> <div class="qualitySelectees">
@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.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.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.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.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.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.LabelFor(m => m.Bluray1080p)
</div> </div>
@Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" }) @Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" })

Loading…
Cancel
Save