When merging items, add master item to all collections
Also changes Zotero.Item.prototype.clone() to take an `options` object for its second parameter instead of a boolean `skipTags`. The object includes `skipTags` as well as a new `includeCollections` property to add the new item to the same collections.
This commit is contained in:
parent
e66954a6f7
commit
0b75b75b96
6 changed files with 54 additions and 16 deletions
|
@ -58,5 +58,39 @@ describe("Duplicate Items", function () {
|
|||
assert.property(rels, pred);
|
||||
assert.equal(rels[pred], uri2);
|
||||
});
|
||||
|
||||
it("should combine collections from all items", function* () {
|
||||
var collection1 = yield createDataObject('collection');
|
||||
var collection2 = yield createDataObject('collection');
|
||||
|
||||
var item1 = yield createDataObject('item', { setTitle: true, collections: [collection1.id] });
|
||||
var item2 = item1.clone();
|
||||
item2.setCollections([collection2.id]);
|
||||
yield item2.saveTx();
|
||||
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
var selected = yield cv.selectByID('D' + userLibraryID);
|
||||
assert.ok(selected);
|
||||
yield waitForItemsLoad(win);
|
||||
|
||||
// Select the first item, which should select both
|
||||
var iv = zp.itemsView;
|
||||
var row = iv.getRowIndexByID(item1.id);
|
||||
clickOnItemsRow(iv, row);
|
||||
|
||||
// Click merge button
|
||||
var button = win.document.getElementById('zotero-duplicates-merge-button');
|
||||
button.click();
|
||||
|
||||
yield waitForNotifierEvent('refresh', 'trash');
|
||||
|
||||
// Items should be gone
|
||||
assert.isFalse(iv.getRowIndexByID(item1.id));
|
||||
assert.isFalse(iv.getRowIndexByID(item2.id));
|
||||
assert.isTrue(item2.deleted);
|
||||
assert.isTrue(collection1.hasItem(item1.id));
|
||||
assert.isTrue(collection2.hasItem(item1.id));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue