Fix saved searches and trash not display on collapse/expand of My Library

This commit is contained in:
Dan Stillman 2009-05-17 08:29:46 +00:00
parent 7ab0a62e38
commit fa348d346c

View file

@ -150,34 +150,48 @@ Zotero.CollectionTreeView.prototype.refresh = function()
var oldCount = this.rowCount; var oldCount = this.rowCount;
this._dataItems = []; this._dataItems = [];
this.rowCount = 0; this.rowCount = 0;
this._showItem(new Zotero.ItemGroup('library', { id: null, libraryID: null }), 0, 1, 1); // itemgroup ref, level, beforeRow, startOpen
var collections = Zotero.getCollections(); var self = this;
for (var i=0; i<collections.length; i++) { var library = {
// Skip group collections id: null,
if (collections[i].libraryID) { libraryID: null,
continue; expand: function () {
var newRows = 0;
var collections = Zotero.getCollections();
for (var i=0; i<collections.length; i++) {
// Skip group collections
if (collections[i].libraryID) {
continue;
}
self._showItem(new Zotero.ItemGroup('collection', collections[i]), 1, newRows+1);
newRows++;
}
var savedSearches = Zotero.Searches.getAll();
if (savedSearches) {
for (var i=0; i<savedSearches.length; i++) {
self._showItem(new Zotero.ItemGroup('search', savedSearches[i]), 1, newRows+1);
newRows++;
}
}
var deletedItems = Zotero.Items.getDeleted();
if (deletedItems || Zotero.Prefs.get("showTrashWhenEmpty")) {
self._showItem(new Zotero.ItemGroup('trash', false), 1, newRows+1);
newRows++;
}
self.trashNotEmpty = !!deletedItems;
return newRows;
} }
this._showItem(new Zotero.ItemGroup('collection', collections[i]), 1); };
} this._showItem(new Zotero.ItemGroup('library', library), 0, 1, 1); // itemgroup ref, level, beforeRow, startOpen
library.expand();
var savedSearches = Zotero.Searches.getAll();
if (savedSearches) {
for (var i=0; i<savedSearches.length; i++) {
this._showItem(new Zotero.ItemGroup('search', savedSearches[i]), 1);
}
}
var deletedItems = Zotero.Items.getDeleted();
if (deletedItems || Zotero.Prefs.get("showTrashWhenEmpty")) {
this._showItem(new Zotero.ItemGroup('trash', false), 1);
}
this.trashNotEmpty = !!deletedItems;
var groups = Zotero.Groups.getAll(); var groups = Zotero.Groups.getAll();
if (groups.length) { if (groups.length) {
this._showItem(new Zotero.ItemGroup('separator', false)); this._showItem(new Zotero.ItemGroup('separator', false));
var self = this;
var header = { var header = {
id: "group-libraries-header", id: "group-libraries-header",
label: "Group Libraries", // TODO: localize label: "Group Libraries", // TODO: localize
@ -543,15 +557,20 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
itemGroup.ref.expand(); itemGroup.ref.expand();
} }
else { else {
if (itemGroup.isGroup()) { if (itemGroup.isLibrary()) {
var collections = itemGroup.ref.getCollections(); // Get child collections count = itemGroup.ref.expand();
} }
else { else {
var collections = Zotero.getCollections(itemGroup.ref.id); // Get child collections if (itemGroup.isGroup()) {
} var collections = itemGroup.ref.getCollections(); // Get child collections
for (var i=0; i<collections.length; i++) { }
count++; else {
this._showItem(new Zotero.ItemGroup('collection', collections[i]), thisLevel+1, row+i+1); //insert new row var collections = Zotero.getCollections(itemGroup.ref.id); // Get child collections
}
for (var i=0; i<collections.length; i++) {
this._showItem(new Zotero.ItemGroup('collection', collections[i]), thisLevel+1, row+i+1); //insert new row
count++;
}
} }
} }
} }