diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index ba10b24284..8c6dd2e1a3 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -179,7 +179,7 @@ var ZoteroItemPane = new function() { var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); if (ps.confirm(null, '', Zotero.getString('pane.item.notes.delete.confirm'))) { - Zotero.Items.trash(id); + Zotero.Items.trashTx(id); } } diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 230b5d489b..680394f69f 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1037,7 +1037,9 @@ Zotero.CollectionTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(f //erase collection from DB: var treeRow = this.getRow(rows[i]-i); if (treeRow.isCollection()) { - yield treeRow.ref.erase(deleteItems); + yield treeRow.ref.eraseTx({ + deleteItems: true + }); } else if (treeRow.isSearch()) { yield Zotero.Searches.erase(treeRow.ref.id); diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index 2d65e3b635..477e5e47b5 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -1136,13 +1136,15 @@ Zotero.DataObject.prototype.updateSynced = Zotero.Promise.coroutine(function* (s * Delete object from database * * @param {Object} [options] + * @param {Boolean} [options.deleteItems] - Move descendant items to trash (Collection only) * @param {Boolean} [options.skipDeleteLog] - Don't add to sync delete log */ -Zotero.DataObject.prototype.erase = Zotero.Promise.coroutine(function* (options) { - options = options || {}; - var env = { - options: options - }; +Zotero.DataObject.prototype.erase = Zotero.Promise.coroutine(function* (options = {}) { + if (!options || typeof options != 'object') { + throw new Error("'options' must be an object"); + } + + var env = { options }; if (!env.options.tx && !Zotero.DB.inTransaction()) { Zotero.logError("erase() called on Zotero." + this._ObjectType + " without a wrapping " diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 763b3563b0..a4dba41713 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -148,6 +148,7 @@ Zotero.defineProperty(Zotero.Item.prototype, 'parentItemKey', { set: function(val) this.parentKey = val }); + Zotero.defineProperty(Zotero.Item.prototype, 'firstCreator', { get: function() this._firstCreator }); diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 8733dd03c0..e21c35fd99 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -492,32 +492,39 @@ Zotero.Items = function() { }; - this.trash = function (ids) { + this.trash = Zotero.Promise.coroutine(function* (ids) { + Zotero.DB.requireTransaction(); + ids = Zotero.flattenArguments(ids); - return Zotero.DB.executeTransaction(function* () { - for (let i=0; i