Collapse My Publications when first opened
Child items marked as visible are technically search matches, so we have to take extra steps to keep the parents from being auto-expanded.
This commit is contained in:
parent
850a9bb309
commit
d472752101
|
@ -64,6 +64,7 @@ Zotero.ItemTreeView.prototype = Object.create(Zotero.LibraryTreeView.prototype);
|
||||||
Zotero.ItemTreeView.prototype.type = 'item';
|
Zotero.ItemTreeView.prototype.type = 'item';
|
||||||
Zotero.ItemTreeView.prototype.regularOnly = false;
|
Zotero.ItemTreeView.prototype.regularOnly = false;
|
||||||
Zotero.ItemTreeView.prototype.expandAll = false;
|
Zotero.ItemTreeView.prototype.expandAll = false;
|
||||||
|
Zotero.ItemTreeView.prototype.collapseAll = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,13 +115,13 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield this.refresh();
|
yield this.refresh(true);
|
||||||
if (!this._treebox.treeBody) {
|
if (!this._treebox.treeBody) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand all parent items for some views (e.g., My Publications). We do this here instead of
|
// Expand all parent items in the view, regardless of search matches. We do this here instead
|
||||||
// refresh so that it doesn't get reverted after item changes.
|
// of refresh so that it doesn't get reverted after item changes.
|
||||||
if (this.expandAll) {
|
if (this.expandAll) {
|
||||||
var t = new Date();
|
var t = new Date();
|
||||||
for (let i = 0; i < this._rows.length; i++) {
|
for (let i = 0; i < this._rows.length; i++) {
|
||||||
|
@ -245,7 +246,9 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree
|
||||||
tree._handleEnter = function () {};
|
tree._handleEnter = function () {};
|
||||||
|
|
||||||
this.sort();
|
this.sort();
|
||||||
|
if (!this.collapseAll) {
|
||||||
this.expandMatchParents();
|
this.expandMatchParents();
|
||||||
|
}
|
||||||
|
|
||||||
if (this._ownerDocument.defaultView.ZoteroPane_Local) {
|
if (this._ownerDocument.defaultView.ZoteroPane_Local) {
|
||||||
// For My Publications, show intro text in middle pane if no items
|
// For My Publications, show intro text in middle pane if no items
|
||||||
|
@ -343,7 +346,7 @@ Zotero.ItemTreeView.prototype.setSortColumn = function() {
|
||||||
* Reload the rows from the data access methods
|
* Reload the rows from the data access methods
|
||||||
* (doesn't call the tree.invalidate methods, etc.)
|
* (doesn't call the tree.invalidate methods, etc.)
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView.prototype.refresh = Zotero.serial(Zotero.Promise.coroutine(function* () {
|
Zotero.ItemTreeView.prototype.refresh = Zotero.serial(Zotero.Promise.coroutine(function* (skipExpandMatchParents) {
|
||||||
Zotero.debug('Refreshing items list for ' + this.id);
|
Zotero.debug('Refreshing items list for ' + this.id);
|
||||||
|
|
||||||
// DEBUG: necessary?
|
// DEBUG: necessary?
|
||||||
|
@ -433,7 +436,9 @@ Zotero.ItemTreeView.prototype.refresh = Zotero.serial(Zotero.Promise.coroutine(f
|
||||||
|
|
||||||
this.rememberOpenState(savedOpenState);
|
this.rememberOpenState(savedOpenState);
|
||||||
this.rememberSelection(savedSelection);
|
this.rememberSelection(savedSelection);
|
||||||
|
if (!skipExpandMatchParents) {
|
||||||
this.expandMatchParents();
|
this.expandMatchParents();
|
||||||
|
}
|
||||||
if (unsuppress) {
|
if (unsuppress) {
|
||||||
this._treebox.endUpdateBatch();
|
this._treebox.endUpdateBatch();
|
||||||
this.selection.selectEventsSuppressed = false;
|
this.selection.selectEventsSuppressed = false;
|
||||||
|
@ -670,7 +675,8 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
|
||||||
if (collectionTreeRow.isSearch()
|
if (collectionTreeRow.isSearch()
|
||||||
|| collectionTreeRow.isPublications()
|
|| collectionTreeRow.isPublications()
|
||||||
|| collectionTreeRow.isTrash()) {
|
|| collectionTreeRow.isTrash()) {
|
||||||
yield this.refresh();
|
let skipExpandMatchParents = collectionTreeRow.isPublications();
|
||||||
|
yield this.refresh(skipExpandMatchParents);
|
||||||
refreshed = true;
|
refreshed = true;
|
||||||
madeChanges = true;
|
madeChanges = true;
|
||||||
sort = true;
|
sort = true;
|
||||||
|
|
|
@ -1238,7 +1238,7 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
this.itemsView = new Zotero.ItemTreeView(collectionTreeRow);
|
this.itemsView = new Zotero.ItemTreeView(collectionTreeRow);
|
||||||
if (collectionTreeRow.isPublications()) {
|
if (collectionTreeRow.isPublications()) {
|
||||||
this.itemsView.expandAll = true;
|
this.itemsView.collapseAll = true;
|
||||||
}
|
}
|
||||||
this.itemsView.onError = function () {
|
this.itemsView.onError = function () {
|
||||||
// Don't reload last folder, in case that's the problem
|
// Don't reload last folder, in case that's the problem
|
||||||
|
|
Loading…
Reference in New Issue
Block a user