Add .regularOnly and .expandAll flags to ItemTreeView
This commit is contained in:
parent
6c1ba0aeee
commit
b0140686f3
|
@ -89,7 +89,8 @@ var onCollectionSelected = Zotero.Promise.coroutine(function* ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create items list and wait for it to load
|
// Create items list and wait for it to load
|
||||||
itemsView = new Zotero.ItemTreeView(collectionTreeRow, (window.arguments[1] ? true : false));
|
itemsView = new Zotero.ItemTreeView(collectionTreeRow);
|
||||||
|
itemsView.sourcesOnly = !!window.arguments[1];
|
||||||
document.getElementById('zotero-items-tree').view = itemsView;
|
document.getElementById('zotero-items-tree').view = itemsView;
|
||||||
yield itemsView.waitForLoad();
|
yield itemsView.waitForLoad();
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
/*
|
/*
|
||||||
* Constructor for the ItemTreeView object
|
* Constructor for the ItemTreeView object
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView = function (collectionTreeRow, sourcesOnly) {
|
Zotero.ItemTreeView = function (collectionTreeRow) {
|
||||||
Zotero.LibraryTreeView.apply(this);
|
Zotero.LibraryTreeView.apply(this);
|
||||||
|
|
||||||
this.wrappedJSObject = this;
|
this.wrappedJSObject = this;
|
||||||
|
@ -44,8 +44,6 @@ Zotero.ItemTreeView = function (collectionTreeRow, sourcesOnly) {
|
||||||
|
|
||||||
this._skipKeypress = false;
|
this._skipKeypress = false;
|
||||||
|
|
||||||
this._sourcesOnly = sourcesOnly;
|
|
||||||
|
|
||||||
this._ownerDocument = null;
|
this._ownerDocument = null;
|
||||||
this._needsSort = false;
|
this._needsSort = false;
|
||||||
|
|
||||||
|
@ -64,6 +62,8 @@ Zotero.ItemTreeView = function (collectionTreeRow, sourcesOnly) {
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype = Object.create(Zotero.LibraryTreeView.prototype);
|
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.expandAll = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,6 +119,19 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expand all parent items for some views (e.g., My Publications). We do this here instead of
|
||||||
|
// refresh so that it doesn't get reverted after item changes.
|
||||||
|
if (this.expandAll) {
|
||||||
|
var t = new Date();
|
||||||
|
for (let i = 0; i < this._rows.length; i++) {
|
||||||
|
if (this.isContainer(i) && !this.isContainerOpen(i)) {
|
||||||
|
this.toggleOpenState(i, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Zotero.debug(`Opened all parent items in ${new Date() - t} ms`);
|
||||||
|
}
|
||||||
|
this._refreshItemRowMap();
|
||||||
|
|
||||||
// Add a keypress listener for expand/collapse
|
// Add a keypress listener for expand/collapse
|
||||||
var tree = this._treebox.treeBody.parentNode;
|
var tree = this._treebox.treeBody.parentNode;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -371,8 +384,8 @@ Zotero.ItemTreeView.prototype.refresh = Zotero.serial(Zotero.Promise.coroutine(f
|
||||||
for (let i=0, len=newItems.length; i < len; i++) {
|
for (let i=0, len=newItems.length; i < len; i++) {
|
||||||
let item = newItems[i];
|
let item = newItems[i];
|
||||||
|
|
||||||
// Only add regular items if sourcesOnly is set
|
// Only add regular items if regularOnly is set
|
||||||
if (this._sourcesOnly && !item.isRegularItem()) {
|
if (this.regularOnly && !item.isRegularItem()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,7 +1187,7 @@ Zotero.ItemTreeView.prototype.isContainer = function(row)
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype.isContainerEmpty = function(row)
|
Zotero.ItemTreeView.prototype.isContainerEmpty = function(row)
|
||||||
{
|
{
|
||||||
if (this._sourcesOnly) {
|
if (this.regularOnly) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user