Merge pull request #712 from retorquere/export-group
export groups (#487)
This commit is contained in:
commit
7761335bc7
|
@ -76,6 +76,10 @@ Zotero_File_Exporter.prototype.save = function() {
|
||||||
translation.setCollection(this.collection);
|
translation.setCollection(this.collection);
|
||||||
} else if(this.items) {
|
} else if(this.items) {
|
||||||
translation.setItems(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);
|
translation.setLocation(fp.file);
|
||||||
|
@ -129,7 +133,11 @@ var Zotero_File_Interface = new function() {
|
||||||
*/
|
*/
|
||||||
function exportFile() {
|
function exportFile() {
|
||||||
var exporter = new Zotero_File_Exporter();
|
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();
|
exporter.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2110,17 +2110,23 @@ Zotero.Translate.Export.prototype.Sandbox = Zotero.Translate.Sandbox._inheritFro
|
||||||
* @param {Zotero.Item[]} items
|
* @param {Zotero.Item[]} items
|
||||||
*/
|
*/
|
||||||
Zotero.Translate.Export.prototype.setItems = function(items) {
|
Zotero.Translate.Export.prototype.setItems = function(items) {
|
||||||
this._items = items;
|
this._export = {type: 'items', items: items};
|
||||||
delete this._collection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @param {Zotero.Collection[]} collection
|
||||||
*/
|
*/
|
||||||
Zotero.Translate.Export.prototype.setCollection = function(collection) {
|
Zotero.Translate.Export.prototype.setCollection = function(collection) {
|
||||||
this._collection = collection;
|
this._export = {type: 'collection', collection: collection};
|
||||||
delete this._items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2182,15 +2188,21 @@ Zotero.Translate.Export.prototype._prepareTranslation = function() {
|
||||||
this._itemGetter = new Zotero.Translate.ItemGetter();
|
this._itemGetter = new Zotero.Translate.ItemGetter();
|
||||||
var configOptions = this._translatorInfo.configOptions || {},
|
var configOptions = this._translatorInfo.configOptions || {},
|
||||||
getCollections = configOptions.getCollections || false;
|
getCollections = configOptions.getCollections || false;
|
||||||
if(this._collection) {
|
switch (this._export.type) {
|
||||||
this._itemGetter.setCollection(this._collection, getCollections);
|
case 'collection':
|
||||||
delete this._collection;
|
this._itemGetter.setCollection(this._export.collection, getCollections);
|
||||||
} else if(this._items) {
|
break;
|
||||||
this._itemGetter.setItems(this._items);
|
case 'items':
|
||||||
delete this._items;
|
this._itemGetter.setItems(this._export.items);
|
||||||
} else {
|
break;
|
||||||
this._itemGetter.setAll(getCollections);
|
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
|
// export file data, if requested
|
||||||
if(this._displayOptions["exportFileData"]) {
|
if(this._displayOptions["exportFileData"]) {
|
||||||
|
|
|
@ -786,11 +786,11 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
this.numItems = this._itemsLeft.length;
|
this.numItems = this._itemsLeft.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
"setAll":function(getChildCollections) {
|
"setAll":function(libraryID, getChildCollections) {
|
||||||
this._itemsLeft = Zotero.Items.getAll(true);
|
this._itemsLeft = Zotero.Items.getAll(true, libraryID);
|
||||||
|
|
||||||
if(getChildCollections) {
|
if(getChildCollections) {
|
||||||
this._collectionsLeft = Zotero.getCollections();
|
this._collectionsLeft = Zotero.getCollections(null, true, libraryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.numItems = this._itemsLeft.length;
|
this.numItems = this._itemsLeft.length;
|
||||||
|
|
|
@ -2173,7 +2173,7 @@ var ZoteroPane = new function()
|
||||||
show = [m.emptyTrash];
|
show = [m.emptyTrash];
|
||||||
}
|
}
|
||||||
else if (itemGroup.isGroup()) {
|
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()) {
|
else if (itemGroup.isDuplicates() || itemGroup.isUnfiled()) {
|
||||||
show = [
|
show = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user