mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
make it easier to manipulate filters
This commit is contained in:
parent
bfdaa47aff
commit
466b245fdf
3 changed files with 24 additions and 13 deletions
|
@ -86,15 +86,15 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the currently selected filter
|
* Return the currently selected filter state
|
||||||
* @returns {String} the current filter
|
* @returns {String} the current filter state
|
||||||
*/
|
*/
|
||||||
getFilter: function() {
|
getState: function() {
|
||||||
if (!this.list.getSelectionCount()) return;
|
if (!this.list.getSelectionCount()) return;
|
||||||
|
|
||||||
var filter = this.list.getSelectedRecords()[0];
|
var state = this.list.getSelectedRecords()[0];
|
||||||
if (filter.id == 'All') return;
|
if (state.id == 'All') return;
|
||||||
return filter.id;
|
return state.id;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,17 +87,28 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
|
||||||
this.fireEvent('afterfiltercreate', this, panel);
|
this.fireEvent('afterfiltercreate', this, panel);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFilters: function() {
|
getFilterStates: function() {
|
||||||
var filters = {}
|
var states = {}
|
||||||
|
|
||||||
// Grab the filters from each of the filter panels
|
// Grab the filters from each of the filter panels
|
||||||
this.items.each(function(panel) {
|
this.items.each(function(panel) {
|
||||||
var filter = panel.getFilter();
|
var state = panel.getState();
|
||||||
if (!filter == null) return;
|
if (!state == null) return;
|
||||||
filters[panel.filterType] = filter;
|
states[panel.filterType] = state;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return filters;
|
return states;
|
||||||
|
},
|
||||||
|
|
||||||
|
hasFilter: function(filter) {
|
||||||
|
var has = false;
|
||||||
|
this.items.each(function(panel) {
|
||||||
|
if (panel.filterType == filter) {
|
||||||
|
has = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return has;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
|
|
|
@ -102,7 +102,7 @@ deluge.ui = {
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
var filters = deluge.sidebar.getFilters();
|
var filters = deluge.sidebar.getFilterStates();
|
||||||
deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
|
deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
|
||||||
success: this.onUpdate,
|
success: this.onUpdate,
|
||||||
failure: this.onUpdateError,
|
failure: this.onUpdateError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue