Add "Show Item in Library" button to note-too-long window
TODO: other too-long errors
This commit is contained in:
parent
110bf42e5f
commit
ba2a16531b
5 changed files with 107 additions and 2 deletions
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -1411,6 +1411,14 @@ var ZoteroPane = new function()
|
|||
for (var i=0, len=itemsView.selection.getRangeCount(); i<len; i++) {
|
||||
itemsView.selection.getRangeAt(i, start, end);
|
||||
for (var j=start.value; j<=end.value; j++) {
|
||||
let itemRow = itemsView._getItemAtRow(j);
|
||||
|
||||
// DEBUG: Not sure how this is possible, but it was happening while switching
|
||||
// to an item in the trash in a collapsed library from another library
|
||||
if (!itemRow) {
|
||||
Zotero.debug("Item row " + j + " not found in _nonDeletedItemsSelected()", 2);
|
||||
continue;
|
||||
}
|
||||
if (!itemsView._getItemAtRow(j).ref.deleted) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1961,8 +1969,14 @@ var ZoteroPane = new function()
|
|||
|
||||
var selected = this.itemsView.selectItem(itemID, expand);
|
||||
if (!selected) {
|
||||
Zotero.debug("Item was not selected; switching to library");
|
||||
this.collectionsView.selectLibrary(item.libraryID);
|
||||
if (item.deleted) {
|
||||
Zotero.debug("Item is deleted; switching to trash");
|
||||
this.collectionsView.selectTrash(item.libraryID);
|
||||
}
|
||||
else {
|
||||
Zotero.debug("Item was not selected; switching to library");
|
||||
this.collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
this.itemsView.selectItem(itemID, expand);
|
||||
}
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ pane.items.menu.createParent = Create Parent Item
|
|||
pane.items.menu.createParent.multiple = Create Parent Items
|
||||
pane.items.menu.renameAttachments = Rename File from Parent Metadata
|
||||
pane.items.menu.renameAttachments.multiple = Rename Files from Parent Metadata
|
||||
pane.items.showItemInLibrary = Show Item in Library
|
||||
|
||||
pane.items.letter.oneParticipant = Letter to %S
|
||||
pane.items.letter.twoParticipants = Letter to %S and %S
|
||||
|
|
Loading…
Reference in a new issue