From 41d14f99b6dd2fe991768046b6a14603f7847097 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 21 Jun 2005 21:38:59 +0000 Subject: [PATCH] more general web cleanup more record_detail and supporting work bugfixes git-svn-id: svn://svn.open-ils.org/ILS/trunk@903 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/css/opac/nav_bar.css | 2 +- .../javascript/opac/AbstractRecordResultPage.js | 3 +- Open-ILS/src/javascript/opac/LocationTree.js | 62 +++++++++++++-- Open-ILS/src/javascript/opac/Page.js | 2 +- Open-ILS/src/javascript/opac/RecordDetailPage.js | 87 +++++++++++++++++++--- Open-ILS/src/javascript/util/ils_utils.js | 1 + Open-ILS/src/javascript/util/webutils.js | 2 +- Open-ILS/src/templates/opac/pages/chunks/init.ttk | 11 ++- .../src/templates/opac/pages/chunks/org_tree.ttk | 4 +- .../src/templates/opac/pages/record_result.ttk | 5 +- 10 files changed, 153 insertions(+), 26 deletions(-) diff --git a/Evergreen/css/opac/nav_bar.css b/Evergreen/css/opac/nav_bar.css index d951585d86..e6dfdff92f 100644 --- a/Evergreen/css/opac/nav_bar.css +++ b/Evergreen/css/opac/nav_bar.css @@ -21,7 +21,7 @@ background: #FFF; } -#ot_nav_widget_box { +.ot_nav_widget_box { height: 400px; width: 400px; padding-left: 2px; diff --git a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js index f86c23721a..e42783b9b8 100644 --- a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js +++ b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js @@ -463,7 +463,8 @@ AbstractRecordResultPage.prototype.displayCopyCounts = var cell = trow.insertCell(trow.cells.length); add_css_class(cell,"record_result_thead_header"); cell.innerHTML = - findOrgType(findOrgUnit(copy_counts[i].org_unit).ou_type()).name(); + findOrgType(findOrgUnit( + copy_counts[i].org_unit).ou_type()).opac_label(); } this.theadDrawn = true; } diff --git a/Open-ILS/src/javascript/opac/LocationTree.js b/Open-ILS/src/javascript/opac/LocationTree.js index 42081a1ab3..7bfc7ab3ff 100644 --- a/Open-ILS/src/javascript/opac/LocationTree.js +++ b/Open-ILS/src/javascript/opac/LocationTree.js @@ -6,6 +6,7 @@ function LocationTree( tree, box_id, container_id ) { this.treeContainerBoxId = container_id; this.treeBoxId = box_id; this.setObjects(); + this.treeBuilder = buildOrgTreeWidget; } @@ -16,7 +17,7 @@ LocationTree.prototype.setObjects = function() { this.treeContainerBox = getById("ot_nav_widget"); if(this.treeBoxId) - this.treeBox = getById(treeBoxId); + this.treeBox = getById(this.treeBoxId); else this.treeBox = getById("ot_nav_widget_box"); @@ -26,7 +27,8 @@ LocationTree.prototype.buildOrgTreeWidget = function() { debug("Somebody called buildOrgTreeWidget on me..."); this.setObjects(); - this.widget = buildOrgTreeWidget(globalOrgTree, true); + //this.widget = buildOrgTreeWidget(globalOrgTree, true); + this.widget = this.treeBuilder(globalOrgTree, true); } @@ -61,10 +63,10 @@ function buildOrgTreeWidget(org_node, root) { LocationTree.prototype.hide = function() { this.setObjects(); - this.widget = buildOrgTreeWidget(globalOrgTree, true); + this.widget = this.treeBuilder(globalOrgTree, true); if(this.treeContainerBox && - this.treeContainerBox.className.indexOf("nav_bar_visible") != -1 ) { - swapClass( this.treeContainerBox, "nav_bar_hidden", "nav_bar_visible" ); + this.treeContainerBox.className.indexOf("show_me") != -1 ) { + swapClass( this.treeContainerBox, "hide_me", "show_me" ); } } @@ -76,13 +78,18 @@ LocationTree.prototype.toggle = function(button_div, offsetx, offsety) { debug("Tree container " + this.treeContainerBox ); debug("Tree box " + this.treeBox ); - swapClass( this.treeContainerBox, "nav_bar_hidden", "nav_bar_visible" ); + swapClass( this.treeContainerBox, "hide_me", "show_me" ); var obj = this; - if(this.treeBox && this.treeBox.firstChild.nodeType == 3) { + if( (this.treeBox && this.treeBox.firstChild && + this.treeBox.firstChild.nodeType == 3) || + (!this.treeBox.firstChild)) { + + debug("location tree has not been rendered... rendering.."); setTimeout(function() { renderTree(obj); }, 5 ); } + //alert(this.treeBox.firstChild.nodeType); if( button_div && offsetx == null && offsety == null ) { var x = findPosX(button_div); @@ -107,7 +114,48 @@ LocationTree.prototype.toggle = function(button_div, offsetx, offsety) { function renderTree(tree) { tree.setObjects(); if(!tree.widget) tree.buildOrgTreeWidget(); + /* + debug("Spitting tree out to the treeBox:\n" + + tree.widget.toString() ); */ tree.treeBox.innerHTML = tree.widget.toString(); } + +/* generates a new chunk within with the tree is inserted */ +LocationTree.prototype.newSpot = function(box_id, container_id) { + + var cont = elem("div", { id : this.treeContainerBoxId } ); + var box = elem("div", { id : this.treeBoxId } ); + var expando_line = elem("div"); + var expando = elem("div"); + var expand_all = elem("a", null, null, "Expand All"); + var collapse_all = elem("a", null, null, "Collapse All"); + + add_css_class(cont, "nav_widget"); + add_css_class(cont, "hide_me"); + add_css_class(box, "ot_nav_widget_box"); + add_css_class(expando_line, "expando_links"); + add_css_class(expando, "expando_links"); + + + cont.appendChild(expando_line); + cont.appendChild(expando); + cont.appendChild(elem("br")); + cont.appendChild(box); + + expando_line.appendChild(elem("br")); + var obj = this; + expand_all.onclick = function() { obj.widget.expandAll(); }; + collapse_all.onclick = function() { + obj.widget.collapseAll(); + obj.widget.expand(); }; + + expando.appendChild(expand_all); + expando.appendChild(createAppTextNode(" ")); + expando.appendChild(collapse_all); + expando.appendChild(createAppTextNode(" ")); + + return cont; + +} diff --git a/Open-ILS/src/javascript/opac/Page.js b/Open-ILS/src/javascript/opac/Page.js index 0c045e2db1..6153f86d57 100644 --- a/Open-ILS/src/javascript/opac/Page.js +++ b/Open-ILS/src/javascript/opac/Page.js @@ -86,7 +86,7 @@ Page.prototype.resetRange = function() { if( otype.depth() > findOrgType(orgunit.ou_type()).depth() ) continue; - var select = new Option(otype.name(), otype.depth()); + var select = new Option(otype.opac_label(), otype.depth()); this.searchRange.options[this.searchRange.options.length] = select; diff --git a/Open-ILS/src/javascript/opac/RecordDetailPage.js b/Open-ILS/src/javascript/opac/RecordDetailPage.js index 2950d9bcdf..299bac8d02 100644 --- a/Open-ILS/src/javascript/opac/RecordDetailPage.js +++ b/Open-ILS/src/javascript/opac/RecordDetailPage.js @@ -3,6 +3,8 @@ RecordDetailPage.prototype = new Page(); RecordDetailPage.prototype.constructor = RecordDetailPage; RecordDetailPage.baseClass = Page.constructor; +var globalDetailRecord; + function RecordDetailPage() { if( globalRecordDetailPage != null ) return globalRecordDetailPage; @@ -54,15 +56,44 @@ RecordDetailPage.prototype.init = function() { RecordDetailPage.prototype.draw = function() { this.mainBox = getById("record_detail_copy_info"); + var linksDiv = elem("div"); + var leftLink = elem("div", { style: "width: 50%;text-align: left" }); + var rightLink = elem("div", { style: "width: 50%;text-align: right"}); + linksDiv.appendChild(leftLink); + linksDiv.appendChild(rightLink); + this.mainBox.appendChild(linksDiv); + this.mainBox.appendChild(elem("br")); this.parentLink = elem("a", { href : "javascript:void(0)", id : "parent_link", style : "text-decoration:underline" } ); - this.mainBox.appendChild(this.parentLink); - this.locationTree = elem("div"); - this.mainBox.appendChild(this.locationTree); + var a = elem("a", + { href : "javascript:void(0)", + style : "text-decoration:underline" }, null, + "Select a location whose Volumes/Copies you wish to see"); + + var obj = this; + a.onclick = function(evt) { + obj.copyLocationTree.toggle(null, 100, 100); + }; + + leftLink.appendChild(a); + rightLink.appendChild(this.parentLink); + + /* --------------------------------------------- */ + + + this.copyLocationTree = new LocationTree( + globalOrgTree, "record_detail_tree", "record_detail_tree_container" ); + td = this.copyLocationTree.newSpot(); + this.copyLocationTree.treeBuilder = buildCustomOrgTree; + this.mainBox.appendChild(td); + + this.copyLocationTree.setObjects(); + + this.treeDiv = elem("div"); this.mainBox.appendChild(this.treeDiv); @@ -73,6 +104,39 @@ RecordDetailPage.prototype.draw = function() { } + +function buildCustomOrgTree(org_node, root) { + + debug("performing custom org tree build"); + var item; + + if(root) { + item = new WebFXTree(org_node.name()); + item.setBehavior('classic'); + } else { + item = new WebFXTreeItem(org_node.name()); + } + + item.action = + "javascript:globalPage.drawCopyTrees(" + + org_node.id() + ", logicNode.globalDetailRecord );" + + "globalPage.copyLocationTree.hide();"; + + + for( var index in org_node.children()) { + var childorg = org_node.children()[index]; + if( childorg != null ) { + debug("Adding " + childorg.name() + " to org tree"); + var tree_node = buildCustomOrgTree(childorg); + if(tree_node != null) + item.add(tree_node); + } + } + + return item; +} + + RecordDetailPage.prototype.setViewMarc = function(record) { var marcb = elem( "a", { @@ -103,6 +167,9 @@ RecordDetailPage.prototype.fetchRecord = function(id) { req.setCompleteCallback( function() { obj.record = req.getResultObject(); + globalDetailRecord = obj.record; + obj.copyLocationTree.widget = + buildCustomOrgTree(globalOrgTree, obj.record, true); obj.drawRecord(obj.record); obj.setViewMarc(obj.record); } @@ -232,9 +299,12 @@ RecordDetailPage.prototype.grabCopyTree = function(record, orgUnit, callback, sy /* entry point for displaying the copy details pane */ RecordDetailPage.prototype.drawCopyTrees = function(orgUnit, record) { + debug("Got ORG unit " + orgUnit); + orgUnit = findOrgUnit(orgUnit); + debug("OrgUnit depth is: " + findOrgType(orgUnit.ou_type()).depth()); - this.displayLocationTree(record); + //this.displayLocationTree(record); /* display a 'hold on' message */ this.treeDiv.appendChild(elem("br")); @@ -251,15 +321,12 @@ RecordDetailPage.prototype.drawCopyTrees = function(orgUnit, record) { } -/* displays a link to choose another location and embeds a - copy of the location tree for choosing said location */ +/* RecordDetailPage.prototype.displayLocationTree = function(record) { - - var locTree = new LocationTree(globalOrgTree); - locTree.buildOrgTreeWidget(); +} +*/ -} /* displays a link to view info for the parent org if showMe == true, we don't search for the parent, diff --git a/Open-ILS/src/javascript/util/ils_utils.js b/Open-ILS/src/javascript/util/ils_utils.js index e7d3babc5c..a6e4aceacb 100644 --- a/Open-ILS/src/javascript/util/ils_utils.js +++ b/Open-ILS/src/javascript/util/ils_utils.js @@ -32,6 +32,7 @@ function findOrgType(type_id) { /* locates a specific org unit */ function findOrgUnit(org_id, branch) { if(org_id == null) return null; + if(typeof org_id == 'object') return org_id; if(globalOrgTree == null) throw new EXArg("Need globalOrgTree"); diff --git a/Open-ILS/src/javascript/util/webutils.js b/Open-ILS/src/javascript/util/webutils.js index ff71cb03ef..ba33981ebe 100644 --- a/Open-ILS/src/javascript/util/webutils.js +++ b/Open-ILS/src/javascript/util/webutils.js @@ -617,7 +617,7 @@ function elem(name, attrs, style, text) { } } if (text) { - e.appendChild(document.createTextNode(text)); + e.appendChild(createAppTextNode(text)); } return e; } diff --git a/Open-ILS/src/templates/opac/pages/chunks/init.ttk b/Open-ILS/src/templates/opac/pages/chunks/init.ttk index c1b4f7ba28..770b28c5bc 100644 --- a/Open-ILS/src/templates/opac/pages/chunks/init.ttk +++ b/Open-ILS/src/templates/opac/pages/chunks/init.ttk @@ -73,8 +73,17 @@ function setDeepLink() { var node = document.getElementById("deep_link_div"); if(node) { + var org = logicNode.globalSelectedLocation; + if(org == null) + org = logicNode.globalLocation; + org = org.id(); + + var depth = logicNode.globalSearchDepth; + var a = document.createElement("a"); - a.setAttribute("href", location.href + "&sub_frame=1"); + a.setAttribute("href", location.href + + "&sub_frame=1&location=" + org + "&depth=" + depth); + a.setAttribute("target", "_blank"); a.appendChild(document.createTextNode("Link to this page")); node.appendChild(a); diff --git a/Open-ILS/src/templates/opac/pages/chunks/org_tree.ttk b/Open-ILS/src/templates/opac/pages/chunks/org_tree.ttk index 182ecb30e7..fc21d135b7 100644 --- a/Open-ILS/src/templates/opac/pages/chunks/org_tree.ttk +++ b/Open-ILS/src/templates/opac/pages/chunks/org_tree.ttk @@ -2,7 +2,7 @@ WRAPPER html/div id='ot_wrapper_box' class='nav_wrapper_box'; - WRAPPER html/div id='ot_nav_widget' class='nav_widget nav_bar_hidden' ; + WRAPPER html/div id='ot_nav_widget' class='nav_widget hide_me' ; WRAPPER html/div class='expando_links'; lines(1); @@ -23,7 +23,7 @@ lines(1); - WRAPPER html/div id='ot_nav_widget_box'; + WRAPPER html/div class='ot_nav_widget_box' id='ot_nav_widget_box'; "Loading Tree..."; END; diff --git a/Open-ILS/src/templates/opac/pages/record_result.ttk b/Open-ILS/src/templates/opac/pages/record_result.ttk index 0b04f7d050..0b6d532fd6 100644 --- a/Open-ILS/src/templates/opac/pages/record_result.ttk +++ b/Open-ILS/src/templates/opac/pages/record_result.ttk @@ -32,8 +32,9 @@ WRAPPER html/table class='record_result_box', id='record_result_box'; WRAPPER html/thead class='record_result_thead'; WRAPPER html/row id='record_result_thead_row'; - cell(nowrap='nowrap', colspan='2', - content="Title / Author", class='record_box_descriptor' ); + cell(nowrap='nowrap', colspan='2', + #content="Title / Author", class='record_box_descriptor' ); + content=" ", class='record_box_descriptor' ); END; END; END; -- 2.11.0