summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/models/Package.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-06 18:15:24 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-06 18:15:24 +0100
commit1f4c6cd6e4b712263b40de4ce1fcebe716019b4f (patch)
treed25db580032edff61a58b3be426b4681e23addf8 /pyload/web/app/scripts/models/Package.js
parentfixed jshint (diff)
downloadpyload-1f4c6cd6e4b712263b40de4ce1fcebe716019b4f.tar.xz
package edit dialog
Diffstat (limited to 'pyload/web/app/scripts/models/Package.js')
-rw-r--r--pyload/web/app/scripts/models/Package.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/pyload/web/app/scripts/models/Package.js b/pyload/web/app/scripts/models/Package.js
index 555d5b7d6..a1828ed67 100644
--- a/pyload/web/app/scripts/models/Package.js
+++ b/pyload/web/app/scripts/models/Package.js
@@ -41,6 +41,17 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
return obj;
},
+ toServerJSON: function() {
+ var obj = Backbone.Model.prototype.toJSON.call(this);
+ return {
+ pid: obj.pid,
+ site: obj.site,
+ comment: obj.comment,
+ password: obj.password,
+ '@class': 'PackageInfo'
+ };
+ },
+
// Changes url + method and delegates call to super class
fetch: function(options) {
options = App.apiRequest(
@@ -61,8 +72,14 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
return Backbone.Model.prototype.fetch.call(this, options);
},
+ // sync some attributes with the server
save: function(options) {
- // TODO
+ options = App.apiRequest(
+ 'updatePackage',
+ {pack: this.toServerJSON()},
+ options);
+
+ return Backbone.Model.prototype.fetch.call(this, options);
},
togglePaused: function() {
@@ -123,7 +140,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
return resp.root;
}
- return Backbone.model.prototype.parse.call(this, resp);
+ return Backbone.Model.prototype.parse.call(this, resp);
},
// Any time a model attribute is set, this method is called