mirror of https://github.com/apache/cloudstack.git
cloudStack 3.0 new UI - listView widget - (1) remove default option "All". (2) fix a bug that args.filterBy.kind got value from wrong dropdown when selectView dropdown and filterBy dropdown both exist on the same page.
This commit is contained in:
parent
d9a5f851b5
commit
f8945168ae
|
|
@ -10,6 +10,7 @@
|
|||
listView: {
|
||||
section: 'instances',
|
||||
filters: {
|
||||
all: { label: 'All' },
|
||||
mine: { label: 'Mine' },
|
||||
running: { label: 'Running' },
|
||||
stopped: { label: 'Stopped' },
|
||||
|
|
@ -720,10 +721,12 @@
|
|||
},
|
||||
|
||||
dataProvider: function(args) {
|
||||
var array1 = [];
|
||||
var array1 = [];
|
||||
if(args.filterBy != null) {
|
||||
if(args.filterBy.kind != null) {
|
||||
switch(args.filterBy.kind) {
|
||||
case "all":
|
||||
break;
|
||||
case "mine":
|
||||
array1.push("&domainid=" + g_domainid + "&account=" + g_account);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,12 @@
|
|||
title: 'Templates',
|
||||
listView: {
|
||||
id: 'templates',
|
||||
label: 'Templates',
|
||||
label: 'Templates',
|
||||
filters: {
|
||||
mine: { label: 'Mine' },
|
||||
featured: { label: 'Featured' },
|
||||
community: { label: 'Community' }
|
||||
},
|
||||
fields: {
|
||||
name: { label: 'Name' },
|
||||
id: { label: 'ID' },
|
||||
|
|
@ -382,9 +387,32 @@
|
|||
|
||||
},
|
||||
|
||||
dataProvider: function(args) {
|
||||
dataProvider: function(args) {
|
||||
var array1 = [];
|
||||
if(args.filterBy != null) {
|
||||
if(args.filterBy.kind != null) {
|
||||
switch(args.filterBy.kind) {
|
||||
case "mine":
|
||||
array1.push("&templatefilter=self");
|
||||
break;
|
||||
case "featured":
|
||||
array1.push("&templatefilter=featured");
|
||||
break;
|
||||
case "community":
|
||||
array1.push("&templatefilter=community");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) {
|
||||
switch(args.filterBy.search.by) {
|
||||
case "name":
|
||||
array1.push("&keyword=" + args.filterBy.search.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url: createURL("listTemplates&templatefilter=self&page="+args.page+"&pagesize="+pageSize),
|
||||
url: createURL("listTemplates&page=" + args.page + "&pagesize=" + pageSize + array1.join("")),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function(json) {
|
||||
|
|
|
|||
|
|
@ -441,9 +441,8 @@
|
|||
var $filters = $('<div></div>').addClass('filters reduced-hide');
|
||||
$filters.append('<label>Filter By: </label>');
|
||||
|
||||
var $filterSelect = $('<select></select>').appendTo($filters);
|
||||
$filterSelect.append('<option value="all">All</option>'); // Always appears by default
|
||||
|
||||
var $filterSelect = $('<select id="filterBy"></select>').appendTo($filters);
|
||||
|
||||
if (filters)
|
||||
$.each(filters, function(key) {
|
||||
var $option = $('<option>').attr({
|
||||
|
|
@ -871,13 +870,21 @@
|
|||
|
||||
createFilters($toolbar, listViewData.filters);
|
||||
createSearchBar($toolbar);
|
||||
|
||||
loadBody(
|
||||
$table,
|
||||
listViewData.dataProvider,
|
||||
listViewData.fields,
|
||||
false,
|
||||
{
|
||||
page: page,
|
||||
page: page,
|
||||
filterBy: {
|
||||
kind: $listView.find('select[id=filterBy]').val(),
|
||||
search: {
|
||||
value: $listView.find('input[type=text]').val(),
|
||||
by: 'name'
|
||||
}
|
||||
},
|
||||
ref: args.ref
|
||||
},
|
||||
actions,
|
||||
|
|
@ -928,7 +935,7 @@
|
|||
{
|
||||
page: 1,
|
||||
filterBy: {
|
||||
kind: $listView.find('select').val(),
|
||||
kind: $listView.find('select[id=filterBy]').val(),
|
||||
search: {
|
||||
value: $listView.find('input[type=text]').val(),
|
||||
by: 'name'
|
||||
|
|
|
|||
Loading…
Reference in New Issue