Show "Export Collection…" if there are items in subcollections
And generate collection context menu asynchronously Closes #1482
This commit is contained in:
parent
460a423df3
commit
0e3071576b
|
@ -2380,6 +2380,37 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show context menu once it's ready
|
||||||
|
*/
|
||||||
|
this.onCollectionsContextMenuOpen = async function (event) {
|
||||||
|
await ZoteroPane.buildCollectionContextMenu();
|
||||||
|
document.getElementById('zotero-collectionmenu').openPopup(
|
||||||
|
null, null, event.clientX + 1, event.clientY + 1, true, false, event
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show context menu once it's ready
|
||||||
|
*/
|
||||||
|
this.onItemsContextMenuOpen = async function (event) {
|
||||||
|
await ZoteroPane.buildItemContextMenu()
|
||||||
|
document.getElementById('zotero-itemmenu').openPopup(
|
||||||
|
null, null, event.clientX + 1, event.clientY + 1, true, false, event
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.onCollectionContextMenuSelect = function (event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
var o = _collectionContextMenuOptions.find(o => o.id == event.target.id)
|
||||||
|
if (o.oncommand) {
|
||||||
|
o.oncommand();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// menuitem configuration
|
// menuitem configuration
|
||||||
//
|
//
|
||||||
// This has to be kept in sync with zotero-collectionmenu in zoteroPane.xul. We could do this
|
// This has to be kept in sync with zotero-collectionmenu in zoteroPane.xul. We could do this
|
||||||
|
@ -2498,7 +2529,7 @@ var ZoteroPane = new function()
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
this.buildCollectionContextMenu = function (noRepeat) {
|
this.buildCollectionContextMenu = async function () {
|
||||||
var libraryID = this.getSelectedLibraryID();
|
var libraryID = this.getSelectedLibraryID();
|
||||||
var options = _collectionContextMenuOptions;
|
var options = _collectionContextMenuOptions;
|
||||||
|
|
||||||
|
@ -2508,12 +2539,16 @@ var ZoteroPane = new function()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the items view isn't initialized, this was a right-click on a different collection and
|
// If the items view isn't initialized, this was a right-click on a different collection
|
||||||
// the new collection's items are still loading, so update the menu after loading. This causes
|
// and the new collection's items are still loading, so continue menu after loading is
|
||||||
// some menu items (e.g., export/createBib/loadReport) to appear gray in the menu at first and
|
// done. This causes some menu items (e.g., export/createBib/loadReport) to appear gray
|
||||||
// then turn black once there are items. Pass a flag to prevent an accidental infinite loop.
|
// in the menu at first and then turn black once there are items
|
||||||
if (!collectionTreeRow.isHeader() && !this.itemsView.initialized && !noRepeat) {
|
if (!collectionTreeRow.isHeader() && !this.itemsView.initialized) {
|
||||||
this.itemsView.onLoad.addListener(() => this.buildCollectionContextMenu(true));
|
await new Promise((resolve) => {
|
||||||
|
this.itemsView.onLoad.addListener(() => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set attributes on the menu from the configuration object
|
// Set attributes on the menu from the configuration object
|
||||||
|
@ -2554,7 +2589,12 @@ var ZoteroPane = new function()
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!this.itemsView.rowCount) {
|
if (!this.itemsView.rowCount) {
|
||||||
disable = ['exportCollection', 'createBibCollection', 'loadReport'];
|
disable = ['createBibCollection', 'loadReport'];
|
||||||
|
|
||||||
|
// If no items in subcollections either, disable export
|
||||||
|
if (!(await collectionTreeRow.ref.getDescendents(false, 'item', false).length)) {
|
||||||
|
disable.push('exportCollection');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust labels
|
// Adjust labels
|
||||||
|
@ -2693,25 +2733,6 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onCollectionContextMenuSelect = function (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
var o = _collectionContextMenuOptions.find(o => o.id == event.target.id)
|
|
||||||
if (o.oncommand) {
|
|
||||||
o.oncommand();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show context menu once it's ready
|
|
||||||
*/
|
|
||||||
this.onItemsContextMenuOpen = function (event) {
|
|
||||||
ZoteroPane.buildItemContextMenu()
|
|
||||||
.then(function () {
|
|
||||||
document.getElementById('zotero-itemmenu').openPopup(
|
|
||||||
null, null, event.clientX + 1, event.clientY + 1, true, false, event
|
|
||||||
);
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
this.buildItemContextMenu = Zotero.Promise.coroutine(function* () {
|
this.buildItemContextMenu = Zotero.Promise.coroutine(function* () {
|
||||||
var options = [
|
var options = [
|
||||||
|
|
|
@ -273,7 +273,6 @@
|
||||||
|
|
||||||
<popupset>
|
<popupset>
|
||||||
<menupopup id="zotero-collectionmenu"
|
<menupopup id="zotero-collectionmenu"
|
||||||
onpopupshowing="ZoteroPane_Local.buildCollectionContextMenu();"
|
|
||||||
oncommand="ZoteroPane.onCollectionContextMenuSelect(event)">
|
oncommand="ZoteroPane.onCollectionContextMenuSelect(event)">
|
||||||
<!-- Keep order in sync with buildCollectionContextMenu, which adds additional attributes -->
|
<!-- Keep order in sync with buildCollectionContextMenu, which adds additional attributes -->
|
||||||
<menuitem class="zotero-menuitem-sync"/>
|
<menuitem class="zotero-menuitem-sync"/>
|
||||||
|
@ -344,10 +343,12 @@
|
||||||
<box id="zotero-collections-tree-shim"/>
|
<box id="zotero-collections-tree-shim"/>
|
||||||
<!-- This extra vbox prevents the toolbar from getting compressed when resizing
|
<!-- This extra vbox prevents the toolbar from getting compressed when resizing
|
||||||
the tag selector to max height -->
|
the tag selector to max height -->
|
||||||
<tree id="zotero-collections-tree" hidecolumnpicker="true" context="zotero-collectionmenu"
|
<tree id="zotero-collections-tree"
|
||||||
onmouseover="ZoteroPane_Local.collectionsView.setHighlightedRows();"
|
hidecolumnpicker="true"
|
||||||
onselect="ZoteroPane_Local.onCollectionSelected();"
|
oncontextmenu="ZoteroPane.onCollectionsContextMenuOpen(event)"
|
||||||
seltype="cell" flex="1" editable="true">
|
onmouseover="ZoteroPane_Local.collectionsView.setHighlightedRows();"
|
||||||
|
onselect="ZoteroPane_Local.onCollectionSelected();"
|
||||||
|
seltype="cell" flex="1" editable="true">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
id="zotero-collections-name-column"
|
id="zotero-collections-name-column"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user