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..."
This commit is contained in:
parent
f5e55d21bf
commit
fc2be86681
4 changed files with 38 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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();"/>
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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...
|
||||
|
|
Loading…
Reference in a new issue