Author: damoxc

Revision: 5854

Log:
        fixes to the M.O.M and the options details tab, still not 100% though

Diff:
Modified: branches/1.2_RC/deluge/ui/web/js/Deluge.Details.Options.js
===================================================================
--- branches/1.2_RC/deluge/ui/web/js/Deluge.Details.Options.js  2009-10-20 
22:45:32 UTC (rev 5853)
+++ branches/1.2_RC/deluge/ui/web/js/Deluge.Details.Options.js  2009-10-21 
19:48:44 UTC (rev 5854)
@@ -51,13 +51,13 @@
                }, config);
                Ext.deluge.details.OptionsTab.superclass.constructor.call(this, 
config);
        },
-       
+
        initComponent: function() {
                
Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
                
                this.fieldsets = {}, this.fields = {};
                this.optionsManager = new Deluge.MultiOptionsManager({
-                       defaults: {
+                       options: {
                                'max_download_speed': -1,
                                'max_upload_speed': -1,
                                'max_connections': -1,
@@ -209,9 +209,10 @@
                });
                
                this.fields.is_auto_managed = this.fieldsets.queue.add({
+                       xtype: 'checkbox',
                        fieldLabel: '',
                        labelSeparator: '',
-                       id: 'is_auto_managed',
+                       name: 'is_auto_managed',
                        boxLabel: _('Auto Managed'),
                        width: 200,
                        colspan: 2
@@ -364,13 +365,14 @@
        },
        
        reset: function() {
-               if (this.torrentId) {
-                       this.optionsManager.reset(this.torrentId);
-               }
+               if (this.torrentId) this.optionsManager.reset(this.torrentId);
        },
        
        update: function(torrentId) {
-               this.torrentId = torrentId;
+               if (this.torrentId != torrentId) {
+                       this.torrentId = torrentId;
+                       this.optionsManager.changeId(torrentId);
+               }
                Deluge.Client.core.get_torrent_status(torrentId, 
Deluge.Keys.Options, {
                        success: this.onRequestComplete,
                        scope: this
@@ -378,7 +380,7 @@
        },
        
        onApply: function() {
-               var changed = this.optionsManager.getChanged(this.torrentId);
+               var changed = this.optionsManager.getDirty(this.torrentId);
                if (!Ext.isEmpty(changed['prioritize_first_last'])) {
                        var value = changed['prioritize_first_last'];
                        
Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
@@ -390,8 +392,7 @@
                }
                Deluge.Client.core.set_torrent_options([this.torrentId], 
changed, {
                        success: function() {
-                               this.optionsManager.set(this.torrentId, 
changed);
-                               this.optionsManager.reset(this.torrentId);
+                               this.optionsManager.commit(this.torrentId);
                        },
                        scope: this
                });
@@ -411,8 +412,7 @@
        onRequestComplete: function(torrent, options) {
                this.fields['private'].setDisabled(!torrent['private']);
                delete torrent['private'];
-               
-               this.optionsManager.update(this.torrentId, torrent);
+               this.optionsManager.setDefault(this.torrentId, torrent);
        }
 });
 Deluge.Details.add(new Ext.deluge.details.OptionsTab());

Modified: branches/1.2_RC/deluge/ui/web/js/Deluge.MultiOptionsManager.js
===================================================================
--- branches/1.2_RC/deluge/ui/web/js/Deluge.MultiOptionsManager.js      
2009-10-20 22:45:32 UTC (rev 5853)
+++ branches/1.2_RC/deluge/ui/web/js/Deluge.MultiOptionsManager.js      
2009-10-21 19:48:44 UTC (rev 5854)
@@ -149,14 +149,26 @@
         * @param {String} option
         * @param {Object} value The value for the option
         */
-       set: function(id, option, value) {
-               if (typeof value === undefined) {
+       setDefault: function(id, option, value) {
+               if (value === undefined) {
                        for (var key in option) {
-                               this.set(id, key, option[key]);
+                               this.setDefault(id, key, option[key]);
                        }
                } else {
-                       if (!this.changed[id]) this.changed[id] = {};
-                       this.changed[id][option] = value;
+                       var oldValue = this.getDefault(id, option);
+                       value = this.convertValueType(oldValue, value);
+                       
+                       // If the value is the same as the old value there is 
+                       // no point in setting it again.
+                       if (oldValue == value) return;
+                       
+                       // Store the new default
+                       if (!this.stored[id]) this.stored[id] = {};
+                       this.stored[id][option] = value;
+                       
+                       if (!this.isDirty(id, option)) {
+                               this.fireEvent('changed', id, option, value, 
oldValue);
+                       }
                }
        },
 

Modified: trunk/deluge/ui/web/js/Deluge.Details.Options.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.Details.Options.js    2009-10-20 22:45:32 UTC 
(rev 5853)
+++ trunk/deluge/ui/web/js/Deluge.Details.Options.js    2009-10-21 19:48:44 UTC 
(rev 5854)
@@ -51,13 +51,13 @@
                }, config);
                Ext.deluge.details.OptionsTab.superclass.constructor.call(this, 
config);
        },
-       
+
        initComponent: function() {
                
Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
                
                this.fieldsets = {}, this.fields = {};
                this.optionsManager = new Deluge.MultiOptionsManager({
-                       defaults: {
+                       options: {
                                'max_download_speed': -1,
                                'max_upload_speed': -1,
                                'max_connections': -1,
@@ -209,9 +209,10 @@
                });
                
                this.fields.is_auto_managed = this.fieldsets.queue.add({
+                       xtype: 'checkbox',
                        fieldLabel: '',
                        labelSeparator: '',
-                       id: 'is_auto_managed',
+                       name: 'is_auto_managed',
                        boxLabel: _('Auto Managed'),
                        width: 200,
                        colspan: 2
@@ -364,13 +365,14 @@
        },
        
        reset: function() {
-               if (this.torrentId) {
-                       this.optionsManager.reset(this.torrentId);
-               }
+               if (this.torrentId) this.optionsManager.reset(this.torrentId);
        },
        
        update: function(torrentId) {
-               this.torrentId = torrentId;
+               if (this.torrentId != torrentId) {
+                       this.torrentId = torrentId;
+                       this.optionsManager.changeId(torrentId);
+               }
                Deluge.Client.core.get_torrent_status(torrentId, 
Deluge.Keys.Options, {
                        success: this.onRequestComplete,
                        scope: this
@@ -378,7 +380,7 @@
        },
        
        onApply: function() {
-               var changed = this.optionsManager.getChanged(this.torrentId);
+               var changed = this.optionsManager.getDirty(this.torrentId);
                if (!Ext.isEmpty(changed['prioritize_first_last'])) {
                        var value = changed['prioritize_first_last'];
                        
Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
@@ -390,8 +392,7 @@
                }
                Deluge.Client.core.set_torrent_options([this.torrentId], 
changed, {
                        success: function() {
-                               this.optionsManager.set(this.torrentId, 
changed);
-                               this.optionsManager.reset(this.torrentId);
+                               this.optionsManager.commit(this.torrentId);
                        },
                        scope: this
                });
@@ -411,8 +412,7 @@
        onRequestComplete: function(torrent, options) {
                this.fields['private'].setDisabled(!torrent['private']);
                delete torrent['private'];
-               
-               this.optionsManager.update(this.torrentId, torrent);
+               this.optionsManager.setDefault(this.torrentId, torrent);
        }
 });
 Deluge.Details.add(new Ext.deluge.details.OptionsTab());

Modified: trunk/deluge/ui/web/js/Deluge.MultiOptionsManager.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.MultiOptionsManager.js        2009-10-20 
22:45:32 UTC (rev 5853)
+++ trunk/deluge/ui/web/js/Deluge.MultiOptionsManager.js        2009-10-21 
19:48:44 UTC (rev 5854)
@@ -149,14 +149,26 @@
         * @param {String} option
         * @param {Object} value The value for the option
         */
-       set: function(id, option, value) {
-               if (typeof value === undefined) {
+       setDefault: function(id, option, value) {
+               if (value === undefined) {
                        for (var key in option) {
-                               this.set(id, key, option[key]);
+                               this.setDefault(id, key, option[key]);
                        }
                } else {
-                       if (!this.changed[id]) this.changed[id] = {};
-                       this.changed[id][option] = value;
+                       var oldValue = this.getDefault(id, option);
+                       value = this.convertValueType(oldValue, value);
+                       
+                       // If the value is the same as the old value there is 
+                       // no point in setting it again.
+                       if (oldValue == value) return;
+                       
+                       // Store the new default
+                       if (!this.stored[id]) this.stored[id] = {};
+                       this.stored[id][option] = value;
+                       
+                       if (!this.isDirty(id, option)) {
+                               this.fireEvent('changed', id, option, value, 
oldValue);
+                       }
                }
        },
 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to