|
|
|
@ -3,14 +3,57 @@
|
|
|
|
|
className: "quality-profile",
|
|
|
|
|
template: "#QualityProfileTemplate",
|
|
|
|
|
events: {
|
|
|
|
|
'click .quality-selectee': 'toggleAllowed'
|
|
|
|
|
'click .quality-selectee': 'toggleAllowed',
|
|
|
|
|
'change .cutoff': 'changeCutoff',
|
|
|
|
|
'change .name': 'changeName'
|
|
|
|
|
},
|
|
|
|
|
toggleAllowed: function (e) {
|
|
|
|
|
//Add to cutoff
|
|
|
|
|
//Update model
|
|
|
|
|
var target = $(e.target);
|
|
|
|
|
|
|
|
|
|
var checked = $(e.target).attr('checked') != undefined;
|
|
|
|
|
this.model.set({ });
|
|
|
|
|
var checked = $(target).attr('checked') != undefined;
|
|
|
|
|
var id = this.model.get("Id");
|
|
|
|
|
|
|
|
|
|
var qualities = _.clone(this.model.get("Qualities"));
|
|
|
|
|
_.each(qualities, function (qualityType) {
|
|
|
|
|
var qualityId = parseInt($(target).attr('data-quality-id'));
|
|
|
|
|
|
|
|
|
|
if (qualityType.Id == qualityId) {
|
|
|
|
|
qualityType.Allowed = checked;
|
|
|
|
|
|
|
|
|
|
//Todo: Add/Remove from cutoff
|
|
|
|
|
//Find cutoff dropdown
|
|
|
|
|
var cutoff = ('select#' + id);
|
|
|
|
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
$('<option>' + qualityType.Name + '</option>').val(qualityId).appendTo(cutoff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
$(cutoff).find('option[value="' + qualityId + '"]').remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.model.set({ "Qualities": qualities });
|
|
|
|
|
this.model.save();
|
|
|
|
|
},
|
|
|
|
|
changeCutoff: function(e) {
|
|
|
|
|
//Todo: save change
|
|
|
|
|
var cutoff = $(e.target).val();
|
|
|
|
|
|
|
|
|
|
this.model.set({ "Cutoff": cutoff });
|
|
|
|
|
this.model.save();
|
|
|
|
|
},
|
|
|
|
|
changeName: function(e) {
|
|
|
|
|
var name = $(e.target).val();
|
|
|
|
|
|
|
|
|
|
//Todo: update default quality dropdown
|
|
|
|
|
$('#DefaultQualityProfileId option[value="' + this.model.get("Id") + '"]').html(name);
|
|
|
|
|
|
|
|
|
|
this.model.set({ "Name": name });
|
|
|
|
|
this.model.save();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|