From 2a80d15676433a5838fb6b188ec23708289b7909 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 2 May 2005 17:09:14 +0000 Subject: [PATCH] web batch update git-svn-id: svn://svn.open-ils.org/ILS/trunk@596 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../opac/AbstractRecordResultPage.js | 226 +++++++++--------- .../src/javascript/opac/AdvancedSearchPage.js | 7 + Open-ILS/src/javascript/opac/GlobalInit.js | 12 +- Open-ILS/src/javascript/opac/LocationTree.js | 8 +- Open-ILS/src/javascript/opac/LogoutPage.js | 2 +- Open-ILS/src/javascript/opac/MRResultPage.js | 36 ++- Open-ILS/src/javascript/opac/Page.js | 1 - .../src/javascript/opac/RecordDetailPage.js | 21 ++ .../src/javascript/opac/RecordResultPage.js | 40 +++- .../src/javascript/opac/SearchBarChunk.js | 2 +- .../src/javascript/opac/SearchBarFormChunk.js | 1 - 11 files changed, 222 insertions(+), 134 deletions(-) create mode 100644 Open-ILS/src/javascript/opac/RecordDetailPage.js diff --git a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js index 7489e0da8d..36dccc2358 100644 --- a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js +++ b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js @@ -5,9 +5,7 @@ AbstractRecordResultPage.baseClass = Page.constructor; /* constructor for our singleton object */ -function AbstractRecordResultPage() { - -} +function AbstractRecordResultPage() {} /* initialize all of the UI components and set up data structures */ @@ -27,15 +25,15 @@ AbstractRecordResultPage.prototype.init = function() { this.subBox = getById("record_subject_sidebar_box"); this.authBox = getById("record_author_sidebar_box"); + this.subBoxL = getById("record_subject_sidebar_box_label"); + this.authBoxL = getById("record_author_sidebar_box_label"); + this.hitsPerPage = 8; /* how many hits are displayed per page */ this.resetPage(); this.searchDepth = 0; /* default to the current search location */ - this.statusBar = getById("top_status_bar_table"); - this.theadDrawn = false; - this.bigOlBox = getById("big_ol_box"); } @@ -44,46 +42,35 @@ AbstractRecordResultPage.prototype.init = function() { /** Resets data structures for a new search */ AbstractRecordResultPage.prototype.resetPage = function() { - - /* - while(this.recordBox.rows.length > 0) - this.recordBox.deleteRow(-1); - */ - - this.prevButton.style.visibility = "hidden"; - this.nextButton.style.visibility = "hidden"; - this.buttonsBox.style.visibility = "hidden"; - - //this.prevButton0.style.visibility = "hidden"; - //this.nextButton0.style.visibility = "hidden"; - //this.buttonsBox0.style.visibility = "hidden"; - this.subBox.innerHTML = ""; this.authBox.innerHTML = ""; - this.subBox.style.visibility = "hidden"; - this.authBox.style.visibility = "hidden"; - this.collectedSubjects = new Array(); this.collectedAuthors = new Array(); - this.searchBar.reset(); - - /* - this.treeBox = getById("ot_nav_widget"); - if(this.treeBox) { - this.treeBox.innerHTML = globalOrgTreeWidget.toString(); + var spot = getById("progress_bar_location"); + var spot2 = getById("progress_bar_percent_location"); + if(spot) { + while(spot.lastChild) + spot.removeChild(spot.lastChild); + + /* progress items for each record and it's hit count listing */ + this.progressBar = new ProgressBar(parseInt(this.hitsPerPage) * 2); + spot.appendChild(this.progressBar.getNode()); + + if(!this.progressBar.running()) { + //this.progressBar.start(); + } } - */ - - + if(spot2 && this.progressBar) + spot2.appendChild(this.progressBar.percentDiv); } AbstractRecordResultPage.prototype.resetSearch = function() { - this.recordIDS = new Array(); + this.recordIDs = new Array(); + this.ranks = new Array(); this.collectedSubjects = new Array(); /* subjects attached to the current batch of records */ this.collectedAuthors = new Array(); /* subjects attached to the current batch of records */ this.requestBatch = new Array(); /* current batch of RemoteRequest objects */ - this.recordIDs = new Array(); /* this set of ids for this search */ this.hitCount = 0; /* hits for the current search */ this.searchOffset = 0; /* the offset for the search display */ @@ -92,40 +79,41 @@ AbstractRecordResultPage.prototype.resetSearch = function() { AbstractRecordResultPage.prototype.gatherIDs = function(result) { this.hitCount = parseInt(result.count); + debug("here"); + /* the 'ids' field consist of [record, rank] */ /* gather all of the ID's */ - for( var i in result.ids ) { - if(result.ids[i]==null) break; - var offset = parseInt(i) + parseInt(this.searchOffset); - this.recordIDs[offset] = result.ids[i]; - debug("adding recordIDs["+offset+"], result.ids["+i+"]"); - } + if( typeof result.ids == 'object' && result.ids[0].constructor == Array ) { + for( var i in result.ids ) { + if(result.ids[i]==null || result.ids[i][0] == null) break; + var offset = parseInt(i) + parseInt(this.searchOffset); + this.recordIDs[offset] = result.ids[i][0]; + this.ranks[offset] = parseFloat(result.ids[i][1]); + debug("adding ranks[" + offset + "] = " + result.ids[i][1] + + " \nrecordIDs["+offset+"], result.ids["+i+"][0]"); + } -} + } else { + for( var i in result.ids ) { + if(result.ids[i]==null) break; + var offset = parseInt(i) + parseInt(this.searchOffset); + this.recordIDs[offset] = result.ids[i]; + debug("adding recordIDs["+offset+"], result.ids["+i+"]"); + } + } -/* search_id is where we are in the recordID's array. page_id is where we - are in relation to the current page [ 0 .. hitsPerPage ] - */ -function menu() { - alert('swapping'); - swapClass(getById('record_context_menu'), 'hide_me', 'show_me' ); - return true; } -function recordRowContextHandler(evt) { - if(!getAppWindow().event) { getAppWindow().event = evt; }; - var win = getAppWindow(); - globalMenuManager.toggle(target.id); - return false; -} + AbstractRecordResultPage.prototype.displayRecord = function( record, search_id, page_id ) { + this.progressBar.manualNext(); var id = parseInt(page_id); var title_row = table_row_find_or_create(this.recordBox, id * 2 + 1 ); @@ -136,7 +124,8 @@ AbstractRecordResultPage.prototype.displayRecord = /* build the appropriate context node for this result */ var menu = globalMenuManager.buildMenu( - "record_result_row","record_result_row_" + page_id ); + "record_result_row_" + page_id ); + this.addMenuItems( menu, record ); globalMenuManager.setContext(title_row, menu); globalMenuManager.setContext(author_row, menu); @@ -153,8 +142,21 @@ AbstractRecordResultPage.prototype.displayRecord = pic_cell.rowSpan = 2; - pic_cell.innerHTML = - "
 
"; + } + + + debug("Adding rank box " + rankBox ); + + pic_cell.innerHTML = rankBox + + ""; @@ -167,20 +169,6 @@ AbstractRecordResultPage.prototype.displayRecord = add_css_class(author_cell, "record_result_author_box"); - if(!title_cell) - alert("No title box"); - - if(!author_cell) - alert("no author box"); - - /* - try { - xulEvtRecordResultButton( globalPageTarget, xul, record, search_id, page_id ); - } catch(E) { - debug("xul function error: " + E ); - } - */ - debug( "Displaying record title: " + record.title() + " author: " + record.author() ); /* limit the length of the title and author lines */ @@ -218,13 +206,23 @@ AbstractRecordResultPage.prototype.displayRecord = if( record.author() ) this.collectedAuthors[record.author()] = true; + /* gather the subjects. subjects are either a string or an array of + [subject, broader topic]. currently, they're all just treated like + subjects */ var arr = record.subject(); for( var sub in arr ) { - var s = normalize(arr[sub]); - if( this.collectedSubjects[s]) - this.collectedSubjects[s] += 1; - else - this.collectedSubjects[s] = 1; + + var ss = arr[sub]; + if( ss.constructor != Array ) + ss = [ss]; + + for( var i in ss ) { + var s = normalize(ss[i]); + if( this.collectedSubjects[s]) + this.collectedSubjects[s] += 1; + else + this.collectedSubjects[s] = 1; + } } /* after loading the last record, contine building the page */ @@ -239,9 +237,10 @@ AbstractRecordResultPage.prototype.finalizePage = function() { this.collectedSubjects = this.collectedSubjects.sort().reverse(); this.collectedAuthors = this.collectedAuthors.sort().reverse(); - this.subBox.style.visibility = "visible"; - this.authBox.style.visibility = "visible"; - + showMe( this.subBox ); + showMe( this.authBox ); + showMe( this.subBoxL ); + showMe( this.authBoxL ); var counter = 0; debug("Collected Subjects: " + this.collectedSubjects[0] + ":" + this.collectedSubjects); @@ -272,48 +271,49 @@ AbstractRecordResultPage.prototype.finalizePage = function() { this.authBox.innerHTML += "
"; } - /* do we need next/prev buttons */ - this.buttonsBox.style.visibility = "visible"; + showMe(this.buttonsBox); - if( this.searchOffset < (parseInt(this.hitCount) - this.hitsPerPage)) { - this.nextButton.style.visibility = "visible"; - } - if(this.searchOffset > 0) { - this.prevButton.style.visibility = "visible"; - } + if( this.searchOffset < (parseInt(this.hitCount) - this.hitsPerPage)) + showMe(this.nextButton); + if(this.searchOffset > 0) + showMe(this.prevButton); - this.bigOlBox.style.visibility = "visible"; - this.bigOlBox.style.display = "block"; - - /* - if( this.progressBar ) - this.progressBar.progressStop(); - */ - /* now add the subjects */ - this.surveyBox = getById("record_survey_sidebar_box"); - this.surveyBox.style.visibility = "visible"; + var box = getById("record_survey_sidebar_box"); var ses = UserSession.instance().getSessionId(); + if(ses) { - var surveys = Survey.retrieveAll(ses); - for( var i in surveys ) { - bc(this.surveyBox,surveys[i]); - } + showMe(box); + showMe(getById("record_survey_sidebar_box_label")); + Survey.retrieveRandom(ses, + function(sur) { + var name = sur.getName(); + sur.setAction( function() { alert("Submitted Survey: " + name); } ); + box.appendChild( sur.getNode() ); + } + ); } -} + /* + var spot = getById("record_sidebar_box"); + spot.style.border = "1px solid green"; + spot.appendChild(createAppElement("br")); + var sidebar = new Sidebar(); + var sidebarbox = new SidebarBox("Test"); + sidebarbox.addItem(createAppTextNode("Hello")); + sidebarbox.addItem(createAppTextNode("Hello2")); + sidebar.addItem(sidebarbox); + spot.appendChild(sidebar.getNode()); + */ -function bc(box, survey) { - var name = survey.getName(); - survey.setAction( function() { alert("Submitted Survey: " + name); } ); - box.appendChild( survey.getNode() ); } AbstractRecordResultPage.prototype.displayCopyCounts = function(copy_counts, search_id, page_id) { + this.progressBar.manualNext(); var titlerow = getById("record_result_title_row_" + page_id ); var authorrow = getById("record_result_author_row_" + page_id ); @@ -331,20 +331,24 @@ AbstractRecordResultPage.prototype.displayCopyCounts = } for( var i in copy_counts) { - //var cell = titlerow.insertCell(titlerow.cells.length); var cell = createAppElement("td"); add_css_class(cell, "copy_count_cell"); cell.innerHTML = copy_counts[i].available + " / " + copy_counts[i].count; cell.setAttribute("rowspan","2"); cell.rowSpan = 2; titlerow.appendChild(cell); - /* - titlerow.innerHTML = titlerow.innerHTML + "" + - copy_counts[i].available + " / " + copy_counts[i].count + ""; - */ + } + if(page_id == (parseInt(this.hitsPerPage) - 1) ) { + if(this.progressBar) this.progressBar.stop(); + showMe(this.bigOlBox); } + if( (page_id == ((parseInt(this.hitCount) - 1 ) - parseInt(this.searchOffset))) || + (page_id == (parseInt(this.hitsPerPage) - 1) )) + if(this.progressBar) this.progressBar.stop(); + + } diff --git a/Open-ILS/src/javascript/opac/AdvancedSearchPage.js b/Open-ILS/src/javascript/opac/AdvancedSearchPage.js index 1829652f19..11e7432857 100644 --- a/Open-ILS/src/javascript/opac/AdvancedSearchPage.js +++ b/Open-ILS/src/javascript/opac/AdvancedSearchPage.js @@ -62,6 +62,13 @@ function doGlobalSearch() { "search", "global", "tcn", obj.tcnText.value ] ); return; } + if( obj.barcodeText.value != null + && obj.barcodeText.value.length > 1 ) { + url_redirect( [ "target", "record_result", "page", "0", + "search", "global", "barcode", obj.barcodeText.value ] ); + return; + } + } diff --git a/Open-ILS/src/javascript/opac/GlobalInit.js b/Open-ILS/src/javascript/opac/GlobalInit.js index 501685a849..7080cd1431 100644 --- a/Open-ILS/src/javascript/opac/GlobalInit.js +++ b/Open-ILS/src/javascript/opac/GlobalInit.js @@ -51,6 +51,10 @@ function globalInit() { globalPage = new MyOPACPage(); break; + case "record_detail": + globalPage = new RecordDetailPage(); + break; + case "about": globalPage = new AboutPage(); break; @@ -65,12 +69,11 @@ function globalInit() { globalLocation = globalOrgTree; globalOrgTreeWidget = new LocationTree(globalOrgTree); globalSearchDepth = findOrgDepth(globalOrgTree.ou_type()); - globalUser = UserSession.instance(); - globalUser.verifySession(); - globalMenuManager = new ContextMenuManager(); loaded = true; } + globalMenuManager = new ContextMenuManager(); + /* hide all context menus on body click */ getDocument().body.onclick = function() { globalMenuManager.hideAll(); @@ -80,9 +83,6 @@ function globalInit() { globalPage.setLocDisplay(); globalPage.locationTree = globalOrgTreeWidget; - -// setTimeout("renderTree()", 5 ); - if( globalSearchBarFormChunk != null) globalSearchBarFormChunk.resetPage(); diff --git a/Open-ILS/src/javascript/opac/LocationTree.js b/Open-ILS/src/javascript/opac/LocationTree.js index 5ed3db8671..522e8496d7 100644 --- a/Open-ILS/src/javascript/opac/LocationTree.js +++ b/Open-ILS/src/javascript/opac/LocationTree.js @@ -58,6 +58,11 @@ LocationTree.prototype.toggle = function(button_div, offsetx, offsety) { offsetx = xpos; } + if(IE) { /*HACK XXX*/ + offsety = parseInt(offsety) + 15; + offsetx = parseInt(offsetx) + 8; + } + this.treeContainerBox.style.position = "absolute"; this.treeContainerBox.style.top = offsety; this.treeContainerBox.style.left = offsetx; @@ -71,8 +76,9 @@ function renderTree() { if(!globalPage.locationTree.widget) globalPage.locationTree.buildOrgTreeWidget(); - debug(" +++++++++++++ Adding org tree widget"); globalPage.locationTree.treeBox.innerHTML = globalPage.locationTree.widget.toString(); } + + diff --git a/Open-ILS/src/javascript/opac/LogoutPage.js b/Open-ILS/src/javascript/opac/LogoutPage.js index 1a5891e2f8..97e9957a77 100644 --- a/Open-ILS/src/javascript/opac/LogoutPage.js +++ b/Open-ILS/src/javascript/opac/LogoutPage.js @@ -28,7 +28,7 @@ LogoutPage.prototype.doLogout = function() { request.send(true); var response = request.getResultObject(); if(! response ) { - alert("error logging out"); /* exception */ + //alert("error logging out"); /* exception */ } } diff --git a/Open-ILS/src/javascript/opac/MRResultPage.js b/Open-ILS/src/javascript/opac/MRResultPage.js index 5b81dacf50..095ce48746 100644 --- a/Open-ILS/src/javascript/opac/MRResultPage.js +++ b/Open-ILS/src/javascript/opac/MRResultPage.js @@ -49,12 +49,11 @@ MRResultPage.prototype.prev = function() { ] ); } -MRResultPage.prototype.addMenuItems = function(menu, record) { - menu.addItem("View Metarecord Details", - function() { alert(record.doc_id()); }); - menu.getItems()[0].addIcon("/images/icon1.png"); - xulEvtMRResultDisplayed( menu, record ); +MRResultPage.prototype.addMenuItems = function(menu, record) { + menu.addItem("View Metarecord Details", + function() { alert(record.doc_id()); }); + xulEvtMRResultDisplayed( menu, record ); } @@ -157,7 +156,6 @@ MRResultPage.prototype.doSearch = function() { this.searchLocation.id(), this.searchDepth, "50", this.searchOffset ); - var obj = this; request.setCompleteCallback( function(req) { @@ -223,6 +221,7 @@ MRResultPage.prototype.doCopyCount = function( record, search_id, page_id ) { var copy_box = getById("record_result_copy_count_box_" + page_id ); /* kick off the copy count search */ + debug("Grabbing copy count for record " + record.doc_id() ); var copy_request = new RemoteRequest( "open-ils.search", "open-ils.search.biblio.metarecord.copy_count", 1, record.doc_id() ); this.requestBatch.push(copy_request); @@ -238,7 +237,7 @@ MRResultPage.prototype.doCopyCount = function( record, search_id, page_id ) { try { copy_box.innerHTML = req.getResultObject(); } catch(E) { - alert("Copy Count Retrieval Error:\n" + E ); + //alert("Copy Count Retrieval Error:\n" + E ); } } ); @@ -273,10 +272,31 @@ MRResultPage.prototype.doCopyCount = function( record, search_id, page_id ) { try { obj.displayCopyCounts(req.getResultObject(), search_id, page_id ); } catch(E) { - alert("Copy Count Retrieval Error:\n" + E ); + //alert("Copy Count Retrieval Error:\n" + E ); } } ); copy_request.send(); } + + +/* +MRResultPage.prototype.gatherIDs = function(result) { + + this.hitCount = parseInt(result.count); + debug("here"); + + for( var i in result.ids ) { + if(result.ids[i]==null || result.ids[i][0] == null) break; + var offset = parseInt(i) + parseInt(this.searchOffset); + this.recordIDs[offset] = result.ids[i][0]; + this.ranks[offset] = parseFloat(result.ids[i][1]); + debug("adding ranks[" + offset + "] = " + result.ids[i][1] + + " \nrecordIDs["+offset+"], result.ids["+i+"][0]"); + } + +} +*/ + + diff --git a/Open-ILS/src/javascript/opac/Page.js b/Open-ILS/src/javascript/opac/Page.js index 48fc589c40..001ecf4170 100644 --- a/Open-ILS/src/javascript/opac/Page.js +++ b/Open-ILS/src/javascript/opac/Page.js @@ -55,7 +55,6 @@ Page.prototype.setLocDisplay = function(name) { } - Page.prototype.updateCurrentLocation = function(org) { if( typeof org == 'object' ) node = org; else node = getOrgById(orgid); diff --git a/Open-ILS/src/javascript/opac/RecordDetailPage.js b/Open-ILS/src/javascript/opac/RecordDetailPage.js new file mode 100644 index 0000000000..6ef9a3544a --- /dev/null +++ b/Open-ILS/src/javascript/opac/RecordDetailPage.js @@ -0,0 +1,21 @@ +var globalRecordDetailPage = null; +RecordDetailPage.prototype = new Page(); +RecordDetailPage.prototype.constructor = RecordDetailPage; +RecordDetailPage.baseClass = Page.constructor; + +function RecordDetailPage() { + if( globalRecordDetailPage != null ) + return globalRecordDetailPage; + this.searchBar = new SearchBarChunk(); +} + + +RecordDetailPage.instance = function() { + if( globalRecordDetailPage != null ) + return globalRecordDetailPage; + return new RecordDetailPage(); +} + +RecordDetailPage.prototype.init = function() { + debug("Initing RecordDetailPage"); +} diff --git a/Open-ILS/src/javascript/opac/RecordResultPage.js b/Open-ILS/src/javascript/opac/RecordResultPage.js index f694f7dc6c..71ce1146cb 100644 --- a/Open-ILS/src/javascript/opac/RecordResultPage.js +++ b/Open-ILS/src/javascript/opac/RecordResultPage.js @@ -43,10 +43,33 @@ RecordResultPage.prototype.prev = function() { } RecordResultPage.prototype.addMenuItems = function(menu, record) { - menu.addItem("View MARC", - function() { alert(record.doc_id()); }); + var func = function() { + var req = new RemoteRequest( + "open-ils.search", + "open-ils.search.biblio.record.html", + record.doc_id()); + req.send(true); + buildViewMARCWindow(req.getResultObject(), record.doc_id() ); + } + + menu.addItem("View MARC", func); xulEvtRecordResultDisplayed( menu, record ); + +} + + +function buildViewMARCWindow(html, id) { + var win = window.open(null,"MARC_" + id, + "location=0,menubar=0,status=0,resizeable,resize," + + "outerHeight=500,outerWidth=400,height=500," + + "width=400,scrollbars=1,screenX=100," + + "screenY=100,top=100,left=100,alwaysraised" ) + win.document.write(html); + win.document.close(); + win.document.title = "View MARC"; + win.focus(); + } @@ -59,7 +82,7 @@ RecordResultPage.prototype.mkLink = function(id, type, value) { case "title": href = createAppElement("a"); add_css_class(href,"record_result_title_link"); - href.setAttribute("href","?target=record_result&mrid=" + id ); + href.setAttribute("href","?target=record_detail&record=" + id ); href.appendChild(createAppTextNode(value)); break; @@ -145,6 +168,11 @@ RecordResultPage.prototype.doSearch = function() { this.globalSearch("isbn", paramObj.__isbn); return; } + if( paramObj.__barcode != null ) { + this.globalSearch("barcode", paramObj.__barcode); + return; + } + } } @@ -156,7 +184,7 @@ RecordResultPage.prototype.globalSearch = function(type, term) { if( !term || term.length < 2 ) throw new EXArg( "globalSearch needs valid term: " + term ); - debug("Performing Global search for term: " + term ); + debug("Performing Global search [" + type + "] for term: " + term ); var method; switch( type ) { @@ -167,6 +195,10 @@ RecordResultPage.prototype.globalSearch = function(type, term) { case "isbn": method = "open-ils.search.biblio.isbn"; break; + + case "barcode": + method = "open-ils.search.biblio.find_by_barcode"; + break; } var request = new RemoteRequest( "open-ils.search", method, term ); diff --git a/Open-ILS/src/javascript/opac/SearchBarChunk.js b/Open-ILS/src/javascript/opac/SearchBarChunk.js index 2a4df8887d..bc6e85472e 100644 --- a/Open-ILS/src/javascript/opac/SearchBarChunk.js +++ b/Open-ILS/src/javascript/opac/SearchBarChunk.js @@ -21,7 +21,7 @@ function SearchBarChunk() { this.logout_div = getById("logout_div"); if(globalSearchBarChunk == null) - this.session = UserSession.instance(); + try { this.session = UserSession.instance(); } catch(E) {} else this.session = globalSearchBarChunk.session; diff --git a/Open-ILS/src/javascript/opac/SearchBarFormChunk.js b/Open-ILS/src/javascript/opac/SearchBarFormChunk.js index 6f1f05aa13..28d7e212a2 100644 --- a/Open-ILS/src/javascript/opac/SearchBarFormChunk.js +++ b/Open-ILS/src/javascript/opac/SearchBarFormChunk.js @@ -4,7 +4,6 @@ var globalSearchBarFormChunk = null; function SearchBarFormChunk() { this.init(); - //this.resetPage(); globalSearchBarFormChunk = this; } -- 2.43.2