Update empty state of parent collection when deleting subcollection
This commit is contained in:
parent
a57ea28d42
commit
55e9a0ee35
|
@ -605,6 +605,16 @@ Zotero.Collection.prototype._eraseData = Zotero.Promise.coroutine(function* (env
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update child collection cache of parent collection
|
||||||
|
if (this.parentKey) {
|
||||||
|
let parentCollectionID = this.ObjectsClass.getIDFromLibraryAndKey(
|
||||||
|
this.libraryID, this.parentKey
|
||||||
|
);
|
||||||
|
Zotero.DB.addCurrentCallback("commit", function () {
|
||||||
|
this.ObjectsClass.unregisterChildCollection(parentCollectionID, this.id);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
var placeholders = collections.map(() => '?').join();
|
var placeholders = collections.map(() => '?').join();
|
||||||
|
|
||||||
// Remove item associations for all descendent collections
|
// Remove item associations for all descendent collections
|
||||||
|
|
|
@ -168,6 +168,17 @@ describe("Zotero.Collection", function() {
|
||||||
var childCollections = collection1.getChildCollections();
|
var childCollections = collection1.getChildCollections();
|
||||||
assert.lengthOf(childCollections, 0);
|
assert.lengthOf(childCollections, 0);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should not include collections that have been deleted", function* () {
|
||||||
|
var collection1 = yield createDataObject('collection');
|
||||||
|
var collection2 = yield createDataObject('collection', { parentID: collection1.id });
|
||||||
|
yield collection1.saveTx();
|
||||||
|
|
||||||
|
yield collection2.eraseTx()
|
||||||
|
|
||||||
|
var childCollections = collection1.getChildCollections();
|
||||||
|
assert.lengthOf(childCollections, 0);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#getChildItems()", function () {
|
describe("#getChildItems()", function () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user