mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Fixed up UI changes when model is edited
This commit is contained in:
parent
d481000001
commit
8be47a128c
3 changed files with 30 additions and 16 deletions
|
@ -57,16 +57,27 @@
|
|||
changeName: function(e) {
|
||||
var name = $(e.target).val();
|
||||
|
||||
$('#DefaultQualityProfileId option[value="' + this.model.get("Id") + '"]').html(name);
|
||||
|
||||
this.model.set({ "Name": name });
|
||||
this.model.save();
|
||||
this.model.save(this.model, {
|
||||
success: function (model) {
|
||||
var id = model.get('Id');
|
||||
var name = model.get('Name');
|
||||
|
||||
var exists = $('#DefaultQualityProfileId option[value="' + id + '"]');
|
||||
|
||||
if (exists.length == 0)
|
||||
$('#DefaultQualityProfileId').append($('\<option\> \</option\>').val(id).html(name));
|
||||
|
||||
else
|
||||
$('#DefaultQualityProfileId option[value="' + id + '"]').html(name);
|
||||
}
|
||||
});
|
||||
},
|
||||
destroy: function (e) {
|
||||
//if (e === undefined)
|
||||
// return;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
$("#DefaultQualityProfileId option[value='" + this.model.get('Id') + "']").remove();
|
||||
|
||||
this.model.destroy();
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
@ -81,10 +92,6 @@ QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
|
|||
itemView: QualityProfileView,
|
||||
template: QualityProfileApp.Constants.Templates.QualityProfileCollection,
|
||||
|
||||
//appendHtml: function (collectionView, itemView) {
|
||||
// collectionView.$('#collection').append(itemView.el);
|
||||
//},
|
||||
|
||||
initialize: function () {
|
||||
_.bindAll(this, 'render');
|
||||
this.collection = new QualityProfileCollection();
|
||||
|
@ -96,8 +103,8 @@ QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
|
|||
},
|
||||
addProfile: function (e) {
|
||||
e.preventDefault();
|
||||
//Add new profile to collection
|
||||
//Todo: How will we get the list of qualities (they would all be NOT allowed) - it all comes from the server side...
|
||||
|
||||
//Todo: Need to get the default profile from the server, instead of creating it manually...
|
||||
var newProfile = new QualityProfile({
|
||||
Name: '', Cutoff: 0, Qualities: [
|
||||
{ "Id": 0, "Weight": 0, "Name": "Unknown", "Allowed": false },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue