This commit is contained in:
rolux 2014-02-03 06:12:55 +00:00
parent e2a64fe0f1
commit 831d3a68f7

View file

@ -4,10 +4,12 @@
pandora.openDocumentDialog = function(options) { pandora.openDocumentDialog = function(options) {
if (pandora.$ui.documentDialog && options.ids && options.ids.length == 1 if (
&& Ox.getObjectById(pandora.$ui.documentDialog.getItems(), options.ids[0])){ pandora.$ui.documentDialog && options.ids && options.ids.length == 1
&& Ox.getObjectById(pandora.$ui.documentDialog.getItems(), options.ids[0])
) {
pandora.UI.set({document: options.ids[0]}); pandora.UI.set({document: options.ids[0]});
} else if(options.ids) { } else if (options.ids) {
pandora.api.findDocuments({ pandora.api.findDocuments({
query: { query: {
conditions: options.ids.map(function(id) { conditions: options.ids.map(function(id) {
@ -18,11 +20,12 @@ pandora.openDocumentDialog = function(options) {
range: [0, options.ids.length], range: [0, options.ids.length],
keys: ['description', 'dimensions', 'extension', 'id', 'name'] keys: ['description', 'dimensions', 'extension', 'id', 'name']
}, function(result) { }, function(result) {
var i = 0, documents = Ox.sort(result.data.items, function(item) { var i = 0,
return options.ids.indexOf(item.id); documents = Ox.sort(result.data.items, function(item) {
}).map(function(document) { return options.ids.indexOf(item.id);
return Ox.extend({index: i++}, document); }).map(function(document) {
}); return Ox.extend({index: i++}, document);
});
pandora.openDocumentDialog({documents: documents}); pandora.openDocumentDialog({documents: documents});
}); });
} else { } else {
@ -200,6 +203,7 @@ pandora.ui.documentDialog = function(options) {
that.getItems = function() { that.getItems = function() {
return items; return items;
}; };
that.update = function(options) { that.update = function(options) {
items = options.items; items = options.items;
item = items[options.index]; item = items[options.index];