add live updates for list items counts, fixes #1213

This commit is contained in:
rolux 2013-02-09 10:44:47 +05:30
parent a253d29d1a
commit b0864cfb5a
2 changed files with 17 additions and 2 deletions

View file

@ -60,9 +60,13 @@ pandora.ui.allItems = function() {
pandora.api.find({ pandora.api.find({
query: {conditions: [], operator: '&'} query: {conditions: [], operator: '&'}
}, function(result) { }, function(result) {
$items.html(Ox.formatNumber(result.data.items)); that.update(result.data.items);
}); });
that.update = function(items) {
$items.html(Ox.formatNumber(items));
};
that.resizeElement = function(width) { that.resizeElement = function(width) {
$name.css({width: width + 'px'}); $name.css({width: width + 'px'});
}; };

View file

@ -111,7 +111,6 @@ pandora.ui.list = function() {
that.size(); that.size();
}, },
sort: function(data) { sort: function(data) {
Ox.Log('', '---- SORT ----', data)
pandora.UI.set({ pandora.UI.set({
listSort: [{key: data.key, operator: data.operator}] listSort: [{key: data.key, operator: data.operator}]
}); });
@ -397,6 +396,18 @@ pandora.ui.list = function() {
}); });
}, },
init: function(data) { init: function(data) {
var find = pandora.user.ui.find, folder, list;
if (find.conditions.length == 0) {
pandora.$ui.allItems.update(data.items);
} else if (
find.conditions.length == 1
&& find.conditions[0].key == 'list'
&& find.conditions[0].operator == '=='
) {
list = find.conditions[0].value;
folder = pandora.getListData(list).folder;
pandora.$ui.folderList[folder].value(list, 'items', data.items);
}
pandora.$ui.statusbar.set('total', data); pandora.$ui.statusbar.set('total', data);
data = []; data = [];
pandora.site.totals.forEach(function(v) { pandora.site.totals.forEach(function(v) {