diff options
Diffstat (limited to 'pyload/web/app/scripts/models/ConfigItem.js')
-rw-r--r-- | pyload/web/app/scripts/models/ConfigItem.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pyload/web/app/scripts/models/ConfigItem.js b/pyload/web/app/scripts/models/ConfigItem.js new file mode 100644 index 000000000..8c75f45f6 --- /dev/null +++ b/pyload/web/app/scripts/models/ConfigItem.js @@ -0,0 +1,42 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], + function($, Backbone, _, App, Api) { + 'use strict'; + + return Backbone.Model.extend({ + + idAttribute: 'name', + + defaults: { + name: '', + label: '', + description: '', + input: null, + value: null, + // additional attributes + inputView: null + }, + + // Model Constructor + initialize: function() { + + }, + + isChanged: function() { + return this.get('inputView') && this.get('inputView').getVal() !== this.get('value'); + }, + + // set new value and return json + prepareSave: function() { + // set the new value + if (this.get('inputView')) + this.set('value', this.get('inputView').getVal()); + + // These values are enough to be handled correctly + return { + name: this.get('name'), + value: this.get('value'), + '@class': this.get('@class') + }; + } + }); + });
\ No newline at end of file |