Exclude annotations from library export
We'll want to support this eventually, but for now they would just break translation.
This commit is contained in:
parent
b00325942a
commit
79950ecfe5
2 changed files with 28 additions and 1 deletions
|
@ -1038,7 +1038,15 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
"setAll": Zotero.Promise.coroutine(function* (libraryID, getChildCollections) {
|
"setAll": Zotero.Promise.coroutine(function* (libraryID, getChildCollections) {
|
||||||
this._itemsLeft = yield Zotero.Items.getAll(libraryID, true);
|
this._itemsLeft = (yield Zotero.Items.getAll(libraryID, true))
|
||||||
|
.filter((item) => {
|
||||||
|
// Don't export annotations
|
||||||
|
switch (item.itemType) {
|
||||||
|
case 'annotation':
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
if(getChildCollections) {
|
if(getChildCollections) {
|
||||||
this._collectionsLeft = Zotero.Collections.getByLibrary(libraryID);
|
this._collectionsLeft = Zotero.Collections.getByLibrary(libraryID);
|
||||||
|
|
|
@ -2121,6 +2121,25 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#setAll()", function () {
|
||||||
|
it("should exclude annotations", async function () {
|
||||||
|
var attachment = await importFileAttachment('test.pdf');
|
||||||
|
var annotation = await createAnnotation('highlight', attachment);
|
||||||
|
|
||||||
|
var getter = new Zotero.Translate.ItemGetter();
|
||||||
|
await getter.setAll(attachment.libraryID, false);
|
||||||
|
|
||||||
|
var item;
|
||||||
|
while (item = getter.nextItem()) {
|
||||||
|
if (item.itemType == 'annotation') {
|
||||||
|
assert.fail("Annotation item should not be returned from nextItem()");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.equal(getter.numItems, 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#_attachmentToArray()", function () {
|
describe("#_attachmentToArray()", function () {
|
||||||
it("should handle missing attachment files", function* () {
|
it("should handle missing attachment files", function* () {
|
||||||
var item = yield importFileAttachment('test.png');
|
var item = yield importFileAttachment('test.png');
|
||||||
|
|
Loading…
Reference in a new issue