consolidate list reloading

This commit is contained in:
rlx 2016-01-12 14:22:20 +05:30
parent 16c0514809
commit 904ed06349
8 changed files with 21 additions and 33 deletions

View file

@ -31,10 +31,7 @@ oml.ui.deleteItemsDialog = function() {
oml.UI.set({listSelection: []});
Ox.Request.clearCache(); // too much?
oml.$ui.info.updateElement();
oml.$ui.filters.forEach(function($filter) {
$filter.reloadList();
});
oml.$ui.list.updateElement();
oml.reloadLists();
oml.user.ui.item && oml.UI.set({
item: '',
itemView: 'info'

View file

@ -33,11 +33,7 @@ oml.ui.editDialog = function() {
if (!ui.updateResults && hasChanged) {
Ox.Request.clearCache();
oml.$ui.info.updateElement();
oml.$ui.filters.forEach(function($filter) {
$filter.reloadList();
});
oml.$ui.list.reloadList(true);
oml.$ui.browser.reloadList(true);
oml.reloadLists();
}
that.close();
}

View file

@ -50,11 +50,7 @@ oml.ui.findForm = function(list) {
function updateResults() {
if (list || ui.updateResults) {
Ox.Request.clearCache();
oml.$ui.list.reloadList();
oml.$ui.filters.forEach(function($filter) {
$filter.reloadList();
});
oml.reloadLists();
} else {
oml.UI.set({find: Ox.clone($filter.options('value'), true)});
oml.$ui.findElement.updateElement();

View file

@ -169,8 +169,7 @@ oml.ui.identifyDialog = function(data) {
)), function(result) {
Ox.Request.clearCache('find');
oml.$ui.info.updateElement();
oml.$ui.browser.reloadList(true);
oml.$ui.list.reloadList(true);
oml.reloadLists();
Ox.Request.clearCache(data.id);
oml.$ui.infoView.updateElement(data.id);
that.close();

View file

@ -23,8 +23,7 @@ oml.ui.list = function() {
oml.clipboard.copy(data.ids, 'book');
oml.doHistory('cut', data.ids, ui._list, function() {
oml.UI.set({listSelection: []});
oml.$ui.folders.updateElement();
oml.$ui.list.updateElement();
oml.reloadLists();
});
}
},
@ -34,8 +33,7 @@ oml.ui.list = function() {
oml.clipboard.add(data.ids, 'book');
oml.doHistory('cut', data.ids, ui._list, function() {
oml.UI.set({listSelection: []});
oml.$ui.folders.updateElement();
oml.$ui.list.updateElement();
oml.reloadLists();
});
}
},
@ -44,8 +42,7 @@ oml.ui.list = function() {
if (listData.editable && listData.type == 'static') {
oml.doHistory('delete', data.ids, ui._list, function() {
oml.UI.set({listSelection: []});
oml.$ui.folders.updateItems();
oml.$ui.list.updateElement();
oml.reloadLists();
});
}
},
@ -104,7 +101,7 @@ oml.ui.list = function() {
) {
oml.doHistory('paste', items, ui._list, function() {
oml.UI.set({listSelection: items});
oml.reloadList();
oml.reloadLists();
});
}
},

View file

@ -386,8 +386,7 @@ oml.ui.mainMenu = function() {
if (listData.editable && listData.type == 'static') {
oml.doHistory('delete', ui.listSelection, ui._list, function() {
oml.UI.set({listSelection: []});
oml.$ui.folders.updateItems();
oml.$ui.list.updateElement();
oml.reloadLists();
});
}
} else if (id == 'deletefromlibrary') {
@ -415,7 +414,7 @@ oml.ui.mainMenu = function() {
oml.clipboard[action](ui.listSelection, 'item');
oml.doHistory('cut', ui.listSelection, ui._list, function() {
oml.UI.set({listSelection: []});
oml.reloadList();
oml.reloadLists();
});
} else if (Ox.contains(['copy', 'copyadd'], id)) {
var action = data.id == 'copy' ? 'copy' : 'add';
@ -425,14 +424,14 @@ oml.ui.mainMenu = function() {
var items = oml.clipboard.paste();
oml.doHistory('paste', items, ui._list, function() {
oml.UI.set({listSelection: items});
oml.reloadList();
oml.reloadLists();
});
} else if (data.id == 'clearclipboard') {
oml.clipboard.clear();
} else if (data.id == 'delete') {
oml.doHistory('delete', ui.listSelection, ui._list, function() {
oml.UI.set({listSelection: []});
oml.reloadList();
oml.reloadLists();
});
} else if (data.id == 'editmetadata') {
oml.$ui.editDialog = oml.ui.editDialog().open();

View file

@ -117,9 +117,8 @@
event.originalEvent.stopPropagation();
oml.upload(event.originalEvent.dataTransfer.files, function(response) {
setTimeout(function() {
Ox.Request.clearCache();
oml.reloadLists();
oml.UI.set({listSelection: response.data.ids});
oml.reloadList();
}, 50);
});
}

View file

@ -284,7 +284,7 @@ oml.createLinks = function($element) {
});
if (Ox.contains(object.targets, ui._list)) {
// FIXME: Why is this timeout needed?
setTimeout(oml.reloadList, 250);
setTimeout(oml.reloadLists, 250);
}
callback && callback();
}
@ -882,8 +882,13 @@ oml.openLink = function(url) {
}
};
oml.reloadList = function() {
oml.$ui.list.updateElement();
oml.reloadLists = function() {
Ox.Request.clearCache('find');
oml.$ui.filters.forEach(function($filter) {
$filter.reloadList();
});
oml.$ui.list.reloadList(true);
oml.$ui.browser.reloadList();
};
oml.renameUser = function(data) {