Fix some bugs adding items to various views

- Refresh Unfiled Items view when items are added
- Fix brief freeze ("too much recursion") adding an item to a search
  where the new item doesn't appear. Now, select the library root
  instead if a manually added item doesn't appear in the current view.
- Fix immediate closing of title field when adding an item to a
  collection rather than the library root
This commit is contained in:
Dan Stillman 2013-11-21 19:52:13 -05:00
parent 5d85bffc9c
commit 1e0674cf7c
2 changed files with 13 additions and 10 deletions

View file

@ -317,6 +317,8 @@ Zotero.ItemTreeView.prototype._refreshGenerator = function()
var usiDisabled = Zotero.UnresponsiveScriptIndicator.disable();
Zotero.ItemGroupCache.clear();
this._searchMode = this._itemGroup.isSearchMode();
if (!this.selection.selectEventsSuppressed) {
@ -593,8 +595,6 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
// If trash or saved search, just re-run search
if (itemGroup.isTrash() || itemGroup.isSearch())
{
Zotero.ItemGroupCache.clear();
// Clear item type icons
var items = Zotero.Items.get(ids);
for (let i=0; i<items.length; i++) {
@ -711,16 +711,15 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
}
else if(action == 'add')
{
// If saved search or trash, just re-run search
if (itemGroup.isSearch() || itemGroup.isTrash()) {
// In some modes, just re-run search
if (itemGroup.isSearch() || itemGroup.isTrash() || itemGroup.isUnfiled()) {
this.refresh();
madeChanges = true;
sort = true;
}
// If not a quicksearch and not background window saved search,
// process new items manually
else if (quicksearch && quicksearch.value == '')
// If not a quicksearch, process new items manually
else if (!quicksearch || quicksearch.value == '')
{
var items = Zotero.Items.get(ids);
for each(var item in items) {
@ -740,7 +739,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
sort = (items.length == 1) ? items[0].id : true;
}
}
// Otherwise re-run the search, which refreshes the item list
// Otherwise re-run the quick search, which refreshes the item list
else
{
// For item adds, clear the quicksearch, unless all the new items
@ -1802,7 +1801,7 @@ Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse)
// Don't change selection if UI updates are disabled (e.g., during sync)
if (Zotero.suppressUIUpdates) {
Zotero.debug("Sync is running; not selecting item");
return;
return false;
}
// If no row map, we're probably in the process of switching collections,

View file

@ -773,7 +773,11 @@ var ZoteroPane = new function()
if (manual) {
// Focus the title field
if (this.selectItem(itemID)) {
setTimeout(function () {
document.getElementById('zotero-editpane-item-box').focusFirstField();
}, 0);
}
// Update most-recently-used list for New Item menu
this.addItemTypeToNewItemTypeMRU(typeID);