Allow dragging parent items to collection if children are selected

This is a simplified version of the fix from #872. Unlike the proposal
in #36, this doesn't require all child items to be selected, since in a
search some children might be grayed out. If the child of an unselected
parent item is included, the drag isn't allowed.

Closes #36
This commit is contained in:
Dan Stillman 2018-02-03 04:09:55 -05:00
parent ad216bcf97
commit 38411fb56c
3 changed files with 40 additions and 0 deletions

View file

@ -480,4 +480,23 @@ describe("Zotero.Items", function () {
assert.instanceOf(feedItem, Zotero.FeedItem);
});
});
describe("#keepParents()", function () {
it("should remove child items of passed items", async function () {
var item1 = await createDataObject('item');
var item2 = await createDataObject('item', { itemType: 'note', parentItemID: item1.id });
var item3 = await createDataObject('item', { itemType: 'note', parentItemID: item1.id });
var item4 = await createDataObject('item');
var item5 = await createDataObject('item', { itemType: 'note', parentItemID: item4.id });
var otherItem = await createDataObject('item');
var item6 = await createDataObject('item', { itemType: 'note', parentItemID: otherItem.id });
var items = Zotero.Items.keepParents([item1, item2, item3, item4, item5, item6]);
assert.sameMembers(
// Convert to ids for clearer output
items.map(item => item.id),
[item1, item4, item6].map(item => item.id)
);
});
});
});