From 4c837452954e4645e6ecf0bb9d8d16d13efe33bf Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Fri, 20 Mar 2009 17:15:46 +0000 Subject: [PATCH] change the cursor to a pointer when over the filters add in generating the filters dict and applying it to the update_ui call --- deluge/ui/web/css/deluge.css | 1 + deluge/ui/web/js/deluge-bars.js | 54 +++++++++++++++++++++++++++++++-- deluge/ui/web/js/deluge-ui.js | 3 +- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/deluge/ui/web/css/deluge.css b/deluge/ui/web/css/deluge.css index e23d3756b..f4a0b1092 100644 --- a/deluge/ui/web/css/deluge.css +++ b/deluge/ui/web/css/deluge.css @@ -154,6 +154,7 @@ input { height: 16px; line-height: 16px; padding: 2px; + cursor: pointer; } .x-deluge-filters .x-deluge-filter { diff --git a/deluge/ui/web/js/deluge-bars.js b/deluge/ui/web/js/deluge-bars.js index 5393cd676..98c8ecd14 100644 --- a/deluge/ui/web/js/deluge-bars.js +++ b/deluge/ui/web/js/deluge-bars.js @@ -335,6 +335,7 @@ Deluge.SideBar = { onRender: function(bar) { this.Bar = bar; Deluge.Events.on("disconnect", this.onDisconnect); + this.selected = null; }, onDisconnect: function() { @@ -354,8 +355,26 @@ Deluge.SideBar = { return String.format('
{0} ({1})
', value, r.data['count'], lname, image); }, + getFilters: function() { + var filters = {} + if (!this.selected) { + return filters; + } + if (!this.selected.filter || !this.selected.panel) { + return filters; + } + var filterType = this.selected.panel.store.id; + if (filterType == "state" && this.selected.filter == "All") { + return filters; + } + + filters[filterType] = this.selected.filter; + return filters; + }, + update: function(filters) { - $each(filters, function(states, filter) { + filters = new Hash(filters); + filters.each(function(states, filter) { if (this.panels.has(filter)) { this.updateFilter(filter, states); } else { @@ -365,7 +384,7 @@ Deluge.SideBar = { // Perform a cleanup of fitlers that aren't enabled $each(this.panels.getKeys(), function(filter) { - if (!fitlers.has(filter)) { + if (!filters.has(filter)) { // We need to remove the panel } }); @@ -398,6 +417,12 @@ Deluge.SideBar = { {id: 'filter', sortable: false, renderer: this.renderer, dataIndex: 'filter'} ], stripeRows: false, + selModel: new Ext.grid.RowSelectionModel({ + singleSelect: true, + listeners: { + 'rowselect': this.onSelect.bindWithEvent(this) + } + }), hideHeaders: true, autoExpandColumn: 'filter', deferredRender: false, @@ -408,11 +433,36 @@ Deluge.SideBar = { this.Bar.add(panel); this.Bar.doLayout(); + if (!this.selected) { + panel.getSelectionModel().selectFirstRow(); + this.selected = { + row: 0, + filter: states[0][0], + panel: panel + } + } + this.panels[filter] = panel; }, + onSelect: function(selModel, rowIndex, record) { + if (!this.selected) needsUpdate = true; + else if (this.selected.row != rowIndex) needsUpdate = true; + else needsUpdate = false; + this.selected = { + row: rowIndex, + filter: record.get('filter'), + panel: this.panels[record.store.id] + } + + if (needsUpdate) Deluge.Ui.update(); + }, + updateFilter: function(filter, states) { this.panels[filter].store.loadData(states); + if (this.selected && this.selected.panel == this.panels[filter]) { + this.panels[filter].getSelectionModel().selectRow(this.selected.row); + } } }; diff --git a/deluge/ui/web/js/deluge-ui.js b/deluge/ui/web/js/deluge-ui.js index e7798d824..9a04a8acd 100644 --- a/deluge/ui/web/js/deluge-ui.js +++ b/deluge/ui/web/js/deluge-ui.js @@ -52,7 +52,8 @@ Deluge.Ui = { }, update: function() { - Deluge.Client.web.update_ui(Deluge.Keys.Grid, {}, { + var filters = Deluge.SideBar.getFilters(); + Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, { onSuccess: this.onUpdate.bindWithEvent(this), onFailure: this.onUpdateError.bindWithEvent(this) });