add a couple of extra methods to the option manager

updateOptions in onRequestComplete in the options tab
This commit is contained in:
Damien Churchill 2009-05-27 16:31:36 +00:00
parent ea2a79a903
commit 629b239739
3 changed files with 38 additions and 11 deletions

View File

@ -56,6 +56,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
this.fieldsets = {}, this.fields = {};
this.optionsManager = new Deluge.OptionsManager();
/*
* Bandwidth Options
@ -317,7 +318,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
reset: function() {
if (this.torrentId) {
delete this.changed[this.torrentId];
this.optionsManager.resetOptions(this.torrentId);
}
},
@ -334,8 +335,10 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
},
onRequestComplete: function(torrent, options) {
this.optionsManager.updateOptions(this.torrentId, torrent);
for (var key in torrent) {
if (this.fields[key]) {
//this.
this.fields[key].setValue(torrent[key])
} else {
//alert(key);

View File

@ -36,16 +36,15 @@ Copyright:
* @namespace Deluge
* @class Deluge.OptionsManager
*/
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
initComponent: function() {
Deluge.OptionsManager.superclass.initComponent.call(this);
Deluge.OptionsManager = function(config) {
this.changed = {};
this.options = {};
},
Deluge.OptionsManager.superclass.constructor.call(this);
};
Ext.extend(Deluge.OptionsManager, Ext.util.Observable, {
/**
* Add a set of options and values for an id to the options manager
* Add a set of default options and values for an id to the options manager
* @param {String} id
* @param {Object} options The default options for the id.
*/
@ -76,10 +75,35 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
/**
* Set the specified options for the passed in id.
* @param {String} id
* @param {object} options The option values to change.
* @param {Object} options The option values to change.
*/
setOptions: function(id, options) {
if (!this.changed[id]) this.changed[id] = {};
this.changed[id] = Ext.extend(this.changed[id], options);
},
/**
* Update the default value for the specified option and id.
* @param {String} id
* @param {String} option
* @param {Object} value;
*/
updateOption: function(id, option, value) {
this.options[id] = value;
},
/**
* Update the defaults for the specified id.
* @param {String} id
* @param {Object} options The option defaults to change.
*/
updateOptions: function(id, options) {
if (!this.options[id]) {
this.addOptions(id, options);
} else {
for (var key in options) {
this.setOption(id, key, options[key]);
}
}
}
});

File diff suppressed because one or more lines are too long