Fix ZoteroPane.selectItem() to rely on itemsView.selectItem() to find the item in the current view if it's there, regardless of mode -- this simplifies ZP.selectItem() and fixes problems adding items while viewing a saved search. If the new item(/attachment/note) matches the saved search, it'll now appear and become selected. Otherwise, Z will switch to the Library and the new item will be selected in there.
There might be some regressions from this, but it seems to work fine. Also: - Fixed JS strict warnings in popup note window - Use Zotero.Notes.add() when using toolbar button instead of a two-stage save with ZP.newItem('note')
This commit is contained in:
parent
26c62fba4b
commit
b8321f13ea
|
@ -25,7 +25,7 @@
|
|||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<binding id="note-editor">
|
||||
<implementation>
|
||||
<field name="itemRef"/>
|
||||
<field name="itemRef">null</field>
|
||||
<property name="item" onget="return this.itemRef;">
|
||||
<setter>
|
||||
<![CDATA[
|
||||
|
@ -42,7 +42,7 @@
|
|||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
<field name="noteRef"/>
|
||||
<field name="noteRef">null</field>
|
||||
<property name="note" onget="return this.noteRef;">
|
||||
<setter>
|
||||
<![CDATA[
|
||||
|
@ -60,7 +60,7 @@
|
|||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
<field name="collectionRef"/>
|
||||
<field name="collectionRef">null</field>
|
||||
<property name="collection" onget="return this.collectionRef;" onset="this.collectionRef = val;"/>
|
||||
<property name="value" onget="return this.id('noteField').value;" onset="this.id('noteField').value = val;"/>
|
||||
<method name="save">
|
||||
|
|
|
@ -262,12 +262,16 @@ var ZoteroPane = new function()
|
|||
}
|
||||
|
||||
item.save();
|
||||
if(itemsView && itemsView._itemGroup.isCollection())
|
||||
|
||||
if (itemsView && itemsView._itemGroup.isCollection()) {
|
||||
itemsView._itemGroup.ref.addItem(item.getID());
|
||||
|
||||
}
|
||||
|
||||
//set to Info tab
|
||||
document.getElementById('zotero-view-item').selectedIndex = 0;
|
||||
|
||||
selectItem(item.getID());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -681,31 +685,17 @@ var ZoteroPane = new function()
|
|||
if (!itemID) {
|
||||
return;
|
||||
}
|
||||
if(itemsView)
|
||||
{
|
||||
if(!itemsView._itemGroup.isLibrary())
|
||||
{
|
||||
if (inLibrary) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
// Select the Library if the item is not in the current collection
|
||||
// TODO: does not work in saved searches
|
||||
else {
|
||||
var item = Zotero.Items.get(itemID);
|
||||
var collectionID = itemsView._itemGroup.ref.getID();
|
||||
if (!item.isRegularItem()) {
|
||||
// If this isn't a regular item, check if the parent is
|
||||
// in the collection instead
|
||||
if (!Zotero.Items.get(item.getSource()).inCollection(collectionID)) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
}
|
||||
else if (!item.inCollection(collectionID)) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (itemsView) {
|
||||
if (!itemsView._itemGroup.isLibrary() && inLibrary) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
|
||||
var selected = itemsView.selectItem(itemID);
|
||||
if (!selected) {
|
||||
collectionsView.selection.select(0);
|
||||
itemsView.selectItem(itemID);
|
||||
}
|
||||
itemsView.selectItem(itemID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1114,25 +1104,21 @@ var ZoteroPane = new function()
|
|||
{
|
||||
if (!popup)
|
||||
{
|
||||
var item = newItem(Zotero.ItemTypes.getID('note'));
|
||||
var note = document.getElementById('zotero-note-editor');
|
||||
try {
|
||||
// trim
|
||||
text = text.replace(/^[\xA0\r\n\s]*(.*)[\xA0\r\n\s]*$/m, "$1");
|
||||
}
|
||||
catch (e){}
|
||||
if (text)
|
||||
{
|
||||
note.value = text;
|
||||
}
|
||||
note.save();
|
||||
note.focus();
|
||||
|
||||
if (parent)
|
||||
{
|
||||
item.setSource(parent);
|
||||
selectItem(item.getID());
|
||||
var itemID = Zotero.Notes.add(text, parent);
|
||||
|
||||
if (itemsView && itemsView._itemGroup.isCollection()) {
|
||||
itemsView._itemGroup.ref.addItem(itemID);
|
||||
}
|
||||
|
||||
selectItem(itemID);
|
||||
|
||||
document.getElementById('zotero-note-editor').focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2343,7 +2343,7 @@ Zotero.Notes = new function(){
|
|||
var bindParams = [
|
||||
note.getID(),
|
||||
(sourceItemID ? {int:sourceItemID} : null),
|
||||
{string:text},
|
||||
{string: text ? text : ''},
|
||||
isAbstract ? 1 : null,
|
||||
];
|
||||
Zotero.DB.query(sql, bindParams);
|
||||
|
|
|
@ -617,6 +617,8 @@ Zotero.ItemTreeView.prototype.selectItem = function(id)
|
|||
|
||||
this.selection.select(row);
|
||||
this._treebox.ensureRowIsVisible(row);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue
Block a user