Merge pull request #712 from retorquere/export-group

export groups (#487)
This commit is contained in:
Dan Stillman 2015-05-12 12:03:00 -04:00
commit 7761335bc7
4 changed files with 38 additions and 18 deletions

View file

@ -76,6 +76,10 @@ Zotero_File_Exporter.prototype.save = function() {
translation.setCollection(this.collection);
} else if(this.items) {
translation.setItems(this.items);
} else if(this.libraryID === undefined) {
throw new Error('No export configured');
} else {
translation.setLibraryID(this.libraryID);
}
translation.setLocation(fp.file);
@ -129,7 +133,11 @@ var Zotero_File_Interface = new function() {
*/
function exportFile() {
var exporter = new Zotero_File_Exporter();
exporter.name = Zotero.getString("pane.collections.library");
exporter.libraryID = ZoteroPane_Local.getSelectedLibraryID();
if (exporter.libraryID === false) {
throw new Error('No library selected');
}
exporter.name = Zotero.Libraries.getName(exporter.libraryID);
exporter.save();
}

View file

@ -2110,17 +2110,23 @@ Zotero.Translate.Export.prototype.Sandbox = Zotero.Translate.Sandbox._inheritFro
* @param {Zotero.Item[]} items
*/
Zotero.Translate.Export.prototype.setItems = function(items) {
this._items = items;
delete this._collection;
this._export = {type: 'items', items: items};
}
/**
* Sets the collection to be exported (overrides setItems)
* Sets the group to be exported (overrides setItems/setCollection)
* @param {Zotero.Group[]} group
*/
Zotero.Translate.Export.prototype.setLibraryID = function(libraryID) {
this._export = {type: 'library', id: libraryID};
}
/**
* Sets the collection to be exported (overrides setItems/setGroup)
* @param {Zotero.Collection[]} collection
*/
Zotero.Translate.Export.prototype.setCollection = function(collection) {
this._collection = collection;
delete this._items;
this._export = {type: 'collection', collection: collection};
}
/**
@ -2182,15 +2188,21 @@ Zotero.Translate.Export.prototype._prepareTranslation = function() {
this._itemGetter = new Zotero.Translate.ItemGetter();
var configOptions = this._translatorInfo.configOptions || {},
getCollections = configOptions.getCollections || false;
if(this._collection) {
this._itemGetter.setCollection(this._collection, getCollections);
delete this._collection;
} else if(this._items) {
this._itemGetter.setItems(this._items);
delete this._items;
} else {
this._itemGetter.setAll(getCollections);
switch (this._export.type) {
case 'collection':
this._itemGetter.setCollection(this._export.collection, getCollections);
break;
case 'items':
this._itemGetter.setItems(this._export.items);
break;
case 'library':
this._itemGetter.setAll(this._export.id, getCollections);
break;
default:
throw new Error('No export set up');
break;
}
delete this._export;
// export file data, if requested
if(this._displayOptions["exportFileData"]) {

View file

@ -786,11 +786,11 @@ Zotero.Translate.ItemGetter.prototype = {
this.numItems = this._itemsLeft.length;
},
"setAll":function(getChildCollections) {
this._itemsLeft = Zotero.Items.getAll(true);
"setAll":function(libraryID, getChildCollections) {
this._itemsLeft = Zotero.Items.getAll(true, libraryID);
if(getChildCollections) {
this._collectionsLeft = Zotero.getCollections();
this._collectionsLeft = Zotero.getCollections(null, true, libraryID);
}
this.numItems = this._itemsLeft.length;

View file

@ -2173,7 +2173,7 @@ var ZoteroPane = new function()
show = [m.emptyTrash];
}
else if (itemGroup.isGroup()) {
show = [m.newCollection, m.newSavedSearch, m.sep1, m.showDuplicates, m.showUnfiled];
show = [m.newCollection, m.newSavedSearch, m.sep1, m.showDuplicates, m.showUnfiled, m.sep2, m.exportFile];
}
else if (itemGroup.isDuplicates() || itemGroup.isUnfiled()) {
show = [