commit fc2be8668101c092431f16f089b508ad31f13c2d
parent f5e55d21bfc57aad6f0dcd3621a862dbf01bcb01
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 22 Sep 2006 09:01:25 +0000
Closes #292, "Delete From Library" context menu option in collections
Library or Saved Search:
"Delete Selected Item From Library..."
Collection:
"Remove Selected Item"
"Delete Selected Item From Library..."
Diffstat:
4 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js
@@ -260,16 +260,21 @@ var ScholarPane = new function()
}
- function deleteSelectedItem()
+ /*
+ * _force_ deletes item from DB even if removing from a collection or search
+ */
+ function deleteSelectedItem(force)
{
if(itemsView && itemsView.selection.count > 0)
{
- if (itemsView._itemGroup.isCollection()){
- var noPrompt = true;
- }
- // Do nothing in search view
- else if (itemsView._itemGroup.isSearch()){
- return;
+ if (!force){
+ if (itemsView._itemGroup.isCollection()){
+ var noPrompt = true;
+ }
+ // Do nothing in search view
+ else if (itemsView._itemGroup.isSearch()){
+ return;
+ }
}
var eraseChildren = {value: true};
@@ -300,7 +305,7 @@ var ScholarPane = new function()
hasChildren ? Scholar.getString('pane.items.delete.attached') : '',
eraseChildren))
{
- itemsView.deleteSelection(eraseChildren.value);
+ itemsView.deleteSelection(eraseChildren.value, force);
}
}
}
@@ -514,28 +519,33 @@ var ScholarPane = new function()
if(itemsView && itemsView.selection.count > 0)
{
menu.childNodes[2].removeAttribute('disabled');
- menu.childNodes[4].removeAttribute('disabled');
+ menu.childNodes[3].removeAttribute('disabled');
menu.childNodes[5].removeAttribute('disabled');
+ menu.childNodes[6].removeAttribute('disabled');
}
else
{
menu.childNodes[2].setAttribute('disabled', true);
- menu.childNodes[4].setAttribute('disabled', true);
+ menu.childNodes[3].setAttribute('disabled', true);
menu.childNodes[5].setAttribute('disabled', true);
+ menu.childNodes[6].setAttribute('disabled', true);
}
-
- if(itemsView && itemsView.selection.count > 1)
+
+ var multiple = (itemsView && itemsView.selection.count > 1) ? '.multiple' : '';
+
+ if (itemsView._itemGroup.isCollection())
{
- menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove.multiple'));
- menu.childNodes[4].setAttribute('label', Scholar.getString('pane.items.menu.export.multiple'));
- menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.createBib.multiple'));
+ menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove' + multiple));
+ menu.childNodes[2].setAttribute('hidden', false);
}
else
{
- menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove'));
- menu.childNodes[4].setAttribute('label', Scholar.getString('pane.items.menu.export'));
- menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.createBib'));
+ menu.childNodes[2].setAttribute('hidden', true);
}
+
+ menu.childNodes[3].setAttribute('label', Scholar.getString('pane.items.menu.erase' + multiple));
+ menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.export' + multiple));
+ menu.childNodes[6].setAttribute('label', Scholar.getString('pane.items.menu.createBib' + multiple));
}
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul
@@ -51,6 +51,7 @@
<menuitem label="&toolbar.newItem.label;" command="cmd_scholar_newItem"/>
<menuseparator/>
<menuitem oncommand="ScholarPane.deleteSelectedItem();"/>
+ <menuitem oncommand="ScholarPane.deleteSelectedItem(true);"/>
<menuseparator/>
<menuitem oncommand="Scholar_File_Interface.exportItems();"/>
<menuitem oncommand="Scholar_File_Interface.bibliographyFromItems();"/>
diff --git a/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js b/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js
@@ -534,9 +534,11 @@ Scholar.ItemTreeView.prototype.selectItem = function(id)
}
/*
- * Delete the selection
+ * Delete the selection
+ *
+ * _force_ deletes item from DB even if removing from a collection
*/
-Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren)
+Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren, force)
{
if(this.selection.count == 0)
return;
@@ -562,7 +564,7 @@ Scholar.ItemTreeView.prototype.deleteSelection = function(eraseChildren)
this._treebox.beginUpdateBatch();
for (var i=0; i<items.length; i++)
{
- if(this._itemGroup.isLibrary()) //erase item from DB
+ if(this._itemGroup.isLibrary() || force) //erase item from DB
items[i].ref.erase(eraseChildren);
else if(this._itemGroup.isCollection())
this._itemGroup.ref.removeItem(items[i].ref.getID());
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties
@@ -9,8 +9,10 @@ pane.items.delete = Are you sure you want to delete the selected item?
pane.items.delete.multiple = Are you sure you want to delete the selected items?
pane.items.delete.title = Delete
pane.items.delete.attached = Erase attached notes and files
-pane.items.menu.remove = Remove Selected Item...
-pane.items.menu.remove.multiple = Remove Selected Items...
+pane.items.menu.remove = Remove Selected Item
+pane.items.menu.remove.multiple = Remove Selected Items
+pane.items.menu.erase = Delete Selected Item From Library...
+pane.items.menu.erase.multiple = Delete Selected Items From Library...
pane.items.menu.export = Export Selected Item...
pane.items.menu.export.multiple = Export Selected Items...
pane.items.menu.createBib = Create Bibliography From Selected Item...