improve listmap editing functionality

This commit is contained in:
rolux 2011-05-24 13:56:53 +02:00
parent b17e8a783b
commit 0e5172a8fa

View file

@ -1215,6 +1215,18 @@ Ox.List = function(options, self) {
})); }));
} }
function updateSelected() {
var oldSelectedIds = getSelectedIds(),
newSelectedIds = [];
Ox.forEach(self.options.items, function(item) {
if (oldSelectedIds.indexOf(item.id) > -1) {
newSelectedIds.push(item.id);
}
return newSelectedIds.length < oldSelectedIds.length;
});
setSelected(newSelectedIds);
}
function updateSort(map) { function updateSort(map) {
Ox.print('start sort') Ox.print('start sort')
var key = self.options.sort[0].key, var key = self.options.sort[0].key,
@ -1243,8 +1255,10 @@ Ox.List = function(options, self) {
self.setOption = function(key, value) { self.setOption = function(key, value) {
//Ox.print('list setOption', key, value); //Ox.print('list setOption', key, value);
var selectedIds;
if (key == 'items') { if (key == 'items') {
if (Ox.typeOf(value) == 'array') { if (Ox.typeOf(value) == 'array') {
updateSelected();
updateSort(); updateSort();
} else { } else {
updateQuery(); updateQuery();