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
This commit is contained in:
Dan Stillman 2015-11-03 17:01:07 -05:00
parent bd1092e519
commit f2bef5998c
4 changed files with 92 additions and 67 deletions

View file

@ -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"

View file

@ -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,11 +2384,17 @@ var ZoteroPane = new function()
}
var collectionTreeRow = this.getCollectionTreeRow();
var isTrash = collectionTreeRow.isTrash();
if(collectionTreeRow.isTrash()) {
show.push(m.restoreToLibrary);
} else {
if (isTrash) {
show.push(m.deleteFromLibrary);
show.push(m.restoreToLibrary);
}
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,16 +2488,12 @@ var ZoteroPane = new function()
menu.setAttribute('itemID', item.id);
menu.setAttribute('itemKey', item.key);
if (!isTrash) {
// Show in Library
if (!collectionTreeRow.isLibrary() && !collectionTreeRow.isWithinGroup()) {
if (!collectionTreeRow.isLibrary(true)) {
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);
}
@ -2523,6 +2532,7 @@ var ZoteroPane = new function()
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,20 +2555,29 @@ 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 'restoreToLibrary':
case 'deleteFromLibrary':
continue;
}
}
else if (collectionTreeRow.isPublications()) {
switch (i) {
case 'addNote':
case 'deleteFromLibrary':
continue;
}
}
@ -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));

View file

@ -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();"/>

View file

@ -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…