summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/models/TreeCollection.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-31 23:25:26 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-31 23:25:26 +0200
commitcbd4f4b5375f89362733e10a9b98e5a74c2a5734 (patch)
tree056bb5af9aec5dee164d7f3055819ceb40e92a87 /module/web/static/js/models/TreeCollection.js
parentFixed free space issue closed #676 (diff)
downloadpyload-cbd4f4b5375f89362733e10a9b98e5a74c2a5734.tar.xz
first js models/views
Diffstat (limited to 'module/web/static/js/models/TreeCollection.js')
-rw-r--r--module/web/static/js/models/TreeCollection.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/module/web/static/js/models/TreeCollection.js b/module/web/static/js/models/TreeCollection.js
new file mode 100644
index 000000000..6476ea7b5
--- /dev/null
+++ b/module/web/static/js/models/TreeCollection.js
@@ -0,0 +1,38 @@
+define(['jquery', 'backbone', 'underscore', 'models/Package', 'collections/FileList', 'collections/PackageList'],
+ function($, Backbone, _, Package, FileList, PackageList) {
+
+ // TreeCollection
+ // A Model and not a collection, aggregates other collections
+ return Backbone.Model.extend({
+
+ defaults : {
+ root: null,
+ packages: null,
+ files: null
+ },
+
+ initialize: function() {
+
+ },
+
+ fetch: function(options) {
+ options || (options = {});
+ var pid = options.pid || -1;
+
+ // TODO: more options possible
+ options.url = 'api/getFileTree/' + pid + '/false';
+ options.type = "post";
+
+ return Backbone.Model.prototype.fetch.call(this, options);
+ },
+
+ parse: function(resp, xhr) {
+ return {
+ root: new Package(resp.root),
+ packages: new PackageList(_.values(resp.packages)),
+ files: new FileList(_.values(resp.files))
+ };
+ }
+
+ });
+}); \ No newline at end of file