2014-05-04 17:26:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
oml.ui.list = function() {
|
|
|
|
|
|
|
|
var ui = oml.user.ui,
|
|
|
|
|
|
|
|
that = oml.ui[ui.listView + 'View']()
|
|
|
|
.bindEvent({
|
|
|
|
closepreview: function() {
|
|
|
|
oml.$ui.previewButton.options({value: false});
|
|
|
|
oml.$ui.previewDialog.close();
|
|
|
|
delete oml.$ui.previewDialog;
|
|
|
|
},
|
2014-05-17 11:45:57 +00:00
|
|
|
copy: function(data) {
|
2014-05-19 15:00:33 +00:00
|
|
|
oml.clipboard.copy(data.ids, 'book');
|
2014-05-17 11:45:57 +00:00
|
|
|
},
|
|
|
|
copyadd: function(data) {
|
2014-05-19 15:00:33 +00:00
|
|
|
oml.clipboard.copy(data.ids, 'book');
|
2014-05-17 11:45:57 +00:00
|
|
|
},
|
|
|
|
cut: function(data) {
|
|
|
|
var listData = oml.getListData();
|
|
|
|
if (listData.editable && listData.type == 'static') {
|
2014-05-19 15:00:33 +00:00
|
|
|
oml.clipboard.copy(data.ids, 'book');
|
2014-05-17 11:45:57 +00:00
|
|
|
oml.doHistory('cut', data.ids, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: []});
|
2014-05-17 14:42:46 +00:00
|
|
|
oml.$ui.folders.updateElement();
|
|
|
|
oml.$ui.list.updateElement();
|
2014-05-17 11:45:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cutadd: function(data) {
|
|
|
|
var listData = oml.getListData();
|
|
|
|
if (listData.editable && listData.type == 'static') {
|
2014-05-19 15:00:33 +00:00
|
|
|
oml.clipboard.add(data.ids, 'book');
|
2014-05-17 11:45:57 +00:00
|
|
|
oml.doHistory('cut', data.ids, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: []});
|
2014-05-17 14:42:46 +00:00
|
|
|
oml.$ui.folders.updateElement();
|
|
|
|
oml.$ui.list.updateElement();
|
2014-05-17 11:45:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2014-05-17 14:42:46 +00:00
|
|
|
'delete': function(data) {
|
2014-05-17 11:45:57 +00:00
|
|
|
var listData = oml.getListData();
|
|
|
|
if (listData.editable && listData.type == 'static') {
|
|
|
|
oml.doHistory('delete', data.ids, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: []});
|
2014-05-17 14:42:46 +00:00
|
|
|
oml.$ui.folders.updateItems();
|
|
|
|
oml.$ui.list.updateElement();
|
2014-05-17 11:45:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2014-05-04 17:26:43 +00:00
|
|
|
init: function(data) {
|
2014-05-18 23:24:04 +00:00
|
|
|
if (ui.find.conditions.length == 0 || (
|
|
|
|
ui.find.conditions.length == 1
|
|
|
|
&& ui.find.conditions[0].key == 'list'
|
|
|
|
&& ui.find.conditions[0].operator == '=='
|
|
|
|
)) {
|
|
|
|
oml.$ui.folders.updateItems(data.items);
|
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
oml.$ui.statusbar.set('total', data);
|
|
|
|
},
|
2014-05-17 11:45:57 +00:00
|
|
|
key_control_delete: function() {
|
|
|
|
var listData = oml.getListData();
|
|
|
|
if (listData.own) {
|
|
|
|
oml.ui.deleteItemsDialog().open();
|
|
|
|
}
|
|
|
|
},
|
2014-05-18 23:24:04 +00:00
|
|
|
key_shift_enter: function() {
|
|
|
|
var selected = that.options('selected');
|
|
|
|
if (selected.length) {
|
|
|
|
oml.UI.set({
|
|
|
|
item: selected[0],
|
|
|
|
itemView: 'book'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2014-05-04 17:26:43 +00:00
|
|
|
open: function(data) {
|
|
|
|
oml.UI.set({
|
|
|
|
item: data.ids[0],
|
|
|
|
itemView: 'info'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
openpreview: function() {
|
|
|
|
if (!oml.$ui.previewDialog) {
|
|
|
|
oml.$ui.previewButton.options({value: true});
|
|
|
|
oml.$ui.previewDialog = oml.ui.previewDialog()
|
|
|
|
.open()
|
|
|
|
.bindEvent({
|
|
|
|
close: function() {
|
|
|
|
that.closePreview();
|
|
|
|
delete oml.$ui.previewDialog;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2014-05-17 11:45:57 +00:00
|
|
|
oml.$ui.previewDialog.updateElement();
|
2014-05-04 17:26:43 +00:00
|
|
|
}
|
|
|
|
},
|
2014-05-19 15:00:33 +00:00
|
|
|
paste: function(data) {
|
|
|
|
var items = oml.clipboard.paste();
|
2016-01-08 04:11:22 +00:00
|
|
|
if (
|
|
|
|
items.length
|
|
|
|
&& oml.clipboard.type() == 'book'
|
|
|
|
&& oml.getListData().editable
|
|
|
|
) {
|
2014-05-19 15:00:33 +00:00
|
|
|
oml.doHistory('paste', items, ui._list, function() {
|
|
|
|
oml.UI.set({listSelection: items});
|
|
|
|
oml.reloadList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2014-05-04 17:26:43 +00:00
|
|
|
resize: function(data) {
|
|
|
|
// this is the resize event of the split panel
|
|
|
|
that.size();
|
|
|
|
},
|
|
|
|
select: function(data) {
|
|
|
|
oml.UI.set({listSelection: data.ids});
|
|
|
|
},
|
|
|
|
oml_find: function() {
|
2014-05-25 12:16:04 +00:00
|
|
|
if (ui.listView == oml.UI.getPrevious().listView) {
|
2016-01-08 04:11:22 +00:00
|
|
|
if (
|
|
|
|
JSON.stringify(ui.listSort)
|
|
|
|
!= JSON.stringify(oml.UI.getPrevious().listSort)
|
|
|
|
) {
|
|
|
|
/*
|
|
|
|
that.options({sort: ...}) would already reload
|
|
|
|
the list, but not update the number of items
|
|
|
|
*/
|
|
|
|
var options = that.options();
|
|
|
|
options.sort = Ox.clone(ui.listSort, true);
|
2014-10-31 13:18:26 +00:00
|
|
|
}
|
2016-01-08 04:11:22 +00:00
|
|
|
that.reloadList();
|
2014-05-25 12:16:04 +00:00
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
},
|
|
|
|
oml_item: function() {
|
|
|
|
if (!ui.item) {
|
|
|
|
that.gainFocus();
|
|
|
|
} else {
|
|
|
|
that.options({selected: [ui.item]});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
oml_listselection: function(data) {
|
2014-05-25 12:16:04 +00:00
|
|
|
if (ui._list == oml.UI.getPrevious()._list) {
|
|
|
|
that.options({selected: data.value});
|
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
},
|
|
|
|
oml_listsort: function(data) {
|
2014-05-25 12:16:04 +00:00
|
|
|
if (ui._list == oml.UI.getPrevious()._list) {
|
|
|
|
that.options({sort: data.value});
|
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
},
|
|
|
|
oml_sidebarsize: function(data) {
|
|
|
|
that.size();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-05-12 12:57:47 +00:00
|
|
|
oml.enableDragAndDrop(that);
|
|
|
|
|
2014-05-17 11:45:57 +00:00
|
|
|
that.updateElement = function() {
|
2014-05-17 14:42:46 +00:00
|
|
|
Ox.Request.clearCache('find');
|
2014-05-17 11:45:57 +00:00
|
|
|
that.reloadList(true);
|
|
|
|
};
|
|
|
|
|
2014-05-04 17:26:43 +00:00
|
|
|
return that;
|
|
|
|
|
2014-05-19 18:12:02 +00:00
|
|
|
};
|