www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 4dc6ef3045dfd257066d166f94d904ae4dfc45dd
parent 2e8e3ffa5df4c538e251b162466327d07713eb6f
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 27 Sep 2016 02:10:14 -0400

Fix #1100, Deleting collection also deletes items

Diffstat:
Mchrome/content/zotero/xpcom/collectionTreeView.js | 4+---
Mtest/tests/zoteroPaneTest.js | 22++++++++++++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1181,9 +1181,7 @@ Zotero.CollectionTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(f //erase collection from DB: var treeRow = this.getRow(rows[i]-i); if (treeRow.isCollection() || treeRow.isFeed()) { - yield treeRow.ref.eraseTx({ - deleteItems: true - }); + yield treeRow.ref.eraseTx({ deleteItems }); if (treeRow.isFeed()) { refreshFeeds = true; } diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js @@ -230,6 +230,28 @@ describe("ZoteroPane", function() { }) }) + describe("#deleteSelectedCollection()", function () { + it("should delete collection but not descendant items by default", function* () { + var collection = yield createDataObject('collection'); + var item = yield createDataObject('item', { collections: [collection.id] }); + var promise = waitForDialog(); + yield zp.deleteSelectedCollection(); + assert.isFalse(Zotero.Collections.exists(collection.id)); + assert.isTrue(Zotero.Items.exists(item.id)); + assert.isFalse(item.deleted); + }); + + it("should delete collection and descendant items when deleteItems=true", function* () { + var collection = yield createDataObject('collection'); + var item = yield createDataObject('item', { collections: [collection.id] }); + var promise = waitForDialog(); + yield zp.deleteSelectedCollection(true); + assert.isFalse(Zotero.Collections.exists(collection.id)); + assert.isTrue(Zotero.Items.exists(item.id)); + assert.isTrue(item.deleted); + }); + }); + describe("#setVirtual()", function () { var cv;