Changes imports from connector to save to selected collection
Closes #1289
This commit is contained in:
parent
cee2e1d47a
commit
a5a7df328a
|
@ -643,7 +643,12 @@ Zotero.Server.Connector.Import.prototype = {
|
||||||
return 400;
|
return 400;
|
||||||
}
|
}
|
||||||
translate.setTranslator(translators[0]);
|
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)];
|
return [201, "application/json", JSON.stringify(items)];
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,11 @@ describe("Connector Server", function () {
|
||||||
assert.equal(error.xmlhttp.status, 400);
|
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,
|
var resource = `@book{test1,
|
||||||
title={Test1},
|
title={Test1},
|
||||||
author={Owl},
|
author={Owl},
|
||||||
|
@ -530,6 +534,9 @@ describe("Connector Server", function () {
|
||||||
);
|
);
|
||||||
assert.equal(response.status, 201);
|
assert.equal(response.status, 201);
|
||||||
assert.equal(JSON.parse(response.responseText)[0].title, 'Test1');
|
assert.equal(JSON.parse(response.responseText)[0].title, 'Test1');
|
||||||
|
|
||||||
|
let itemId = yield addedItemIDPromise;
|
||||||
|
assert.isTrue(collection.hasItem(itemId[0]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user