Fixed quality settings

This commit is contained in:
Mark McDowall 2012-10-14 16:09:07 -07:00
parent 2a1bb8989f
commit 5f217f5720
4 changed files with 28 additions and 17 deletions

View File

@ -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<QualityTypes>();

View File

@ -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<QualityTypes> 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; }
}
}

View File

@ -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')) {
$('<option>' + name + '</option>').appendTo(cutoff);
$('<option>' + name + '</option>').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();
}
});

View File

@ -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))
</div>
<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.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)
</div>
@Html.HiddenFor(x => x.QualityProfileId, new { @class = "qualityProfileId" })