diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-16 19:59:25 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-16 19:59:43 +0200 |
commit | 4e9319f2f932a3baf7a8c9c0548eafe8647238f2 (patch) | |
tree | 16d66a41c96ab31ea4fb008c7cbb5b92527db885 /pyload/web/app/scripts/models/Account.js | |
parent | Adapted SimplydebridCom (diff) | |
download | pyload-4e9319f2f932a3baf7a8c9c0548eafe8647238f2.tar.xz |
settings for individual accounts
Diffstat (limited to 'pyload/web/app/scripts/models/Account.js')
-rw-r--r-- | pyload/web/app/scripts/models/Account.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/pyload/web/app/scripts/models/Account.js b/pyload/web/app/scripts/models/Account.js index d98d3374f..94893f3e2 100644 --- a/pyload/web/app/scripts/models/Account.js +++ b/pyload/web/app/scripts/models/Account.js @@ -1,4 +1,4 @@ -define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($, Backbone, _, App, Api) { +define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', './ConfigItem'], function($, Backbone, _, App, Api, ConfigItem) { 'use strict'; return Backbone.Model.extend({ @@ -30,6 +30,15 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($ }, + parse: function(resp) { + // Convert config to models + resp.config = _.map(resp.config, function(item) { + return new ConfigItem(item); + }); + + return resp; + }, + fetch: function(options) { var refresh = _.has(options, 'refresh') && options.refresh; options = App.apiRequest('getAccountInfo', @@ -47,8 +56,16 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($ }, save: function() { + // use changed config items only + var data = this.toJSON(); + data.config = _.map(_.filter(data.config, function(c){ + return c.isChanged(); + }), function(c) { + return c.prepareSave(); + }); + // On success wait 1sec and trigger event to reload info - var options = App.apiRequest('updateAccountInfo', {account: this.toJSON()}, { + var options = App.apiRequest('updateAccountInfo', {account: data}, { success: function() { _.delay(function() { App.vent.trigger('account:updated'); |