Add right-click menu read state choices for feeds

This commit is contained in:
Adomas Venčkauskas 2016-02-10 16:10:55 +00:00 committed by Dan Stillman
parent 9e88969f3d
commit 39aca505e0
5 changed files with 57 additions and 9 deletions

View file

@ -2137,7 +2137,7 @@ Zotero.ItemTreeView.prototype.getSortFields = function () {
*/
Zotero.ItemTreeView.prototype.getSortDirection = function() {
if (this.collectionTreeRow.isFeed) {
return Zotero.Prefs.get('feedSortAsc') ? 'asc' : 'desc';
return Zotero.Prefs.get('feedSortAsc') ? 'ascending' : 'descending';
}
var column = this._treebox.columns.getSortedColumn();
if (!column) {

View file

@ -1912,6 +1912,19 @@ var ZoteroPane = new function()
}
});
this.toggleSelectedItemsRead = function() {
return Zotero.FeedItems.toggleReadByID(this.getSelectedItems(true));
};
this.markFeedRead = Zotero.Promise.coroutine(function* () {
if (!this.collectionsView.selection.count) return;
let feed = this.collectionsView.getRow(this.collectionsView.selection.currentIndex).ref;
let feedItemIDs = yield Zotero.FeedItems.getAll(feed.libraryID, true, false, true);
yield Zotero.FeedItems.toggleReadByID(feedItemIDs, true);
});
this.editSelectedFeed = Zotero.Promise.coroutine(function* () {
if (!this.collectionsView.selection.count) return;
@ -2216,6 +2229,7 @@ var ZoteroPane = new function()
"showDuplicates",
"showUnfiled",
"editSelectedCollection",
"markReadFeed",
"editSelectedFeed",
"deleteCollection",
"deleteCollectionAndItems",
@ -2276,6 +2290,7 @@ var ZoteroPane = new function()
show = [
m.refreshFeed,
m.sep1,
m.markReadFeed,
m.editSelectedFeed,
m.deleteCollectionAndItems,
m.sep2,
@ -2291,6 +2306,10 @@ var ZoteroPane = new function()
}
}
if (collectionTreeRow.ref.unreadCount == 0) {
disable.push(m.markReadFeed);
}
// Adjust labels
menu.childNodes[m.deleteCollectionAndItems].setAttribute('label', Zotero.getString('pane.collections.menu.delete.feedAndItems'));
menu.childNodes[m.exportCollection].setAttribute('label', Zotero.getString('pane.collections.menu.export.feed'));
@ -2394,6 +2413,7 @@ var ZoteroPane = new function()
'addNote',
'addAttachments',
'sep2',
'toggleRead',
'duplicateItem',
'deleteItem',
'restoreToLibrary',
@ -2439,7 +2459,7 @@ var ZoteroPane = new function()
else if (collectionTreeRow.isPublications()) {
show.push(m.deleteFromLibrary);
}
else {
else if (! collectionTreeRow.isFeed()) {
show.push(m.moveToTrash);
}
@ -2452,6 +2472,8 @@ var ZoteroPane = new function()
var items = this.getSelectedItems();
var canMerge = true, canIndex = true, canRecognize = true, canRename = true;
var canMarkRead = collectionTreeRow.isFeed();
var markUnread = true;
if (!Zotero.Fulltext.pdfConverterIsRegistered()) {
canIndex = false;
@ -2459,7 +2481,7 @@ var ZoteroPane = new function()
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (canMerge && !item.isRegularItem() || collectionTreeRow.isDuplicates()) {
if (canMerge && !item.isRegularItem() || item.isFeedItem || collectionTreeRow.isDuplicates()) {
canMerge = false;
}
@ -2475,6 +2497,10 @@ var ZoteroPane = new function()
if (canRename && (!item.isAttachment() || item.isTopLevelItem() || item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL)) {
canRename = false;
}
if(canMarkRead && markUnread && !item.isRead) {
markUnread = false;
}
}
if (canMerge) {
@ -2489,10 +2515,19 @@ var ZoteroPane = new function()
show.push(m.recognizePDF);
}
if (canMarkRead) {
show.push(m.toggleRead);
if (markUnread) {
menu.childNodes[m.toggleRead].setAttribute('label', Zotero.getString('pane.collections.menu.toggleRead.markUnread'));
} else {
menu.childNodes[m.toggleRead].setAttribute('label', Zotero.getString('pane.collections.menu.toggleRead.markRead'));
}
}
var canCreateParent = true;
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (!item.isTopLevelItem() || !item.isAttachment()) {
if (!item.isTopLevelItem() || !item.isAttachment() || item.isFeedItem) {
canCreateParent = false;
break;
}
@ -2540,7 +2575,7 @@ var ZoteroPane = new function()
show.push(m.showInLibrary, m.sep1);
}
if (item.isRegularItem()) {
if (item.isRegularItem() && !item.isFeedItem) {
show.push(m.addNote, m.addAttachments, m.sep2);
}
@ -2575,6 +2610,14 @@ var ZoteroPane = new function()
show.push(m.sep4);
}
}
else if (item.isFeedItem) {
show.push(m.toggleRead);
if (item.isRead) {
menu.childNodes[m.toggleRead].setAttribute('label', Zotero.getString('pane.collections.menu.toggleRead.markUnread'));
} else {
menu.childNodes[m.toggleRead].setAttribute('label', Zotero.getString('pane.collections.menu.toggleRead.markRead'));
}
}
else {
show.push(m.duplicateItem);
}

View file

@ -247,6 +247,7 @@
<menuitem class="menuitem-iconic zotero-menuitem-show-duplicates" label="&zotero.toolbar.duplicate.label;" oncommand="ZoteroPane_Local.setVirtual(ZoteroPane_Local.getSelectedLibraryID(), 'duplicates', true)"/>
<menuitem class="menuitem-iconic zotero-menuitem-show-unfiled" label="&zotero.collections.showUnfiledItems;" oncommand="ZoteroPane_Local.setVirtual(ZoteroPane_Local.getSelectedLibraryID(), 'unfiled', true)"/>
<menuitem class="menuitem-iconic zotero-menuitem-edit-collection" oncommand="ZoteroPane_Local.editSelectedCollection();"/>
<menuitem class="menuitem-iconic zotero-menuitem-mark-read-feed" label="&zotero.toolbar.markFeedRead.label;" oncommand="ZoteroPane_Local.markFeedRead();"/>
<menuitem class="menuitem-iconic zotero-menuitem-edit-feed" label="&zotero.toolbar.editFeed.label;" oncommand="ZoteroPane_Local.editSelectedFeed();"/>
<menuitem class="menuitem-iconic zotero-menuitem-delete-collection" oncommand="ZoteroPane_Local.deleteSelectedCollection();"/>
<menuitem class="menuitem-iconic zotero-menuitem-move-to-trash" oncommand="ZoteroPane_Local.deleteSelectedCollection(true);"/>
@ -275,6 +276,7 @@
</menupopup>
</menu>
<menuseparator/>
<menuitem class="menuitem-iconic zotero-menuitem-toggle-read-item" oncommand="ZoteroPane_Local.toggleSelectedItemsRead();"/>
<menuitem class="menuitem-iconic zotero-menuitem-duplicate-item" label="&zotero.items.menu.duplicateItem;" oncommand="ZoteroPane_Local.duplicateSelectedItem().done();"/>
<menuitem class="menuitem-iconic zotero-menuitem-delete-collection" oncommand="ZoteroPane_Local.deleteSelectedItems();"/>
<menuitem class="menuitem-iconic zotero-menuitem-restore-to-library" label="&zotero.items.menu.restoreToLibrary;" oncommand="ZoteroPane_Local.restoreSelectedItems();"/>

View file

@ -107,6 +107,7 @@
<!ENTITY zotero.toolbar.newFeed.label "New Feed…">
<!ENTITY zotero.toolbar.refreshFeed.label "Refresh Feed">
<!ENTITY zotero.toolbar.editFeed.label "Edit Feed…">
<!ENTITY zotero.toolbar.markFeedRead.label "Mark Feed Read">
<!ENTITY zotero.toolbar.newGroup "New Group…">
<!ENTITY zotero.toolbar.newSubcollection.label "New Subcollection…">
<!ENTITY zotero.toolbar.newSavedSearch.label "New Saved Search…">

View file

@ -201,6 +201,8 @@ pane.collections.menu.generateReport.savedSearch = Generate Report from Saved Se
pane.collections.menu.generateReport.feed = Generate Report from Feed…
pane.collections.menu.refresh.feed = Refresh Feed
pane.collections.menu.toggleRead.markRead = Mark Read
pane.collections.menu.toggleRead.markUnread = Mark Unread
pane.tagSelector.rename.title = Rename Tag
pane.tagSelector.rename.message = Please enter a new name for this tag.\n\nThe tag will be changed in all associated items.