1 var globalRecordDetailPage = null;
2 RecordDetailPage.prototype = new Page();
3 RecordDetailPage.prototype.constructor = RecordDetailPage;
4 RecordDetailPage.baseClass = Page.constructor;
6 var globalDetailRecord;
8 function RecordDetailPage() {
9 if( globalRecordDetailPage != null )
10 return globalRecordDetailPage;
11 this.searchBar = new SearchBarChunk();
14 RecordDetailPage.prototype.setPageTrail = function() {
15 var box = getById("page_trail");
18 var d = this.buildTrailLink("start",true);
22 d = this.buildTrailLink("advanced_search",true);
27 var b = this.buildTrailLink("mr_result", true);
30 box.appendChild(this.buildDivider());
34 box.appendChild(this.buildDivider());
36 box.appendChild(this.buildTrailLink("record_result", true));
37 } catch(E) {} /* doesn't work when deep linking */
39 box.appendChild(this.buildDivider());
41 this.buildTrailLink("record_detail",false));
45 RecordDetailPage.instance = function() {
46 if( globalRecordDetailPage != null )
47 return globalRecordDetailPage;
48 return new RecordDetailPage();
51 RecordDetailPage.prototype.init = function() {
52 debug("Initing RecordDetailPage");
56 RecordDetailPage.prototype.draw = function() {
57 this.mainBox = getById("record_detail_copy_info");
59 var table = elem("table", { width: "100%" } );
62 var linksDiv = table.insertRow(0);
63 var leftLink = linksDiv.insertCell(0);
64 var rightLink = linksDiv.insertCell(1);
66 leftLink.width = "50%";
67 rightLink.width = "50%";
68 leftLink.align = "left";
69 rightLink.align = "right";
71 this.parentLink = elem("a",
72 { href : "javascript:void(0)",
74 style : "text-decoration:underline" } );
77 { href : "javascript:void(0)",
78 style : "text-decoration:underline" }, null,
79 "Select a location whose Volumes/Copies you wish to see");
82 a.onclick = function(evt) {
83 obj.copyLocationTree.toggle(null, 100, 100);
87 leftLink.appendChild(a);
88 rightLink.appendChild(this.parentLink);
89 this.mainBox.appendChild(table);
91 /* --------------------------------------------- */
94 this.copyLocationTree = new LocationTree(
95 globalOrgTree, "record_detail_tree", "record_detail_tree_container" );
96 td = this.copyLocationTree.newSpot();
97 this.copyLocationTree.treeBuilder = buildCustomOrgTree;
98 this.mainBox.appendChild(td);
100 this.copyLocationTree.setObjects();
104 this.treeDiv = elem("div");
105 this.mainBox.appendChild(this.treeDiv);
107 this.fetchRecord(paramObj.__record); /* sets this.record */
108 this.viewMarc = getById("record_detail_view_marc");
114 function buildCustomOrgTree(org_node, root) {
116 debug("performing custom org tree build");
120 item = new WebFXTree(org_node.name());
121 item.setBehavior('classic');
123 item = new WebFXTreeItem(org_node.name());
127 "javascript:globalPage.drawCopyTrees(" +
128 org_node.id() + ", logicNode.globalDetailRecord );" +
129 "globalPage.copyLocationTree.hide();";
132 for( var index in org_node.children()) {
133 var childorg = org_node.children()[index];
134 if( childorg != null ) {
135 debug("Adding " + childorg.name() + " to org tree");
136 var tree_node = buildCustomOrgTree(childorg);
137 if(tree_node != null)
146 RecordDetailPage.prototype.setViewMarc = function(record) {
147 var marcb = elem( "a",
149 href:"javascript:void(0)",
150 style: "text-decoration:underline"
154 debug(".ou_type()Setting up view marc callback with record " + record.doc_id());
155 var func = buildViewMARCWindow(record);
156 marcb.onclick = func;
157 this.viewMarc.appendChild(marcb);
161 RecordDetailPage.prototype.fetchRecord = function(id) {
163 debug("No ID in fetchRecord");
167 var req = new RemoteRequest(
169 "open-ils.search.biblio.record.mods_slim.retrieve",
173 req.setCompleteCallback(
175 obj.record = req.getResultObject();
176 globalDetailRecord = obj.record;
177 obj.copyLocationTree.widget =
178 buildCustomOrgTree(globalOrgTree, obj.record, true);
179 obj.drawRecord(obj.record);
180 obj.setViewMarc(obj.record);
188 RecordDetailPage.prototype.drawRecord = function(record) {
190 var title_cell = getById("record_detail_title_cell");
191 var author_cell = getById("record_detail_author_cell");
192 var isbn_cell = getById("record_detail_isbn_cell");
194 var edition_cell = getById("record_detail_edition_cell");
195 var pubdate_cell = getById("record_detail_pubdate_cell");
196 var publisher_cell = getById("record_detail_publisher_cell");
198 var subject_cell = getById("record_detail_subject_cell");
199 var tcn_cell = getById("record_detail_tcn_cell");
200 var resource_cell = getById("record_detail_resource_cell");
201 var pic_cell = getById("record_detail_pic_cell");
203 add_css_class(title_cell, "detail_item_cell");
204 add_css_class(author_cell, "detail_item_cell");
205 add_css_class(isbn_cell, "detail_item_cell");
206 add_css_class(edition_cell, "detail_item_cell");
207 add_css_class(pubdate_cell, "detail_item_cell");
208 add_css_class(publisher_cell, "detail_item_cell");
209 add_css_class(subject_cell, "detail_item_cell");
210 add_css_class(tcn_cell, "detail_item_cell");
211 add_css_class(resource_cell, "detail_item_cell");
213 title_cell.appendChild(
214 createAppTextNode(normalize(record.title())));
215 author_cell.appendChild(
216 createAppTextNode(normalize(record.author())));
217 isbn_cell.appendChild(
218 createAppTextNode(record.isbn()));
220 edition_cell.appendChild(
221 createAppTextNode(record.edition()));
222 pubdate_cell.appendChild(
223 createAppTextNode(record.pubdate()));
224 publisher_cell.appendChild(
225 createAppTextNode(record.publisher()));
227 subject_cell.appendChild(
228 createAppTextNode(record.subject()));
229 tcn_cell.appendChild(
230 createAppTextNode(record.tcn()));
235 var resource = record.types_of_resource()[0];
236 var r_pic = elem("img",
237 { src: "/images/" + resource + ".jpg" } );
238 resource_cell.appendChild(r_pic);
239 resource_cell.appendChild(createAppTextNode(" "));
241 resource_cell.appendChild(
242 createAppTextNode(record.types_of_resource()));
245 pic_cell.appendChild(this.mkImage(record));
247 var orgUnit = globalSelectedLocation;
248 if(!orgUnit) orgUnit = globalLocation;
250 this.drawCopyTrees(orgUnit, record);
253 /* sets up the cover art image */
254 RecordDetailPage.prototype.mkImage = function(record) {
256 var isbn = record.isbn();
257 if(isbn) isbn = isbn.replace(/\s+/,"");
260 var big_pic = elem("a", {
261 href : "http://images.amazon.com/images/P/" +isbn + ".01.LZZZZZZZ.jpg",
262 title : "Click for larger image" } );
264 var img_src = "http://images.amazon.com/images/P/" +isbn + ".01.MZZZZZZZ.jpg";
265 var pic = elem ( "img", { src : img_src }, { border : "0px none" });
266 big_pic.appendChild(pic);
272 /* if sync, it is a synchronous call */
273 RecordDetailPage.prototype.grabCopyTree = function(record, orgUnit, callback, sync) {
275 var orgIds = new Array();
276 if(orgUnit.constructor == Array) {
277 for(var x = 0; x < orgUnit.length; x++) {
278 orgIds.push(orgUnit[x].id());
281 orgIds.push(orgUnit.id());
284 debug("Grabbing copy tree for " + orgIds);
286 var req = new RemoteRequest(
288 "open-ils.cat.asset.copy_tree.retrieve",
289 null, record.doc_id(), orgIds );
293 if(sync) { /* synchronous call */
295 callback(req.getResultObject());
298 req.setCompleteCallback(
299 function(r) { callback(r.getResultObject()); });
305 /* entry point for displaying the copy details pane */
306 RecordDetailPage.prototype.drawCopyTrees = function(orgUnit, record) {
308 debug("Got ORG unit " + orgUnit);
309 orgUnit = findOrgUnit(orgUnit);
311 debug("OrgUnit depth is: " + findOrgType(orgUnit.ou_type()).depth());
313 //this.displayLocationTree(record);
315 /* display a 'hold on' message */
316 this.treeDiv.appendChild(elem("br"));
317 this.treeDiv.appendChild(elem("br"));
319 /* everyone gets to see the location tree */
320 var depth = parseInt(findOrgType(orgUnit.ou_type()).depth());
322 this.treeDiv.appendChild(elem("div", null, null, "Loading copy information..."));
323 if(parseInt(findOrgType(orgUnit.ou_type()).can_have_vols()))
324 this.displayParentLink(orgUnit, record);
325 this.displayTrees(orgUnit, record);
331 RecordDetailPage.prototype.displayLocationTree = function(record) {
337 /* displays a link to view info for the parent org
338 if showMe == true, we don't search for the parent,
339 but use the given orgUnit as the link point */
340 RecordDetailPage.prototype.displayParentLink = function(orgUnit, record, showMe) {
342 var region = orgUnit;
344 region = findOrgUnit(orgUnit.parent_ou());
346 var href = this.parentLink;
347 removeChildren(href);
349 href.appendChild(createAppTextNode(
350 "View Volumes/Copies for " + region.name()));
353 href.onclick = function() {
355 removeChildren(obj.treeDiv);
356 obj.treeDiv.appendChild(elem("br"));
357 obj.treeDiv.appendChild(elem("br"));
358 obj.treeDiv.appendChild(elem("div", null, null, "Loading copy information..."));
360 /* allows the above message to be displayed */
361 setTimeout(function() { obj.displayTrees(region, record, true) }, 100);
364 obj.displayParentLink(orgUnit, record);
366 obj.displayParentLink(orgUnit, record, true);
369 var reg_div = createAppElement("div");
370 //reg_div.appendChild(href);
371 this.mainBox.insertBefore(reg_div, this.treeDiv);
374 /* displays copy info for orgUnit and all of it's children.
375 if orgUnit is a region (depth == 1), then we just show
376 all of our children. if it's a branch, sub-branch, etc.
377 the current branch as well as all of it's children are displayed */
378 RecordDetailPage.prototype.displayTrees = function(orgUnit, record, sync) {
380 var orgs = orgUnit.children();
383 if(parseInt(findOrgType(orgUnit.ou_type()).can_have_vols()))
384 orgs.unshift(orgUnit);
386 this.grabCopyTree(record, orgs,
388 obj.displayCopyTree(tree, "Volumes/Copies for " + orgUnit.name() );
393 /* displays a single copy tree */
394 RecordDetailPage.prototype.displayCopyTree = function(tree, title) {
396 debug("Displaying copy tree for " + title);
398 var treeDiv = this.treeDiv;
399 removeChildren(treeDiv);
400 add_css_class( treeDiv, "copy_tree_div" );
402 var table = createAppElement("table");
403 add_css_class(table, "copy_tree_table");
404 var header_row = table.insertRow(table.rows.length);
405 add_css_class(header_row, "top_header_row");
406 var header = header_row.insertCell(header_row.cells.length);
408 header.setAttribute("colspan", 3);
409 var bold = createAppElement("b");
410 bold.appendChild(createAppTextNode(title));
411 header.appendChild(bold);
413 var row2 = table.insertRow(table.rows.length);
414 var cell1 = row2.insertCell(row2.cells.length);
415 var cell2 = row2.insertCell(row2.cells.length);
416 var cell3 = row2.insertCell(row2.cells.length);
417 var cell4 = row2.insertCell(row2.cells.length);
419 cell1.appendChild(createAppTextNode("Callnumber"));
420 cell2.appendChild(createAppTextNode("Location"));
421 cell3.appendChild(createAppTextNode("Barcode(s)"));
422 cell4.appendChild(createAppTextNode("Availability"));
424 add_css_class(cell1, "detail_header_cell");
425 add_css_class(cell2, "detail_header_cell");
426 add_css_class(cell3, "detail_header_cell");
427 add_css_class(cell4, "detail_header_cell");
429 if(tree.length == 0) {
430 var row = table.insertRow(table.rows.length);
431 row.insertCell(0).appendChild(
432 createAppTextNode("No copies available for this location"));
436 for( var i in tree ) {
437 var row = table.insertRow(table.rows.length);
438 if(x%2) add_css_class(row, "copy_tree_row_highlight");
439 var volume = tree[i];
441 var cell1 = row.insertCell(row.cells.length);
442 add_css_class(cell1, "detail_item_cell");
443 cell1.appendChild(createAppTextNode(volume.label()));
444 var cell2 = row.insertCell(row.cells.length);
445 add_css_class(cell2, "detail_item_cell");
446 cell2.appendChild(createAppTextNode(
447 findOrgUnit(volume.owning_lib()).name()));
449 var cell3 = row.insertCell(row.cells.length);
450 add_css_class(cell3, "detail_item_cell");
451 cell3.appendChild(createAppTextNode(" "));
453 var cell4 = row.insertCell(row.cells.length);
454 add_css_class(cell4, "detail_item_cell");
455 cell4.appendChild(createAppTextNode(" "));
457 var copies = volume.copies();
459 while(c < copies.length) {
460 var copy = copies[c];
461 if(c == 0) { /* put the first barcode in the same row as the callnumber */
463 cell3.removeChild(cell3.childNodes[0]);
464 cell3.appendChild(createAppTextNode(copy.barcode()));
465 cell4.removeChild(cell4.childNodes[0]);
467 cell4.appendChild(createAppTextNode(
468 find_list(globalCopyStatus,
469 function(i) { return (i.id() == copy.status()); } ).name() ));
473 var row = table.insertRow(table.rows.length);
474 if(x%2) add_css_class(row, "copy_tree_row_highlight");
475 row.insertCell(0).appendChild(createAppTextNode(" "));
476 row.insertCell(1).appendChild(createAppTextNode(" "));
478 var ce = row.insertCell(2);
479 var status_cell = row.insertCell(3);
480 add_css_class(ce, "detail_item_cell");
481 add_css_class(status_cell, "detail_item_cell");
482 ce.appendChild(createAppTextNode(copy.barcode()));
484 status_cell.appendChild(createAppTextNode(
485 find_list(globalCopyStatus,
486 function(i) { return (i.id() == copy.status()); } ).name() ));
494 treeDiv.appendChild(table);