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:
parent
bd1092e519
commit
f2bef5998c
4 changed files with 92 additions and 67 deletions
|
@ -33,10 +33,12 @@
|
||||||
|
|
||||||
<vbox id="zotero-item-pane" zotero-persist="width">
|
<vbox id="zotero-item-pane" zotero-persist="width">
|
||||||
<!-- Trash -->
|
<!-- 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;"
|
<button id="zotero-item-restore-button" label="&zotero.items.menu.restoreToLibrary;"
|
||||||
oncommand="ZoteroPane_Local.restoreSelectedItems()" hidden="true"/>
|
oncommand="ZoteroPane_Local.restoreSelectedItems()"/>
|
||||||
</vbox>
|
<button id="zotero-item-delete-button" label="&zotero.item.deletePermanently;"
|
||||||
|
oncommand="ZoteroPane_Local.deleteSelectedItems()"/>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
<!-- Commons -->
|
<!-- Commons -->
|
||||||
<button id="zotero-item-show-original" label="Show Original"
|
<button id="zotero-item-show-original" label="Show Original"
|
||||||
|
|
|
@ -1169,19 +1169,25 @@ var ZoteroPane = new function()
|
||||||
"zotero-tb-attachment-add"
|
"zotero-tb-attachment-add"
|
||||||
];
|
];
|
||||||
for(var i=0; i<disableIfNoEdit.length; i++) {
|
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
|
// If a trash is selected, new collection depends on the
|
||||||
// editability of the library
|
// editability of the library
|
||||||
if (collectionTreeRow.isTrash() &&
|
if (collectionTreeRow.isTrash() &&
|
||||||
disableIfNoEdit[i] == 'cmd_zotero_newCollection') {
|
command == 'cmd_zotero_newCollection') {
|
||||||
var overrideEditable = Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID);
|
var overrideEditable = Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var overrideEditable = false;
|
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");
|
if(el.hasAttribute("disabled")) el.removeAttribute("disabled");
|
||||||
} else {
|
} else {
|
||||||
el.setAttribute("disabled", "true");
|
el.setAttribute("disabled", "true");
|
||||||
|
@ -2344,8 +2350,9 @@ var ZoteroPane = new function()
|
||||||
'sep2',
|
'sep2',
|
||||||
'duplicateItem',
|
'duplicateItem',
|
||||||
'deleteItem',
|
'deleteItem',
|
||||||
'deleteFromLibrary',
|
|
||||||
'restoreToLibrary',
|
'restoreToLibrary',
|
||||||
|
'moveToTrash',
|
||||||
|
'deleteFromLibrary',
|
||||||
'mergeItems',
|
'mergeItems',
|
||||||
'sep3',
|
'sep3',
|
||||||
'exportItems',
|
'exportItems',
|
||||||
|
@ -2377,11 +2384,17 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
var collectionTreeRow = this.getCollectionTreeRow();
|
var collectionTreeRow = this.getCollectionTreeRow();
|
||||||
|
var isTrash = collectionTreeRow.isTrash();
|
||||||
|
|
||||||
if(collectionTreeRow.isTrash()) {
|
if (isTrash) {
|
||||||
show.push(m.restoreToLibrary);
|
|
||||||
} else {
|
|
||||||
show.push(m.deleteFromLibrary);
|
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);
|
show.push(m.sep3, m.exportItems, m.createBib, m.loadReport);
|
||||||
|
@ -2463,7 +2476,7 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasImportedAttachment) {
|
if (hasImportedAttachment) {
|
||||||
disable.push(m.deleteFromLibrary, m.createParent, m.renameAttachments);
|
disable.push(m.moveToTrash, m.createParent, m.renameAttachments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2475,53 +2488,50 @@ var ZoteroPane = new function()
|
||||||
menu.setAttribute('itemID', item.id);
|
menu.setAttribute('itemID', item.id);
|
||||||
menu.setAttribute('itemKey', item.key);
|
menu.setAttribute('itemKey', item.key);
|
||||||
|
|
||||||
// Show in Library
|
if (!isTrash) {
|
||||||
if (!collectionTreeRow.isLibrary() && !collectionTreeRow.isWithinGroup()) {
|
// Show in Library
|
||||||
show.push(m.showInLibrary, m.sep1);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.isRegularItem()) {
|
||||||
if (item.isTopLevelItem()) {
|
show.push(m.addNote, m.addAttachments, m.sep2);
|
||||||
show.push(m.createParent);
|
|
||||||
showSep4 = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attachment rename option
|
if (item.isAttachment()) {
|
||||||
if (!item.isTopLevelItem() && item.attachmentLinkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
var showSep4 = false;
|
||||||
show.push(m.renameAttachments);
|
|
||||||
showSep4 = true;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// If not linked URL, show reindex line
|
show.push(m.duplicateItem);
|
||||||
if (Zotero.Fulltext.pdfConverterIsRegistered()
|
|
||||||
&& (yield Zotero.Fulltext.canReindex(item))) {
|
|
||||||
show.push(m.reindexItem);
|
|
||||||
showSep4 = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showSep4) {
|
|
||||||
show.push(m.sep4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
show.push(m.duplicateItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update attachment submenu
|
// Update attachment submenu
|
||||||
|
@ -2530,7 +2540,7 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
// Block certain actions on files if no access
|
// Block certain actions on files if no access
|
||||||
if (item.isImportedAttachment() && !collectionTreeRow.filesEditable) {
|
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);
|
disable.push(x);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2545,21 +2555,30 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
disable.push(m.showInLibrary, m.duplicateItem, m.deleteItem,
|
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 || collectionTreeRow.isPublications()) {
|
||||||
if (!collectionTreeRow.editable) {
|
for (let i in m) {
|
||||||
for (var i in m) {
|
|
||||||
// Still show export/bib/report for non-editable views
|
// Still show export/bib/report for non-editable views
|
||||||
// (other than Commons buckets, which aren't real items)
|
switch (i) {
|
||||||
if (!collectionTreeRow.isBucket()) {
|
case 'exportItems':
|
||||||
|
case 'createBib':
|
||||||
|
case 'loadReport':
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isTrash) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'exportItems':
|
case 'restoreToLibrary':
|
||||||
case 'createBib':
|
case 'deleteFromLibrary':
|
||||||
case 'loadReport':
|
continue;
|
||||||
case 'restoreToLibrary':
|
}
|
||||||
continue;
|
}
|
||||||
|
else if (collectionTreeRow.isPublications()) {
|
||||||
|
switch (i) {
|
||||||
|
case 'addNote':
|
||||||
|
case 'deleteFromLibrary':
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disable.push(m[i]);
|
disable.push(m[i]);
|
||||||
|
@ -2573,8 +2592,9 @@ var ZoteroPane = new function()
|
||||||
show.push(m.deleteItem);
|
show.push(m.deleteItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plural if necessary
|
// Set labels, plural if necessary
|
||||||
menu.childNodes[m.deleteFromLibrary].setAttribute('label', Zotero.getString('pane.items.menu.moveToTrash' + multiple));
|
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.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.createBib].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
|
||||||
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple));
|
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple));
|
||||||
|
|
|
@ -276,8 +276,9 @@
|
||||||
<menuseparator/>
|
<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-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-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-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();"/>
|
<menuitem class="menuitem-iconic zotero-menuitem-merge-items" label="&zotero.items.menu.mergeItems;" oncommand="ZoteroPane_Local.mergeSelectedItems();"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem class="menuitem-iconic zotero-menuitem-export" oncommand="Zotero_File_Interface.exportItems();"/>
|
<menuitem class="menuitem-iconic zotero-menuitem-export" oncommand="Zotero_File_Interface.exportItems();"/>
|
||||||
|
|
|
@ -216,6 +216,8 @@ pane.items.menu.remove = Remove Item from Collection…
|
||||||
pane.items.menu.remove.multiple = Remove Items from Collection…
|
pane.items.menu.remove.multiple = Remove Items from Collection…
|
||||||
pane.items.menu.moveToTrash = Move Item to Trash…
|
pane.items.menu.moveToTrash = Move Item to Trash…
|
||||||
pane.items.menu.moveToTrash.multiple = Move Items 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 = Export Item…
|
||||||
pane.items.menu.export.multiple = Export Items…
|
pane.items.menu.export.multiple = Export Items…
|
||||||
pane.items.menu.createBib = Create Bibliography from Item…
|
pane.items.menu.createBib = Create Bibliography from Item…
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue