diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-25 19:12:39 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-25 19:12:39 +0100 |
commit | b5f66789e70bd105e162470927942c40496cdc92 (patch) | |
tree | 3a762f29008dd7d7c92221eb363f90580f8acb6f /module/web/static/js/models/ConfigHolder.js | |
parent | added view type for input fields (diff) | |
download | pyload-b5f66789e70bd105e162470927942c40496cdc92.tar.xz |
simple rendering for settings page
Diffstat (limited to 'module/web/static/js/models/ConfigHolder.js')
-rw-r--r-- | module/web/static/js/models/ConfigHolder.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/module/web/static/js/models/ConfigHolder.js b/module/web/static/js/models/ConfigHolder.js new file mode 100644 index 000000000..8beb31fb8 --- /dev/null +++ b/module/web/static/js/models/ConfigHolder.js @@ -0,0 +1,44 @@ +define(['jquery', 'backbone', 'underscore', 'app', './ConfigItem'], + function($, Backbone, _, App, ConfigItem) { + + return Backbone.Model.extend({ + + defaults: { + name: "", + label: "", + description: "", + long_description: null, + // simple list but no collection + items: null, + info: null + }, + + // Model Constructor + initialize: function() { + + }, + + // Loads it from server by name + fetch: function(options) { + options = App.apiRequest('loadConfig/"' + this.get('name') + '"', null, options); + return Backbone.Model.prototype.fetch.call(this, options); + }, + + save: function(options) { + // TODO + }, + + parse: function(resp) { + // Create item models + resp.items = _.map(resp.items, function(item) { + return new ConfigItem(item); + }); + + return Backbone.Model.prototype.parse.call(this, resp); + }, + + isLoaded: function() { + return this.has('items') || this.has('long_description'); + } + }); + });
\ No newline at end of file |