Closes #230, Update collection pane context menu for saved searches
Proper labels for saved searches, hiding rather than disabling irrelevant menu options, added "New Saved Search..." to menu, made file and bibliography export work with saved searches, added "Export Library..." option to Library drop-down
This commit is contained in:
parent
498073bc4d
commit
30e2920c27
4 changed files with 87 additions and 21 deletions
|
@ -41,15 +41,29 @@ var Scholar_File_Interface = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exports a collection
|
* exports a collection or saved search
|
||||||
*/
|
*/
|
||||||
function exportCollection() {
|
function exportCollection() {
|
||||||
var collection = ScholarPane.getSelectedCollection();
|
var collection = ScholarPane.getSelectedCollection();
|
||||||
if(!collection) throw("no collection currently selected");
|
if (collection)
|
||||||
|
{
|
||||||
exportFile(Scholar.getItems(collection.getID()));
|
exportFile(Scholar.getItems(collection.getID()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var searchRef = ScholarPane.getSelectedSavedSearch();
|
||||||
|
if (searchRef)
|
||||||
|
{
|
||||||
|
var search = new Scholar.Search();
|
||||||
|
search.load(searchRef['id']);
|
||||||
|
exportFile(Scholar.Items.get(search.search()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ("No collection or saved search currently selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exports items
|
* exports items
|
||||||
*/
|
*/
|
||||||
|
@ -181,13 +195,26 @@ var Scholar_File_Interface = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a bibliography from a collection
|
* Creates a bibliography from a collection or saved search
|
||||||
*/
|
*/
|
||||||
function bibliographyFromCollection() {
|
function bibliographyFromCollection() {
|
||||||
var collection = ScholarPane.getSelectedCollection();
|
var collection = ScholarPane.getSelectedCollection();
|
||||||
if(!collection) throw("no collection currently selected");
|
if (collection)
|
||||||
|
{
|
||||||
_doBibliographyOptions(Scholar.getItems(collection.getID()));
|
_doBibliographyOptions(Scholar.getItems(collection.getID()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var searchRef = ScholarPane.getSelectedSavedSearch();
|
||||||
|
if (searchRef)
|
||||||
|
{
|
||||||
|
var search = new Scholar.Search();
|
||||||
|
search.load(searchRef['id']);
|
||||||
|
_doBibliographyOptions(Scholar.Items.get(search.search()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ("No collection or saved search currently selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -38,12 +38,13 @@ var ScholarPane = new function()
|
||||||
this.itemSelected = itemSelected;
|
this.itemSelected = itemSelected;
|
||||||
this.deleteSelectedItem = deleteSelectedItem;
|
this.deleteSelectedItem = deleteSelectedItem;
|
||||||
this.deleteSelectedCollection = deleteSelectedCollection;
|
this.deleteSelectedCollection = deleteSelectedCollection;
|
||||||
this.renameSelectedCollection = renameSelectedCollection;
|
this.editSelectedCollection = editSelectedCollection;
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.getCollectionsView = getCollectionsView;
|
this.getCollectionsView = getCollectionsView;
|
||||||
this.getItemsView = getItemsView;
|
this.getItemsView = getItemsView;
|
||||||
this.selectItem = selectItem;
|
this.selectItem = selectItem;
|
||||||
this.getSelectedCollection = getSelectedCollection;
|
this.getSelectedCollection = getSelectedCollection;
|
||||||
|
this.getSelectedSavedSearch = getSelectedSavedSearch;
|
||||||
this.getSelectedItems = getSelectedItems;
|
this.getSelectedItems = getSelectedItems;
|
||||||
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
||||||
this.buildItemContextMenu = buildItemContextMenu;
|
this.buildItemContextMenu = buildItemContextMenu;
|
||||||
|
@ -281,7 +282,7 @@ var ScholarPane = new function()
|
||||||
collectionsView.deleteSelection();
|
collectionsView.deleteSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
function renameSelectedCollection()
|
function editSelectedCollection()
|
||||||
{
|
{
|
||||||
if(collectionsView.selection.count > 0)
|
if(collectionsView.selection.count > 0)
|
||||||
{
|
{
|
||||||
|
@ -359,6 +360,18 @@ var ScholarPane = new function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSelectedSavedSearch()
|
||||||
|
{
|
||||||
|
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
|
||||||
|
{
|
||||||
|
collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
|
||||||
|
if(collection && collection.isSearch())
|
||||||
|
{
|
||||||
|
return collection.ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getSelectedItems()
|
function getSelectedItems()
|
||||||
{
|
{
|
||||||
if(itemsView)
|
if(itemsView)
|
||||||
|
@ -380,19 +393,35 @@ var ScholarPane = new function()
|
||||||
{
|
{
|
||||||
var menu = document.getElementById('scholar-collectionmenu');
|
var menu = document.getElementById('scholar-collectionmenu');
|
||||||
|
|
||||||
if(collectionsView.selection.count == 1 && !collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isLibrary())
|
// Collection
|
||||||
|
if (collectionsView.selection.count == 1 &&
|
||||||
|
collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isCollection())
|
||||||
{
|
{
|
||||||
menu.childNodes[2].removeAttribute('disabled');
|
var hide = [4,6,9,11,12];
|
||||||
menu.childNodes[3].removeAttribute('disabled');
|
var show = [3,5,7,8,10];
|
||||||
menu.childNodes[5].removeAttribute('disabled');
|
|
||||||
menu.childNodes[6].removeAttribute('disabled');
|
|
||||||
}
|
}
|
||||||
|
// Saved Search
|
||||||
|
else if (collectionsView.selection.count == 1 &&
|
||||||
|
collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isSearch())
|
||||||
|
{
|
||||||
|
var hide = [3,5,8,10,12];
|
||||||
|
var show = [4,6,7,9,11];
|
||||||
|
}
|
||||||
|
// Library
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menu.childNodes[2].setAttribute('disabled', true);
|
var hide = [3,4,5,6,7,8,9,10,11];
|
||||||
menu.childNodes[3].setAttribute('disabled', true);
|
var show = [12];
|
||||||
menu.childNodes[5].setAttribute('disabled', true);
|
}
|
||||||
menu.childNodes[6].setAttribute('disabled', true);
|
|
||||||
|
for (var i in hide)
|
||||||
|
{
|
||||||
|
menu.childNodes[hide[i]].setAttribute('hidden', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i in show)
|
||||||
|
{
|
||||||
|
menu.childNodes[show[i]].setAttribute('hidden', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,18 @@
|
||||||
<popupset>
|
<popupset>
|
||||||
<popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();">
|
<popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();">
|
||||||
<menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
|
<menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
|
||||||
|
<menuitem label="&toolbar.newSavedSearch.label;" oncommand="ScholarPane.newSearch()"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem label="&toolbar.renameCollection.label;" oncommand="ScholarPane.renameSelectedCollection();"/>
|
<menuitem label="&toolbar.renameCollection.label;" oncommand="ScholarPane.editSelectedCollection();"/>
|
||||||
|
<menuitem label="&toolbar.renameSavedSearch.label;" oncommand="ScholarPane.editSelectedCollection()"/>
|
||||||
<menuitem label="&toolbar.removeCollection.label;" oncommand="ScholarPane.deleteSelectedCollection();"/>
|
<menuitem label="&toolbar.removeCollection.label;" oncommand="ScholarPane.deleteSelectedCollection();"/>
|
||||||
|
<menuitem label="&toolbar.removeSavedSearch.label;" oncommand="ScholarPane.deleteSelectedCollection()"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem label="&toolbar.exportCollection.label;" oncommand="Scholar_File_Interface.exportCollection();"/>
|
<menuitem label="&toolbar.exportCollection.label;" oncommand="Scholar_File_Interface.exportCollection();"/>
|
||||||
|
<menuitem label="&toolbar.exportSavedSearch.label;" oncommand="Scholar_File_Interface.exportCollection()"/>
|
||||||
<menuitem label="&toolbar.createBibCollection.label;" oncommand="Scholar_File_Interface.bibliographyFromCollection();"/>
|
<menuitem label="&toolbar.createBibCollection.label;" oncommand="Scholar_File_Interface.bibliographyFromCollection();"/>
|
||||||
|
<menuitem label="&toolbar.createBibSavedSearch.label;" oncommand="Scholar_File_Interface.bibliographyFromCollection()"/>
|
||||||
|
<menuitem label="&toolbar.export.label;" oncommand="Scholar_File_Interface.exportFile()"/>
|
||||||
</popup>
|
</popup>
|
||||||
<popup id="scholar-itemmenu" onpopupshowing="ScholarPane.buildItemContextMenu();">
|
<popup id="scholar-itemmenu" onpopupshowing="ScholarPane.buildItemContextMenu();">
|
||||||
<menuitem label="&toolbar.newItem.label;" command="cmd_scholar_newItem"/>
|
<menuitem label="&toolbar.newItem.label;" command="cmd_scholar_newItem"/>
|
||||||
|
@ -67,8 +73,8 @@
|
||||||
<vbox id="collections-pane" persist="width" flex="1">
|
<vbox id="collections-pane" persist="width" flex="1">
|
||||||
<toolbar>
|
<toolbar>
|
||||||
<toolbarbutton id="tb-collection-add" tooltiptext="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
|
<toolbarbutton id="tb-collection-add" tooltiptext="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
|
||||||
<toolbarbutton id="tb-collection-addsearch" tooltiptext="&toolbar.newSearch.label;" oncommand="ScholarPane.newSearch();"/>
|
<toolbarbutton id="tb-collection-addsearch" tooltiptext="&toolbar.newSavedSearch.label;" oncommand="ScholarPane.newSearch();"/>
|
||||||
<toolbarbutton id="tb-collection-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ScholarPane.renameSelectedCollection();" disabled="true"/>
|
<toolbarbutton id="tb-collection-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ScholarPane.editSelectedCollection();" disabled="true"/>
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<toolbarbutton id="tb-collection-menu" type="menu">
|
<toolbarbutton id="tb-collection-menu" type="menu">
|
||||||
<menupopup>
|
<menupopup>
|
||||||
|
|
|
@ -21,14 +21,18 @@
|
||||||
<!ENTITY toolbar.newItem.label "New Item">
|
<!ENTITY toolbar.newItem.label "New Item">
|
||||||
<!ENTITY toolbar.removeItem.label "Remove Item...">
|
<!ENTITY toolbar.removeItem.label "Remove Item...">
|
||||||
<!ENTITY toolbar.newCollection.label "New Collection">
|
<!ENTITY toolbar.newCollection.label "New Collection">
|
||||||
<!ENTITY toolbar.newSearch.label "New Search">
|
<!ENTITY toolbar.newSavedSearch.label "New Saved Search...">
|
||||||
<!ENTITY toolbar.renameCollection.label "Rename Collection...">
|
<!ENTITY toolbar.renameCollection.label "Rename Collection...">
|
||||||
<!ENTITY toolbar.removeCollection.label "Remove Collection...">
|
<!ENTITY toolbar.removeCollection.label "Remove Collection...">
|
||||||
<!ENTITY toolbar.exportCollection.label "Export Collection...">
|
<!ENTITY toolbar.exportCollection.label "Export Collection...">
|
||||||
|
<!ENTITY toolbar.renameSavedSearch.label "Edit Saved Search...">
|
||||||
|
<!ENTITY toolbar.removeSavedSearch.label "Remove Saved Search...">
|
||||||
|
<!ENTITY toolbar.exportSavedSearch.label "Export Saved Search...">
|
||||||
<!ENTITY toolbar.import.label "Import...">
|
<!ENTITY toolbar.import.label "Import...">
|
||||||
<!ENTITY toolbar.export.label "Export Library...">
|
<!ENTITY toolbar.export.label "Export Library...">
|
||||||
<!ENTITY toolbar.preferences.label "Preferences...">
|
<!ENTITY toolbar.preferences.label "Preferences...">
|
||||||
<!ENTITY toolbar.createBibCollection.label "Create Bibliography From Collection...">
|
<!ENTITY toolbar.createBibCollection.label "Create Bibliography From Collection...">
|
||||||
|
<!ENTITY toolbar.createBibSavedSearch.label "Create Bibliography From Saved Search...">
|
||||||
<!ENTITY toolbar.search.label "Search:">
|
<!ENTITY toolbar.search.label "Search:">
|
||||||
<!ENTITY toolbar.fullscreen.tooltip "Toggle Fullscreen Mode">
|
<!ENTITY toolbar.fullscreen.tooltip "Toggle Fullscreen Mode">
|
||||||
<!ENTITY toolbar.openurl.label "Find in your library's catalog">
|
<!ENTITY toolbar.openurl.label "Find in your library's catalog">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue