From 81949449ae2a191504d1c77918c7d6854a9067f1 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Tue, 27 Oct 2009 10:25:16 +0000 Subject: [PATCH] fix a couple of bugs in the M.O.M and fix the options tab and file priorities in the torrent add window (success!) --- deluge/ui/web/js/Deluge.Add.js | 16 +++++++--------- deluge/ui/web/js/Deluge.MultiOptionsManager.js | 11 ++++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/deluge/ui/web/js/Deluge.Add.js b/deluge/ui/web/js/Deluge.Add.js index 4fd3288f3..fbb740f7e 100644 --- a/deluge/ui/web/js/Deluge.Add.js +++ b/deluge/ui/web/js/Deluge.Add.js @@ -85,7 +85,7 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { bodyStyle: 'padding: 5px;', border: false, height: 170, - disabled: true + //disabled: true }); var fieldset = this.form.add({ @@ -198,8 +198,6 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { form.layout = new Ext.layout.FormLayout(); form.layout.setContainer(form); form.doLayout(); - - this.optionsManager.changeId(null); }, addTorrent: function(torrent) { @@ -215,9 +213,9 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { priorities[index] = fileIndexes[index]; }); - var oldId = this.optionsManager.changeId(torrent['info_hash'], false); - this.optionsManager.set('file_priorities', priorities); - this.optionsManager.changeId(oldId, false); + var oldId = this.optionsManager.changeId(torrent['info_hash'], true); + this.optionsManager.setDefault('file_priorities', priorities); + this.optionsManager.changeId(oldId, true); }, clear: function() { @@ -263,9 +261,9 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { }, getOptions: function(torrentId) { - var oldId = this.optionsManager.changeId(torrentId, false); + var oldId = this.optionsManager.changeId(torrentId, true); var options = this.optionsManager.get(); - this.optionsManager.changeId(oldTorrentId, false); + this.optionsManager.changeId(oldId, true); Ext.each(options['file_priorities'], function(priority, index) { options['file_priorities'][index] = (priority) ? 1 : 0; }); @@ -334,7 +332,7 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { } priorities[child.attributes.fileindex] = checked; }, this); - this.optionsManager.update('file_priorities', priorities); + this.optionsManager.setDefault('file_priorities', priorities); }, onNodeCheck: function(node, checked) { diff --git a/deluge/ui/web/js/Deluge.MultiOptionsManager.js b/deluge/ui/web/js/Deluge.MultiOptionsManager.js index 290c30ab1..043a739e5 100644 --- a/deluge/ui/web/js/Deluge.MultiOptionsManager.js +++ b/deluge/ui/web/js/Deluge.MultiOptionsManager.js @@ -48,10 +48,10 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * Changes bound fields to use the specified id. * @param {String} id */ - changeId: function(id, updateBinds) { + changeId: function(id, dontUpdateBinds) { var oldId = this.currentId; this.currentId = id; - if (updateBinds) { + if (!dontUpdateBinds) { for (var option in this.options) { if (!this.binds[option]) continue; Ext.each(this.binds[option], function(bind) { @@ -80,10 +80,15 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { if (arguments.length == 1) { var option = arguments[0]; return (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); + } else if (arguments.length == 0) { + var options = {}; + for (var option in this.options) { + options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); + } + return options; } else { var options = {}; Ext.each(arguments, function(option) { - if (!this.has(option)) return; options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); }, this); return options;