use history

This commit is contained in:
rolux 2013-08-03 14:00:25 +00:00
parent c0cc1b29ca
commit 33ad974d45

View file

@ -397,13 +397,30 @@ pandora.ui.list = function() {
copyadd: function(data) { copyadd: function(data) {
Ox.Clipboard.add(data.ids, 'item'); Ox.Clipboard.add(data.ids, 'item');
}, },
cut: function(data) {
var listData = pandora.getListData();
if (listData.editable && listData.type == 'static') {
Ox.Clipboard.copy(data.ids, 'item');
pandora.doHistory('cut', data.ids, pandora.user.ui._list, function() {
pandora.UI.set({listSelection: []});
pandora.reloadList();
});
}
},
cutadd: function(data) {
var listData = pandora.getListData();
if (listData.editable && listData.type == 'static') {
Ox.Clipboard.add(data.ids, 'item');
pandora.doHistory('cut', data.ids, pandora.user.ui._list, function() {
pandora.UI.set({listSelection: []});
pandora.reloadList();
});
}
},
'delete': function(data) { 'delete': function(data) {
var listData = pandora.getListData(); var listData = pandora.getListData();
if (listData.editable && listData.type == 'static') { if (listData.editable && listData.type == 'static') {
pandora.api.removeListItems({ pandora.doHistory('delete', data.ids, pandora.user.ui._list, function() {
list: pandora.user.ui._list,
items: data.ids
}, function() {
pandora.UI.set({listSelection: []}); pandora.UI.set({listSelection: []});
pandora.reloadList(); pandora.reloadList();
}); });
@ -458,13 +475,9 @@ pandora.ui.list = function() {
} }
}, },
paste: function(data) { paste: function(data) {
var items; var items = Ox.Clipboard.paste();
if (Ox.Clipboard.type() == 'item') { if (items.length && Ox.Clipboard.type() == 'item' && pandora.getListData().editable) {
items = Ox.Clipboard.paste(); pandora.doHistory('paste', items, pandora.user.ui._list, function() {
items.length && pandora.getListData().editable && pandora.api.addListItems({
list: pandora.user.ui._list,
items: items
}, function() {
pandora.UI.set({listSelection: items}); pandora.UI.set({listSelection: items});
pandora.reloadList(); pandora.reloadList();
}); });