bug 12728: extend listView widget to take in preFilter. filter Destroyed option from listView filters for regular user.

This commit is contained in:
Jessica Wang 2012-02-01 13:29:35 -08:00
parent d7f6cff115
commit e8d7220ff3
2 changed files with 14 additions and 3 deletions

View File

@ -10,11 +10,19 @@
listView: {
section: 'instances',
filters: {
all: { label: 'All' },
all: { label: 'All' },
mine: { label: 'Mine' },
running: { label: 'Running' },
stopped: { label: 'Stopped' },
destroyed: { label: 'Destroyed' }
destroyed: {
preFilter: function(args) {
if (isAdmin() || isDomainAdmin())
return true;
else
return false;
},
label: 'Destroyed',
}
},
fields: {
name: { label: 'Name', editable: true },

View File

@ -539,7 +539,10 @@
var $filterSelect = $('<select id="filterBy"></select>').appendTo($filters);
if (filters)
$.each(filters, function(key) {
$.each(filters, function(key) {
if(this.preFilter != null && this.preFilter() == false) {
return true; //skip to next item in each loop
}
var $option = $('<option>').attr({
value: key
}).html(this.label);