www

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

commit 022ee4481b69220177a60340cef1348f90e4d7a8
parent 5f283a6b7f44ef93764805c047b9576cc085aef7
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat, 16 Mar 2013 22:55:50 -0400

Add "Delete Collection and Items..." context-menu option

Also update collection/search deletion dialogs with better button text and no more "[JavaScript Application]"

Diffstat:
Mchrome/content/zotero/xpcom/collectionTreeView.js | 14++++++--------
Mchrome/content/zotero/xpcom/data/collection.js | 2+-
Mchrome/content/zotero/zoteroPane.js | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Mchrome/content/zotero/zoteroPane.xul | 1+
Mchrome/locale/en-US/zotero/zotero.properties | 14+++++++++++---
5 files changed, 73 insertions(+), 28 deletions(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -814,7 +814,7 @@ Zotero.CollectionTreeView.prototype.getLastViewedRow = function () { /* * Delete the selection */ -Zotero.CollectionTreeView.prototype.deleteSelection = function() +Zotero.CollectionTreeView.prototype.deleteSelection = function(deleteItems) { if(this.selection.count == 0) return; @@ -842,14 +842,12 @@ Zotero.CollectionTreeView.prototype.deleteSelection = function() for (var i=0; i<rows.length; i++) { //erase collection from DB: - var group = this._getItemAtRow(rows[i]-i); - if(group.isCollection()) - { - group.ref.erase(); + var itemGroup = this._getItemAtRow(rows[i]-i); + if (itemGroup.isCollection()) { + itemGroup.ref.erase(deleteItems); } - else if(group.isSearch()) - { - Zotero.Searches.erase(group.ref['id']); + else if (itemGroup.isSearch()) { + Zotero.Searches.erase(itemGroup.ref.id); } } this._treebox.endUpdateBatch(); diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js @@ -961,7 +961,7 @@ Zotero.Collection.prototype.erase = function(deleteItems) { } } if (del.length) { - Zotero.Items.erase(del); + Zotero.Items.trash(del); } // Remove relations diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -663,7 +663,8 @@ var ZoteroPane = new function() if (from == 'zotero-collections-tree') { if ((event.keyCode == event.DOM_VK_BACK_SPACE && Zotero.isMac) || event.keyCode == event.DOM_VK_DELETE) { - ZoteroPane_Local.deleteSelectedCollection(); + var deleteItems = event.metaKey || (!Zotero.isMac && event.shiftKey); + ZoteroPane_Local.deleteSelectedCollection(deleteItems); event.preventDefault(); return; } @@ -673,7 +674,7 @@ var ZoteroPane = new function() event.keyCode == event.DOM_VK_DELETE) { // If Cmd/Ctrl delete, use forced mode, which does different // things depending on the context - var force = event.metaKey || (!Zotero.isMac && event.ctrlKey); + var force = event.metaKey || (!Zotero.isMac && event.shiftKey); ZoteroPane_Local.deleteSelectedItems(force); event.preventDefault(); return; @@ -1587,7 +1588,7 @@ var ZoteroPane = new function() } - this.deleteSelectedCollection = function () { + this.deleteSelectedCollection = function (deleteItems) { var itemGroup = this.getItemGroup(); // Remove virtual duplicates collection @@ -1606,18 +1607,52 @@ var ZoteroPane = new function() return; } + + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING + + ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL; if (this.collectionsView.selection.count == 1) { if (itemGroup.isCollection()) { - if (confirm(Zotero.getString('pane.collections.delete'))) - { - this.collectionsView.deleteSelection(); + if (deleteItems) { + var index = ps.confirmEx( + null, + Zotero.getString('pane.collections.deleteWithItems.title'), + Zotero.getString('pane.collections.deleteWithItems'), + buttonFlags, + Zotero.getString('pane.collections.deleteWithItems.title'), + "", "", "", {} + ); + } + else { + var index = ps.confirmEx( + null, + Zotero.getString('pane.collections.delete.title'), + Zotero.getString('pane.collections.delete') + + "\n\n" + + Zotero.getString('pane.collections.delete.keepItems'), + buttonFlags, + Zotero.getString('pane.collections.delete.title'), + "", "", "", {} + ); + } + if (index == 0) { + this.collectionsView.deleteSelection(deleteItems); } } else if (itemGroup.isSearch()) { - if (confirm(Zotero.getString('pane.collections.deleteSearch'))) - { + + var index = ps.confirmEx( + null, + Zotero.getString('pane.collections.deleteSearch.title'), + Zotero.getString('pane.collections.deleteSearch'), + buttonFlags, + Zotero.getString('pane.collections.deleteSearch.title'), + "", "", "", {} + ); + if (index == 0) { this.collectionsView.deleteSelection(); } } @@ -1962,7 +1997,8 @@ var ZoteroPane = new function() "showDuplicates", "showUnfiled", "editSelectedCollection", - "removeCollection", + "deleteCollection", + "deleteCollectionAndItems", "sep2", "exportCollection", "createBibCollection", @@ -1992,7 +2028,8 @@ var ZoteroPane = new function() m.newSubcollection, m.sep1, m.editSelectedCollection, - m.removeCollection, + m.deleteCollection, + m.deleteCollectionAndItems, m.sep2, m.exportCollection, m.createBibCollection, @@ -2010,7 +2047,8 @@ var ZoteroPane = new function() // Adjust labels menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.rename.collection')); - menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('pane.collections.menu.remove.collection')); + menu.childNodes[m.deleteCollection].setAttribute('label', Zotero.getString('pane.collections.menu.delete.collection')); + menu.childNodes[m.deleteCollectionAndItems].setAttribute('label', Zotero.getString('pane.collections.menu.delete.collectionAndItems')); menu.childNodes[m.exportCollection].setAttribute('label', Zotero.getString('pane.collections.menu.export.collection')); menu.childNodes[m.createBibCollection].setAttribute('label', Zotero.getString('pane.collections.menu.createBib.collection')); menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.collection')); @@ -2018,14 +2056,14 @@ var ZoteroPane = new function() else if (itemGroup.isSearch()) { show = [ m.editSelectedCollection, - m.removeCollection, + m.deleteCollection, m.sep2, m.exportCollection, m.createBibCollection, m.loadReport ]; - menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('pane.collections.menu.remove.savedSearch')); + menu.childNodes[m.deleteCollection].setAttribute('label', Zotero.getString('pane.collections.menu.delete.savedSearch')); var s = [m.exportCollection, m.createBibCollection, m.loadReport]; if (!this.itemsView.rowCount) { @@ -2046,10 +2084,10 @@ var ZoteroPane = new function() } else if (itemGroup.isDuplicates() || itemGroup.isUnfiled()) { show = [ - m.removeCollection + m.deleteCollection ]; - menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('general.remove')); + menu.childNodes[m.deleteCollection].setAttribute('label', Zotero.getString('general.remove')); } else if (itemGroup.isHeader()) { if (itemGroup.ref.id == 'commons-header') { @@ -2068,7 +2106,7 @@ var ZoteroPane = new function() // Disable some actions if user doesn't have write access // // Some actions are disabled via their commands in onCollectionSelected() - var s = [m.newSubcollection, m.editSelectedCollection, m.removeCollection]; + var s = [m.newSubcollection, m.editSelectedCollection, m.deleteCollection, m.deleteCollectionAndItems]; if (itemGroup.isWithinGroup() && !itemGroup.editable && !itemGroup.isDuplicates() && !itemGroup.isUnfiled()) { disable = disable.concat(s); } diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul @@ -245,6 +245,7 @@ <menuitem label="&zotero.collections.showUnfiledItems;" oncommand="ZoteroPane_Local.setVirtual(ZoteroPane_Local.getSelectedLibraryID(), 'unfiled', true)"/> <menuitem oncommand="ZoteroPane_Local.editSelectedCollection();"/> <menuitem oncommand="ZoteroPane_Local.deleteSelectedCollection();"/> + <menuitem oncommand="ZoteroPane_Local.deleteSelectedCollection(true);"/> <menuseparator/> <menuitem oncommand="Zotero_File_Interface.exportCollection();"/> <menuitem oncommand="Zotero_File_Interface.bibliographyFromCollection();"/> diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -34,6 +34,7 @@ general.permissionDenied = Permission Denied general.character.singular = character general.character.plural = characters general.create = Create +general.delete = Delete general.seeForMoreInformation = See %S for more information. general.enable = Enable general.disable = Disable @@ -132,8 +133,14 @@ date.relative.daysAgo.multiple = %S days ago date.relative.yearsAgo.one = 1 year ago date.relative.yearsAgo.multiple = %S years ago +pane.collections.delete.title = Delete Collection pane.collections.delete = Are you sure you want to delete the selected collection? -pane.collections.deleteSearch = Are you sure you want to delete the selected search? +pane.collections.delete.keepItems = Items within this collection will not be deleted. +pane.collections.deleteWithItems.title = Delete Collection and Items +pane.collections.deleteWithItems = Are you sure you want to delete the selected collection and move all items within it to the Trash? + +pane.collections.deleteSearch.title = Delete Search +pane.collections.deleteSearch = Are you sure you want to delete the selected search? pane.collections.emptyTrash = Are you sure you want to permanently remove items in the Trash? pane.collections.newCollection = New Collection pane.collections.name = Enter a name for this collection: @@ -149,8 +156,9 @@ pane.collections.duplicate = Duplicate Items pane.collections.menu.rename.collection = Rename Collection… pane.collections.menu.edit.savedSearch = Edit Saved Search -pane.collections.menu.remove.collection = Remove Collection… -pane.collections.menu.remove.savedSearch = Remove Saved Search… +pane.collections.menu.delete.collection = Delete Collection… +pane.collections.menu.delete.collectionAndItems = Delete Collection and Items… +pane.collections.menu.delete.savedSearch = Delete Saved Search… pane.collections.menu.export.collection = Export Collection… pane.collections.menu.export.savedSearch = Export Saved Search… pane.collections.menu.createBib.collection = Create Bibliography From Collection…