Fix relations import via translators

Fixes #1282
This commit is contained in:
Dan Stillman 2017-09-22 01:02:50 -04:00
parent 10cae22c55
commit 0d3d4323b5
2 changed files with 28 additions and 2 deletions

View file

@ -94,7 +94,16 @@ Zotero.Translate.Sandbox = {
Zotero.debug("Translate: WARNING: Zotero.Item#complete() called after Zotero.done(); please fix your code", 2);
}
const allowedObjects = ["complete", "attachments", "seeAlso", "creators", "tags", "notes"];
const allowedObjects = [
"complete",
"attachments",
"creators",
"tags",
"notes",
"relations",
// Is this still needed?
"seeAlso"
];
// Create a new object here, so that we strip the "complete" property
var newItem = {};

View file

@ -222,6 +222,23 @@ describe("Zotero.Translate", function() {
checkTestTags(note3);
});
it('should save relations', async function () {
var item = await createDataObject('item');
var itemURI = Zotero.URI.getItemURI(item);
let myItem = {
itemType: "book",
title: "Test Item",
relations: {
"dc:relation": [itemURI]
}
};
let newItems = await saveItemsThroughTranslator("import", [myItem]);
var relations = newItems[0].getRelations();
assert.lengthOf(Object.keys(relations), 1);
assert.lengthOf(relations["dc:relation"], 1);
assert.equal(relations["dc:relation"][0], itemURI);
});
it('should save collections', function* () {
let translate = new Zotero.Translate.Import();
translate.setString("");