Fix cross-library collection dragging from read-only library

This has apparently always been broken.
This commit is contained in:
Dan Stillman 2020-05-20 08:45:37 -04:00
parent b2c03a9a3e
commit 30cefca18e
2 changed files with 47 additions and 1 deletions

View file

@ -2093,7 +2093,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
var collectionID = yield newCollection.save();
// Record link
yield c.addLinkedCollection(newCollection);
yield newCollection.addLinkedCollection(c);
// Recursively copy subcollections
if (desc.children.length) {

View file

@ -868,6 +868,26 @@ describe("Zotero.CollectionTreeView", function() {
assert.isFalse(yield canDrop('item', 'L' + group.libraryID, [item.id]));
})
it("should copy an item from a read-only group to an editable group", async function () {
var group1 = await createGroup();
var item = await createDataObject('item', { libraryID: group1.libraryID });
group1.editable = false;
await group1.saveTx();
var group2 = await createGroup();
await cv.selectLibrary(group1.libraryID);
await waitForItemsLoad(win);
await drop('item', 'L' + group2.libraryID, [item.id]);
assert.isFalse(await item.getLinkedItem(group2.libraryID));
// New collection should link back to original
assert.ok(await item.getLinkedItem(group2.libraryID, true));
await group1.eraseTx();
await group2.eraseTx();
});
it("should remove a linked, trashed item in a group from the trash and collections", function* () {
var group = yield getGroup();
var collection = yield createDataObject('collection', { libraryID: group.libraryID });
@ -1122,6 +1142,32 @@ describe("Zotero.CollectionTreeView", function() {
assert.isFalse(newCollectionA.hasItem(newItemB));
assert.isFalse(newCollectionB.hasItem(newItemA));
})
it("should copy a collection from a read-only group to another group", async function () {
var group1 = await createGroup();
var collection = await createDataObject('collection', { libraryID: group1.libraryID });
var item = await createDataObject('item', { libraryID: group1.libraryID, collections: [collection.id] });
group1.editable = false;
await group1.saveTx();
var group2 = await getGroup();
await cv.selectCollection(collection.id);
await waitForItemsLoad(win);
await drop('collection', 'L' + group2.libraryID, [collection.id]);
assert.isFalse(await collection.getLinkedCollection(group2.libraryID));
// New collection should link back to original
assert.ok(await collection.getLinkedCollection(group2.libraryID, true));
assert.isFalse(await item.getLinkedItem(group2.libraryID));
// New item should link back to original
assert.ok(await item.getLinkedItem(group2.libraryID, true));
await group1.eraseTx();
await group2.eraseTx();
});
})