summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/models
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-07 15:19:49 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-07 15:19:49 +0100
commitbd015ab580645f2cb9af70be64973a425e5f1552 (patch)
treebe97a3174b45ac57e5ee99abb9a6b065754b8db3 /pyload/web/app/scripts/models
parentpackage edit dialog (diff)
downloadpyload-bd015ab580645f2cb9af70be64973a425e5f1552.tar.xz
updated some deps, button to add links to existing packages
Diffstat (limited to 'pyload/web/app/scripts/models')
-rw-r--r--pyload/web/app/scripts/models/CollectorPackage.js40
1 files changed, 29 insertions, 11 deletions
diff --git a/pyload/web/app/scripts/models/CollectorPackage.js b/pyload/web/app/scripts/models/CollectorPackage.js
index 9582c6af8..17a3a1551 100644
--- a/pyload/web/app/scripts/models/CollectorPackage.js
+++ b/pyload/web/app/scripts/models/CollectorPackage.js
@@ -8,7 +8,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
name: 'Unnamed package',
password: null,
new_name: null,
- links: null
+ links: null,
+ pid: null
},
initialize: function() {
@@ -39,16 +40,33 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection
add: function() {
var self = this;
var links = this.get('links').pluck('url');
-
- $.ajax(App.apiRequest('addPackage',
- {name: this.getName(),
- links: links,
- password: this.get('password')},
- {success: function() {
- self.destroy();
- App.vent.trigger('package:added');
- }}));
-
+ var pid = this.get('pid');
+
+ if (pid !== null && _.isNumber(pid)) {
+ console.log('Adding links to package', pid);
+ $.ajax(App.apiRequest('addLinks',
+ {
+ pid: pid,
+ links: links
+ },
+ {
+ success: function() {
+ self.destroy();
+ App.vent.trigger('collectorPackage:added');
+ }}));
+ }
+ else
+ $.ajax(App.apiRequest('addPackage',
+ {
+ name: this.getName(),
+ links: links,
+ password: this.get('password')
+ },
+ {
+ success: function() {
+ self.destroy();
+ App.vent.trigger('collectorPackage:added');
+ }}));
},
updateLinks: function(links) {