fix subcollection not being copied to library root (#5464)
Fixes: #5463
This commit is contained in:
parent
8379bdc8cd
commit
ef5f8be920
2 changed files with 25 additions and 3 deletions
|
@ -1971,9 +1971,8 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
if (desc.type == 'collection') {
|
||||
var c = await Zotero.Collections.getAsync(desc.id);
|
||||
let newCollection = c.clone(targetLibraryID);
|
||||
if (parentID) {
|
||||
newCollection.parentID = parentID;
|
||||
}
|
||||
// set the parent collection if provided or null if copying to root library
|
||||
newCollection.parentID = parentID || null;
|
||||
var collectionID = await newCollection.save();
|
||||
|
||||
// Record link only if copying to a different library
|
||||
|
|
|
@ -1958,6 +1958,29 @@ describe("ZoteroPane", function() {
|
|||
// Menu of the library with linked sub-collection should be disabled
|
||||
assert.equal(groupMenu.disabled, true);
|
||||
});
|
||||
|
||||
it("should copy subcollection to library root", async function () {
|
||||
let collectionParent = await createDataObject('collection');
|
||||
let collectionChild = await createDataObject('collection', { parentID: collectionParent.id });
|
||||
let libraryDestination = Zotero.Libraries.get(collectionChild.libraryID);
|
||||
|
||||
let item = await createDataObject('item', { collections: [collectionChild.id] });
|
||||
|
||||
await zp.collectionsView.selectByID("C" + collectionChild.id);
|
||||
|
||||
await zp.copyCollection(libraryDestination);
|
||||
let data = await waitForNotifierEvent("add", "collection");
|
||||
let collectionID = data.ids[0];
|
||||
let newCollection = Zotero.Collections.get(collectionID);
|
||||
|
||||
// Copied collection has the same name as the original
|
||||
assert.equal(newCollection.name, collectionChild.name);
|
||||
// Copied collections contain the same item
|
||||
let items = newCollection.getDescendents(false, 'item').map(item => item.id);
|
||||
assert.sameMembers(items, [item.id]);
|
||||
// Copied collection is a top-level collection
|
||||
assert.notOk(newCollection.parentID);
|
||||
});
|
||||
});
|
||||
describe("#moveCollection", function () {
|
||||
it("should move collection into another collection of the same library", async function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue