www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0d3d4323b5b457d119228df66707257b985a02d8
parent 10cae22c55accc7ce4843ac860cd1c9b7293e033
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 22 Sep 2017 01:02:50 -0400

Fix relations import via translators

Fixes #1282

Diffstat:
Mchrome/content/zotero/xpcom/translation/translate.js | 11++++++++++-
Mtest/tests/translateTest.js | 19++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -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 = {}; diff --git a/test/tests/translateTest.js b/test/tests/translateTest.js @@ -221,7 +221,24 @@ describe("Zotero.Translate", function() { assert.equal(note3.getNote(), "standalone note"); 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("");