From cbd4f4b5375f89362733e10a9b98e5a74c2a5734 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 31 Aug 2012 23:25:26 +0200 Subject: first js models/views --- module/web/static/js/models/Package.js | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 module/web/static/js/models/Package.js (limited to 'module/web/static/js/models/Package.js') diff --git a/module/web/static/js/models/Package.js b/module/web/static/js/models/Package.js new file mode 100644 index 000000000..e5b0dc5a7 --- /dev/null +++ b/module/web/static/js/models/Package.js @@ -0,0 +1,52 @@ +define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { + + return Backbone.Model.extend({ + + idAttribute: 'pid', + + defaults: { + pid: -1, + name : null, + folder: "", + root: -1, + owner: -1, + site: "", + comment: "", + password: "", + added: -1, + status: -1, + packageorder: -1, + stats: null, + fids: null, + pids: null, + files: null, // Collection + packs: null // Collection + }, + + // Model Constructor + initialize: function() { + + }, + + // Changes url + method and delegates call to super class + fetch: function(options) { + options || (options = {}); + options.url = 'api/getPackageInfo/' + this.get('pid'); + options.type = "post"; + + return Backbone.Model.prototype.fetch.call(options); + + }, + + save: function(options) { + // TODO + }, + + // Any time a model attribute is set, this method is called + validate: function(attrs) { + + } + + }); + +}); \ No newline at end of file -- cgit v1.2.3