diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 0a3cde389..af9844fd2 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -749,6 +749,54 @@ Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) { } +Zotero.CollectionTreeView.prototype.selectTrash = function (libraryID) { + if (Zotero.suppressUIUpdates) { + Zotero.debug("UI updates suppressed -- not changing library selection"); + return false; + } + + // Check if trash is already selected + if (this.selection.currentIndex != -1) { + let itemGroup = this._getItemAtRow(this.selection.currentIndex); + if (itemGroup.isTrash() && itemGroup.ref.libraryID == libraryID) { + this._treebox.ensureRowIsVisible(this.selection.currentIndex); + return true; + } + } + + // If in My Library and it's collapsed, open it + if (!libraryID && !this.isContainerOpen(0)) { + this.toggleOpenState(0); + } + + // Find library trash + for (let i = 0; i < this.rowCount; i++) { + let itemGroup = this._getItemAtRow(i); + + // If group header is closed, open it + if (itemGroup.isHeader() && itemGroup.ref.id == 'group-libraries-header' + && !this.isContainerOpen(i)) { + this.toggleOpenState(i); + continue; + } + + if (itemGroup.isLibrary(true) && itemGroup.ref.libraryID == libraryID + && !this.isContainerOpen(i)) { + this.toggleOpenState(i); + continue; + } + + if (itemGroup.isTrash() && itemGroup.ref.libraryID == libraryID) { + this._treebox.ensureRowIsVisible(i); + this.selection.select(i); + return true; + } + } + + return false; +} + + /** * Select the last-viewed source */ diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 494ba064e..883b6952f 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1764,6 +1764,12 @@ Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse) // Get the row of the parent, if there is one var parentRow = null; var item = Zotero.Items.get(id); + + // Can't select a deleted item if we're not in the trash + if (item.deleted && !this.itemGroup.isTrash()) { + return false; + } + var parent = item.getSource(); if (parent && this._itemRowMap[parent] != undefined) { parentRow = this._itemRowMap[parent]; diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 9192fbc19..e64888bc6 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -2132,6 +2132,42 @@ Zotero.Sync.Server = new function () { }, 1); break; + case 'NOTE_TOO_LONG': + if (!Zotero.Sync.Runner.background) { + let libraryKey = xmlhttp.responseXML.firstChild.getElementsByTagName('item'); + if (libraryKey.length) { + let [libraryID, key] = libraryKey[0].textContent.split('/'); + if (Zotero.Libraries.getType(libraryID) == 'user') { + libraryID = null; + } + let item = Zotero.Items.getByLibraryAndKey(libraryID, key); + if (item) { + let msg = xmlhttp.responseXML.firstChild.getElementsByTagName('error')[0].textContent; + let e = new Zotero.Error( + msg, + 0, + { + dialogText: msg, + dialogButtonText: Zotero.getString('pane.items.showItemInLibrary'), + dialogButtonCallback: function () { + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + var win = wm.getMostRecentWindow("navigator:browser"); + win.ZoteroPane.selectItem(item.id); + } + } + ); + _error(e); + } + else { + let msg = "Long note " + libraryKey[0].textContent + " not found!"; + Zotero.debug(msg, 1); + Components.utils.reportError(msg); + } + } + } + break; + case 'TAG_TOO_LONG': if (!Zotero.Sync.Runner.background) { var tag = xmlhttp.responseXML.firstChild.getElementsByTagName('tag'); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 632491034..c505c5a0b 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1411,6 +1411,14 @@ var ZoteroPane = new function() for (var i=0, len=itemsView.selection.getRangeCount(); i