add a couple of extra methods to the option manager
updateOptions in onRequestComplete in the options tab
This commit is contained in:
parent
ea2a79a903
commit
629b239739
|
@ -56,6 +56,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
|
Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.fieldsets = {}, this.fields = {};
|
this.fieldsets = {}, this.fields = {};
|
||||||
|
this.optionsManager = new Deluge.OptionsManager();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bandwidth Options
|
* Bandwidth Options
|
||||||
|
@ -317,7 +318,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
if (this.torrentId) {
|
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) {
|
onRequestComplete: function(torrent, options) {
|
||||||
|
this.optionsManager.updateOptions(this.torrentId, torrent);
|
||||||
for (var key in torrent) {
|
for (var key in torrent) {
|
||||||
if (this.fields[key]) {
|
if (this.fields[key]) {
|
||||||
|
//this.
|
||||||
this.fields[key].setValue(torrent[key])
|
this.fields[key].setValue(torrent[key])
|
||||||
} else {
|
} else {
|
||||||
//alert(key);
|
//alert(key);
|
||||||
|
|
|
@ -36,16 +36,15 @@ Copyright:
|
||||||
* @namespace Deluge
|
* @namespace Deluge
|
||||||
* @class Deluge.OptionsManager
|
* @class Deluge.OptionsManager
|
||||||
*/
|
*/
|
||||||
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
Deluge.OptionsManager = function(config) {
|
||||||
|
|
||||||
initComponent: function() {
|
|
||||||
Deluge.OptionsManager.superclass.initComponent.call(this);
|
|
||||||
this.changed = {};
|
this.changed = {};
|
||||||
this.options = {};
|
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 {String} id
|
||||||
* @param {Object} options The default options for the 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.
|
* Set the specified options for the passed in id.
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
* @param {object} options The option values to change.
|
* @param {Object} options The option values to change.
|
||||||
*/
|
*/
|
||||||
setOptions: function(id, options) {
|
setOptions: function(id, options) {
|
||||||
if (!this.changed[id]) this.changed[id] = {};
|
if (!this.changed[id]) this.changed[id] = {};
|
||||||
this.changed[id] = Ext.extend(this.changed[id], options);
|
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
Loading…
Reference in New Issue