www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f2bef5998cb0feaebddaad3a384f488f4227fb92
parent bd1092e519c18ad437c6330ebb749562d77bcd56
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  3 Nov 2015 17:01:07 -0500

Disable actions in My Publications and clean up trash item menu

Disallow everything other than adding a child note in My Publications,
since the wizard only shows on drag (currently, at least). Need to
disable translation separately.

Also show "Delete Item[s]..." in the trash context menu, and hide rather
than disable various menu options.

Addresses #703 -- still need to disable saved search saving

Diffstat:
Mchrome/content/zotero/itemPane.xul | 8+++++---
Mchrome/content/zotero/zoteroPane.js | 144+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mchrome/content/zotero/zoteroPane.xul | 3++-
Mchrome/locale/en-US/zotero/zotero.properties | 2++
4 files changed, 91 insertions(+), 66 deletions(-)

diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul @@ -33,10 +33,12 @@ <vbox id="zotero-item-pane" zotero-persist="width"> <!-- Trash --> - <vbox id="zotero-item-restore-button-holder"> + <hbox id="zotero-item-top-buttons-holder" hidden="true"> <button id="zotero-item-restore-button" label="&zotero.items.menu.restoreToLibrary;" - oncommand="ZoteroPane_Local.restoreSelectedItems()" hidden="true"/> - </vbox> + oncommand="ZoteroPane_Local.restoreSelectedItems()"/> + <button id="zotero-item-delete-button" label="&zotero.item.deletePermanently;" + oncommand="ZoteroPane_Local.deleteSelectedItems()"/> + </hbox> <!-- Commons --> <button id="zotero-item-show-original" label="Show Original" diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -1169,19 +1169,25 @@ var ZoteroPane = new function() "zotero-tb-attachment-add" ]; for(var i=0; i<disableIfNoEdit.length; i++) { - var el = document.getElementById(disableIfNoEdit[i]); + let command = disableIfNoEdit[i]; + var el = document.getElementById(command); // If a trash is selected, new collection depends on the // editability of the library if (collectionTreeRow.isTrash() && - disableIfNoEdit[i] == 'cmd_zotero_newCollection') { + command == 'cmd_zotero_newCollection') { var overrideEditable = Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID); } else { var overrideEditable = false; } - if (collectionTreeRow.editable || overrideEditable) { + // Don't allow normal buttons in My Pubications, because things need to + // be dragged and go through the wizard + let forceDisable = collectionTreeRow.isPublications() + && command != 'zotero-tb-note-add'; + + if ((collectionTreeRow.editable || overrideEditable) && !forceDisable) { if(el.hasAttribute("disabled")) el.removeAttribute("disabled"); } else { el.setAttribute("disabled", "true"); @@ -2344,8 +2350,9 @@ var ZoteroPane = new function() 'sep2', 'duplicateItem', 'deleteItem', - 'deleteFromLibrary', 'restoreToLibrary', + 'moveToTrash', + 'deleteFromLibrary', 'mergeItems', 'sep3', 'exportItems', @@ -2377,12 +2384,18 @@ var ZoteroPane = new function() } var collectionTreeRow = this.getCollectionTreeRow(); + var isTrash = collectionTreeRow.isTrash(); - if(collectionTreeRow.isTrash()) { + if (isTrash) { + show.push(m.deleteFromLibrary); show.push(m.restoreToLibrary); - } else { + } + else if (collectionTreeRow.isPublications()) { show.push(m.deleteFromLibrary); } + else { + show.push(m.moveToTrash); + } show.push(m.sep3, m.exportItems, m.createBib, m.loadReport); @@ -2463,7 +2476,7 @@ var ZoteroPane = new function() } } if (hasImportedAttachment) { - disable.push(m.deleteFromLibrary, m.createParent, m.renameAttachments); + disable.push(m.moveToTrash, m.createParent, m.renameAttachments); } } } @@ -2475,54 +2488,51 @@ var ZoteroPane = new function() menu.setAttribute('itemID', item.id); menu.setAttribute('itemKey', item.key); - // Show in Library - if (!collectionTreeRow.isLibrary() && !collectionTreeRow.isWithinGroup()) { - show.push(m.showInLibrary, m.sep1); - } - - // Disable actions in the trash - if (collectionTreeRow.isTrash()) { - disable.push(m.deleteItem); - } - - if (item.isRegularItem()) { - show.push(m.addNote, m.addAttachments, m.sep2); - } - - if (item.isAttachment()) { - var showSep4 = false; - - if (Zotero_RecognizePDF.canRecognize(item)) { - show.push(m.recognizePDF); - showSep4 = true; - } - - // Allow parent item creation for standalone attachments - if (item.isTopLevelItem()) { - show.push(m.createParent); - showSep4 = true; + if (!isTrash) { + // Show in Library + if (!collectionTreeRow.isLibrary(true)) { + show.push(m.showInLibrary, m.sep1); } - // Attachment rename option - if (!item.isTopLevelItem() && item.attachmentLinkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) { - show.push(m.renameAttachments); - showSep4 = true; + if (item.isRegularItem()) { + show.push(m.addNote, m.addAttachments, m.sep2); } - // If not linked URL, show reindex line - if (Zotero.Fulltext.pdfConverterIsRegistered() - && (yield Zotero.Fulltext.canReindex(item))) { - show.push(m.reindexItem); - showSep4 = true; + if (item.isAttachment()) { + var showSep4 = false; + + if (Zotero_RecognizePDF.canRecognize(item)) { + show.push(m.recognizePDF); + showSep4 = true; + } + + // Allow parent item creation for standalone attachments + if (item.isTopLevelItem()) { + show.push(m.createParent); + showSep4 = true; + } + + // Attachment rename option + if (!item.isTopLevelItem() && item.attachmentLinkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) { + show.push(m.renameAttachments); + showSep4 = true; + } + + // If not linked URL, show reindex line + if (Zotero.Fulltext.pdfConverterIsRegistered() + && (yield Zotero.Fulltext.canReindex(item))) { + show.push(m.reindexItem); + showSep4 = true; + } + + if (showSep4) { + show.push(m.sep4); + } } - - if (showSep4) { - show.push(m.sep4); + else { + show.push(m.duplicateItem); } } - else { - show.push(m.duplicateItem); - } // Update attachment submenu var popup = document.getElementById('zotero-add-attachment-popup') @@ -2530,7 +2540,7 @@ var ZoteroPane = new function() // Block certain actions on files if no access if (item.isImportedAttachment() && !collectionTreeRow.filesEditable) { - [m.deleteFromLibrary, m.createParent, m.renameAttachments].forEach(function (x) { + [m.moveToTrash, m.createParent, m.renameAttachments].forEach(function (x) { disable.push(x); }); } @@ -2545,21 +2555,30 @@ var ZoteroPane = new function() } disable.push(m.showInLibrary, m.duplicateItem, m.deleteItem, - m.deleteFromLibrary, m.exportItems, m.createBib, m.loadReport); + m.moveToTrash, m.deleteFromLibrary, m.exportItems, m.createBib, m.loadReport); } - // TODO: implement menu for remote items - if (!collectionTreeRow.editable) { - for (var i in m) { + if (!collectionTreeRow.editable || collectionTreeRow.isPublications()) { + for (let i in m) { // Still show export/bib/report for non-editable views - // (other than Commons buckets, which aren't real items) - if (!collectionTreeRow.isBucket()) { + switch (i) { + case 'exportItems': + case 'createBib': + case 'loadReport': + continue; + } + if (isTrash) { switch (i) { - case 'exportItems': - case 'createBib': - case 'loadReport': - case 'restoreToLibrary': - continue; + case 'restoreToLibrary': + case 'deleteFromLibrary': + continue; + } + } + else if (collectionTreeRow.isPublications()) { + switch (i) { + case 'addNote': + case 'deleteFromLibrary': + continue; } } disable.push(m[i]); @@ -2573,8 +2592,9 @@ var ZoteroPane = new function() show.push(m.deleteItem); } - // Plural if necessary - menu.childNodes[m.deleteFromLibrary].setAttribute('label', Zotero.getString('pane.items.menu.moveToTrash' + multiple)); + // Set labels, plural if necessary + menu.childNodes[m.moveToTrash].setAttribute('label', Zotero.getString('pane.items.menu.moveToTrash' + multiple)); + menu.childNodes[m.deleteFromLibrary].setAttribute('label', Zotero.getString('pane.items.menu.delete' + multiple)); menu.childNodes[m.exportItems].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple)); menu.childNodes[m.createBib].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple)); menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple)); diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul @@ -276,8 +276,9 @@ <menuseparator/> <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-move-to-trash" oncommand="ZoteroPane_Local.deleteSelectedItems(true, true);"/> <menuitem class="menuitem-iconic zotero-menuitem-restore-to-library" label="&zotero.items.menu.restoreToLibrary;" oncommand="ZoteroPane_Local.restoreSelectedItems();"/> + <menuitem class="menuitem-iconic zotero-menuitem-move-to-trash" oncommand="ZoteroPane_Local.deleteSelectedItems(true, true);"/> + <menuitem class="menuitem-iconic zotero-menuitem-delete-from-lib" oncommand="ZoteroPane_Local.deleteSelectedItems(false, true)"/> <menuitem class="menuitem-iconic zotero-menuitem-merge-items" label="&zotero.items.menu.mergeItems;" oncommand="ZoteroPane_Local.mergeSelectedItems();"/> <menuseparator/> <menuitem class="menuitem-iconic zotero-menuitem-export" oncommand="Zotero_File_Interface.exportItems();"/> diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -216,6 +216,8 @@ pane.items.menu.remove = Remove Item from Collection… pane.items.menu.remove.multiple = Remove Items from Collection… pane.items.menu.moveToTrash = Move Item to Trash… pane.items.menu.moveToTrash.multiple = Move Items to Trash… +pane.items.menu.delete = Delete Item… +pane.items.menu.delete.multiple = Delete Items… pane.items.menu.export = Export Item… pane.items.menu.export.multiple = Export Items… pane.items.menu.createBib = Create Bibliography from Item…