From a5a7df328ac08de888a495677fe9e8735ad8b35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 15 Aug 2017 11:14:50 +0300 Subject: [PATCH] Changes imports from connector to save to selected collection Closes #1289 --- chrome/content/zotero/xpcom/server_connector.js | 7 ++++++- test/tests/server_connectorTest.js | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index 09cbc4d9b..1ebfcc5c3 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -643,7 +643,12 @@ Zotero.Server.Connector.Import.prototype = { return 400; } translate.setTranslator(translators[0]); - let items = yield translate.translate(); + var { library, collection, editable } = Zotero.Server.Connector.getSaveTarget(); + let arg = {}; + if (editable) { + arg = {libraryID: library.libraryID, collections: [collection.id]}; + } + let items = yield translate.translate(arg); return [201, "application/json", JSON.stringify(items)]; }) } diff --git a/test/tests/server_connectorTest.js b/test/tests/server_connectorTest.js index 4dc2dd0db..f999d35ab 100644 --- a/test/tests/server_connectorTest.js +++ b/test/tests/server_connectorTest.js @@ -513,7 +513,11 @@ describe("Connector Server", function () { assert.equal(error.xmlhttp.status, 400); }); - it('should import resources (BibTeX)', function* () { + it('should import resources (BibTeX) into selected collection', function* () { + var collection = yield createDataObject('collection'); + yield waitForItemsLoad(win); + + var addedItemIDPromise = waitForItemEvent('add'); var resource = `@book{test1, title={Test1}, author={Owl}, @@ -530,6 +534,9 @@ describe("Connector Server", function () { ); assert.equal(response.status, 201); assert.equal(JSON.parse(response.responseText)[0].title, 'Test1'); + + let itemId = yield addedItemIDPromise; + assert.isTrue(collection.hasItem(itemId[0])); }); }); });