lazyload list/edit item count
This commit is contained in:
parent
475a784da5
commit
7c5620f51d
1 changed files with 28 additions and 0 deletions
|
@ -155,6 +155,11 @@ pandora.ui.folderList = function(id, section) {
|
|||
{key: 'status', value: 'featured', operator: '='}
|
||||
], operator: '&'};
|
||||
}
|
||||
var _updateItemsCount = false;
|
||||
if (data.keys && Ox.contains(data.keys, 'items')) {
|
||||
data.keys = data.keys.filter(function(key) { return key != 'items' })
|
||||
_updateItemsCount = true;
|
||||
}
|
||||
return pandora.api['find' + folderItems](Ox.extend(data, {
|
||||
query: query
|
||||
}), function(result) {
|
||||
|
@ -162,6 +167,13 @@ pandora.ui.folderList = function(id, section) {
|
|||
pandora.$ui.mainMenu.updateLists(id, result.data.items);
|
||||
}
|
||||
callback(result);
|
||||
if (result.data.items.length && _updateItemsCount) {
|
||||
setTimeout(function() {
|
||||
updateItemsCount(result.data.items.map(function(item) {
|
||||
return item.id;
|
||||
}));
|
||||
}, 500)
|
||||
}
|
||||
});
|
||||
};
|
||||
} else {
|
||||
|
@ -451,5 +463,21 @@ pandora.ui.folderList = function(id, section) {
|
|||
}
|
||||
}
|
||||
|
||||
function updateItemsCount(ids) {
|
||||
Ox.serialForEach(ids, function(item, index, items, callback) {
|
||||
pandora.api['find' + folderItems]({
|
||||
keys: ['items'],
|
||||
query: {
|
||||
conditions: [{key: 'id', value: item, operator: '=='}]
|
||||
},
|
||||
range: [0, 1]
|
||||
}, function(result) {
|
||||
that.value(item, 'items', result.data.items[0].items);
|
||||
callback();
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return that;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue