Add ability to hide My Publications (#5367)

This commit is contained in:
Tom Najdek 2025-07-15 06:31:22 +02:00 • committed by GitHub
parent 387d5966c3
commit a85e1fb40a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 32 additions and 9 deletions

View file

@ -515,6 +515,7 @@ var CollectionTree = class CollectionTree extends LibraryTree {
Zotero.Prefs.getVirtualCollectionState('unfiled');
this._virtualCollectionLibraries.retracted =
Zotero.Prefs.getVirtualCollectionState('retracted');
this._virtualCollectionLibraries.publications = Zotero.Prefs.getVirtualCollectionState('publications');
var newRows = [];
var added = 0;
@ -1263,7 +1264,8 @@ var CollectionTree = class CollectionTree extends LibraryTree {
const types = {
duplicates: 'D',
unfiled: 'U',
retracted: 'R'
retracted: 'R',
publications: 'P'
};
if (!(type in types)) {
throw new Error("Invalid virtual collection type '" + type + "'");
@ -2981,6 +2983,7 @@ var CollectionTree = class CollectionTree extends LibraryTree {
&& this._virtualCollectionLibraries.retracted?.[libraryID] !== false
&& Zotero.Retractions.libraryHasRetractedItems(libraryID);
var showPublications = this.props.hideSources.indexOf('publications') == -1
&& this._virtualCollectionLibraries.publications?.[libraryID] !== false
&& libraryID == Zotero.Libraries.userLibraryID;
var showTrash = this.props.hideSources.indexOf('trash') == -1;
}

View file

@ -460,7 +460,8 @@ Zotero.Prefs = new function() {
const prefKeys = {
duplicates: 'duplicateLibraries',
unfiled: 'unfiledLibraries',
retracted: 'retractedLibraries'
retracted: 'retractedLibraries',
publications: 'publications',
};
let prefKey = prefKeys[type];
if (!prefKey) {
@ -493,7 +494,8 @@ Zotero.Prefs = new function() {
const prefKeys = {
duplicates: 'duplicateLibraries',
unfiled: 'unfiledLibraries',
retracted: 'retractedLibraries'
retracted: 'retractedLibraries',
publications: 'publications'
};
let prefKey = prefKeys[type];
if (!prefKey) {

View file

@ -2326,8 +2326,7 @@ var ZoteroPane = new function()
var collectionTreeRow = this.getCollectionTreeRow();
// Don't allow deleting libraries or My Publications
if (collectionTreeRow.isLibrary(true) && !collectionTreeRow.isFeed()
|| collectionTreeRow.isPublications()) {
if (collectionTreeRow.isLibrary(true) && !collectionTreeRow.isFeed()) {
return;
}
@ -2346,6 +2345,11 @@ var ZoteroPane = new function()
this.setVirtual(collectionTreeRow.ref.libraryID, 'retracted', false);
return;
}
// Hide "My Publications"
else if (collectionTreeRow.isPublications()) {
this.setVirtual(collectionTreeRow.ref.libraryID, 'publications', false);
return;
}
if (!this.canEdit() && !collectionTreeRow.isFeedsOrFeed()) {
this.displayCannotEditLibraryMessage();
@ -3249,6 +3253,12 @@ var ZoteroPane = new function()
this.setVirtual(this.getSelectedLibraryID(), 'retracted', true, true);
}
},
{
id: "showPublications",
oncommand: () => {
this.setVirtual(this.getSelectedLibraryID(), 'publications', true, true);
}
},
{
id: "editSelectedCollection",
oncommand: () => this.editSelectedCollection()
@ -3477,9 +3487,9 @@ var ZoteroPane = new function()
else if (collectionTreeRow.isHeader()) {
}
else if (collectionTreeRow.isPublications()) {
show = [
'exportFile'
];
show = ['exportFile', 'deleteCollection'];
m.deleteCollection.setAttribute('label', Zotero.getString('general.hide'));
useHideOrDelete = "hide";
}
// Library
else {
@ -3503,7 +3513,10 @@ var ZoteroPane = new function()
let retracted = Zotero.Prefs.getVirtualCollectionStateForLibrary(
libraryID, 'retracted'
);
if (!duplicates || !unfiled || !retracted) {
let publications = Zotero.Prefs.getVirtualCollectionStateForLibrary(
libraryID, 'publications'
);
if (!duplicates || !unfiled || !retracted || !publications) {
if (!library.archived) {
show.push('sep2');
}
@ -3516,6 +3529,9 @@ var ZoteroPane = new function()
if (!retracted) {
show.push('showRetracted');
}
if (!publications) {
show.push('showPublications');
}
}
if (!library.archived) {
show.push('sep3');

View file

@ -915,6 +915,7 @@
<menuitem class="zotero-menuitem-show-duplicates" label="&zotero.toolbar.duplicate.label;"/>
<menuitem class="zotero-menuitem-show-unfiled" label="&zotero.collections.showUnfiledItems;"/>
<menuitem class="zotero-menuitem-show-retracted" label="&zotero.collections.showRetractedItems;"/>
<menuitem class="zotero-menuitem-show-publications" label="&zotero.collections.showPublications;" />
<menuitem class="zotero-menuitem-edit-collection"/>
<menu class="menu-iconic zotero-menuitem-move-collection">
<menupopup id="zotero-move-collection-popup" onpopupshowing="ZoteroPane_Local.buildMoveCollectionMenu(event)">

View file

@ -53,6 +53,7 @@
<!ENTITY zotero.toolbar.duplicate.label "Show Duplicates">
<!ENTITY zotero.collections.showUnfiledItems "Show Unfiled Items">
<!ENTITY zotero.collections.showRetractedItems "Show Retracted Items">
<!ENTITY zotero.collections.showPublications "Show My Publications">
<!ENTITY zotero.items.itemType "Item Type">
<!ENTITY zotero.items.creator_column "Creator">