From ffc0ff8ebf08d75b274408d84d24e66f4347e9d1 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 28 Jan 2013 19:40:49 -0800 Subject: [PATCH] Quality profile cutoff will be set on add #ND-158 --- .../Scripts/backbone/views/qualityProfiles.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js index 2fdf1567c..23288c306 100644 --- a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js +++ b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js @@ -18,7 +18,6 @@ var el = $(this.el); var checked = $(target).attr('checked') != undefined; - var id = this.model.get("Id"); var qualities = _.clone(this.model.get("Qualities")); _.each(qualities, function (qualityType) { @@ -28,14 +27,14 @@ qualityType.Allowed = checked; //Find cutoff dropdown - var cutoff = $(el).find('.cutoff'); + var cutoffLocal = $(el).find('.cutoff'); if (checked) { - $('').val(qualityId).appendTo(cutoff); + $('').val(qualityId).appendTo(cutoffLocal); } else { - $(cutoff).find('option[value="' + qualityId + '"]').remove(); + $(cutoffLocal).find('option[value="' + qualityId + '"]').remove(); } //Todo: auto-sort by weight (which is not the value) @@ -45,6 +44,13 @@ } }); + var cutoff = $(el).find('.cutoff'); + if (cutoff[0].length === 0) + this.model.set({ "Cutoff": 0 }); + + if (cutoff[0].length === 1) + this.model.set({ "Cutoff": cutoff.val() }); + this.model.set({ "Qualities": qualities }); this.model.save(); },