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:
Dan Stillman 2006-08-30 04:09:34 +00:00
parent 498073bc4d
commit 30e2920c27
4 changed files with 87 additions and 21 deletions

View file

@ -41,15 +41,29 @@ var Scholar_File_Interface = new function() {
}
/*
* exports a collection
* exports a collection or saved search
*/
function exportCollection() {
var collection = ScholarPane.getSelectedCollection();
if(!collection) throw("no collection currently selected");
if (collection)
{
exportFile(Scholar.getItems(collection.getID()));
return;
}
exportFile(Scholar.getItems(collection.getID()));
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
*/
@ -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() {
var collection = ScholarPane.getSelectedCollection();
if(!collection) throw("no collection currently selected");
if (collection)
{
_doBibliographyOptions(Scholar.getItems(collection.getID()));
return;
}
_doBibliographyOptions(Scholar.getItems(collection.getID()));
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");
}
/*

View file

@ -38,12 +38,13 @@ var ScholarPane = new function()
this.itemSelected = itemSelected;
this.deleteSelectedItem = deleteSelectedItem;
this.deleteSelectedCollection = deleteSelectedCollection;
this.renameSelectedCollection = renameSelectedCollection;
this.editSelectedCollection = editSelectedCollection;
this.search = search;
this.getCollectionsView = getCollectionsView;
this.getItemsView = getItemsView;
this.selectItem = selectItem;
this.getSelectedCollection = getSelectedCollection;
this.getSelectedSavedSearch = getSelectedSavedSearch;
this.getSelectedItems = getSelectedItems;
this.buildCollectionContextMenu = buildCollectionContextMenu;
this.buildItemContextMenu = buildItemContextMenu;
@ -281,7 +282,7 @@ var ScholarPane = new function()
collectionsView.deleteSelection();
}
function renameSelectedCollection()
function editSelectedCollection()
{
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()
{
if(itemsView)
@ -380,19 +393,35 @@ var ScholarPane = new function()
{
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');
menu.childNodes[3].removeAttribute('disabled');
menu.childNodes[5].removeAttribute('disabled');
menu.childNodes[6].removeAttribute('disabled');
var hide = [4,6,9,11,12];
var show = [3,5,7,8,10];
}
// 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
{
menu.childNodes[2].setAttribute('disabled', true);
menu.childNodes[3].setAttribute('disabled', true);
menu.childNodes[5].setAttribute('disabled', true);
menu.childNodes[6].setAttribute('disabled', true);
var hide = [3,4,5,6,7,8,9,10,11];
var show = [12];
}
for (var i in hide)
{
menu.childNodes[hide[i]].setAttribute('hidden', true);
}
for (var i in show)
{
menu.childNodes[show[i]].setAttribute('hidden', false);
}
}

View file

@ -48,12 +48,18 @@
<popupset>
<popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();">
<menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
<menuitem label="&toolbar.newSavedSearch.label;" oncommand="ScholarPane.newSearch()"/>
<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.removeSavedSearch.label;" oncommand="ScholarPane.deleteSelectedCollection()"/>
<menuseparator/>
<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.createBibSavedSearch.label;" oncommand="Scholar_File_Interface.bibliographyFromCollection()"/>
<menuitem label="&toolbar.export.label;" oncommand="Scholar_File_Interface.exportFile()"/>
</popup>
<popup id="scholar-itemmenu" onpopupshowing="ScholarPane.buildItemContextMenu();">
<menuitem label="&toolbar.newItem.label;" command="cmd_scholar_newItem"/>
@ -67,8 +73,8 @@
<vbox id="collections-pane" persist="width" flex="1">
<toolbar>
<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-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ScholarPane.renameSelectedCollection();" disabled="true"/>
<toolbarbutton id="tb-collection-addsearch" tooltiptext="&toolbar.newSavedSearch.label;" oncommand="ScholarPane.newSearch();"/>
<toolbarbutton id="tb-collection-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ScholarPane.editSelectedCollection();" disabled="true"/>
<spacer flex="1"/>
<toolbarbutton id="tb-collection-menu" type="menu">
<menupopup>

View file

@ -21,14 +21,18 @@
<!ENTITY toolbar.newItem.label "New Item">
<!ENTITY toolbar.removeItem.label "Remove Item...">
<!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.removeCollection.label "Remove 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.export.label "Export Library...">
<!ENTITY toolbar.preferences.label "Preferences...">
<!ENTITY toolbar.createBibCollection.label "Create Bibliography From Collection...">
<!ENTITY toolbar.createBibSavedSearch.label "Create Bibliography From Saved Search...">
<!ENTITY toolbar.search.label "Search:">
<!ENTITY toolbar.fullscreen.tooltip "Toggle Fullscreen Mode">
<!ENTITY toolbar.openurl.label "Find in your library's catalog">