[open-ils-commits] r20274 - in branches/rel_2_1/Open-ILS: src/perlmods/lib/OpenILS/Application/Search src/perlmods/lib/OpenILS/Application/Storage/Publisher web/opac/skin/default/js (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 21 20:20:27 EDT 2011
Author: phasefx
Date: 2011-04-21 20:20:26 -0400 (Thu, 21 Apr 2011)
New Revision: 20274
Modified:
branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/biblio.pm
branches/rel_2_1/Open-ILS/web/opac/skin/default/js/copy_details.js
branches/rel_2_1/Open-ILS/web/opac/skin/default/js/rdetail.js
Log:
Better call number prefix/support in opac. The copy count status/location summary methods now group by prefix, label, suffix instead of just label. Still need to update rdetailShowCNBrowse/open-ils.search.callnumber.browse, which is being fed an array, [ prefix label, label, suffix label ]
Modified: branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
===================================================================
--- branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm 2011-04-22 00:20:08 UTC (rev 20273)
+++ branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm 2011-04-22 00:20:26 UTC (rev 20274)
@@ -2012,7 +2012,7 @@
method => "copy_count_summary",
api_name => "open-ils.search.biblio.copy_counts.summary.retrieve",
notes => "returns an array of these: "
- . "[ org_id, callnumber_label, <status1_count>, <status2_count>,...] "
+ . "[ org_id, callnumber_prefix, callnumber_label, callnumber_suffix, <status1_count>, <status2_count>,...] "
. "where statusx is a copy status name. The statuses are sorted by ID.",
);
@@ -2024,14 +2024,18 @@
my $data = $U->storagereq(
'open-ils.storage.biblio.record_entry.status_copy_count.atomic', $rid, $org, $depth );
- return [ sort { $a->[1] cmp $b->[1] } @$data ];
+ return [ sort {
+ (($a->[1] ? $a->[1] . ' ' : '') . $a->[2] . ($a->[3] ? ' ' . $a->[3] : ''))
+ cmp
+ (($b->[1] ? $b->[1] . ' ' : '') . $b->[2] . ($b->[3] ? ' ' . $b->[3] : ''))
+ } @$data ];
}
__PACKAGE__->register_method(
method => "copy_location_count_summary",
api_name => "open-ils.search.biblio.copy_location_counts.summary.retrieve",
notes => "returns an array of these: "
- . "[ org_id, callnumber_label, copy_location, <status1_count>, <status2_count>,...] "
+ . "[ org_id, callnumber_prefix, callnumber_label, callnumber_suffix, copy_location, <status1_count>, <status2_count>,...] "
. "where statusx is a copy status name. The statuses are sorted by ID.",
);
@@ -2042,14 +2046,20 @@
my $data = $U->storagereq(
'open-ils.storage.biblio.record_entry.status_copy_location_count.atomic', $rid, $org, $depth );
- return [ sort { $a->[1] cmp $b->[1] || $a->[2] cmp $b->[2] } @$data ];
+ return [ sort {
+ (($a->[1] ? $a->[1] . ' ' : '') . $a->[2] . ($a->[3] ? ' ' . $a->[3] : ''))
+ cmp
+ (($b->[1] ? $b->[1] . ' ' : '') . $b->[2] . ($b->[3] ? ' ' . $b->[3] : ''))
+
+ || $a->[4] cmp $b->[4]
+ } @$data ];
}
__PACKAGE__->register_method(
method => "copy_count_location_summary",
api_name => "open-ils.search.biblio.copy_counts.location.summary.retrieve",
notes => "returns an array of these: "
- . "[ org_id, callnumber_label, <status1_count>, <status2_count>,...] "
+ . "[ org_id, callnumber_prefix, callnumber_label, callnumber_suffix, <status1_count>, <status2_count>,...] "
. "where statusx is a copy status name. The statuses are sorted by ID."
);
@@ -2059,7 +2069,11 @@
$depth ||= 0;
my $data = $U->storagereq(
'open-ils.storage.biblio.record_entry.status_copy_location_count.atomic', $rid, $org, $depth );
- return [ sort { $a->[1] cmp $b->[1] } @$data ];
+ return [ sort {
+ (($a->[1] ? $a->[1] . ' ' : '') . $a->[2] . ($a->[3] ? ' ' . $a->[3] : ''))
+ cmp
+ (($b->[1] ? $b->[1] . ' ' : '') . $b->[2] . ($b->[3] ? ' ' . $b->[3] : ''))
+ } @$data ];
}
@@ -2620,9 +2634,11 @@
);
sub copies_by_cn_label {
- my( $self, $conn, $record, $label, $circ_lib ) = @_;
+ my( $self, $conn, $record, $cn_parts, $circ_lib ) = @_;
my $e = new_editor();
- my $cns = $e->search_asset_call_number({record => $record, label => $label, deleted => 'f'}, {idlist=>1});
+ my $cnp_id = $cn_parts->[0] eq '' ? -1 : $e->search_asset_call_number_prefix({label => $cn_parts->[0]}, {idlist=>1})->[0];
+ my $cns_id = $cn_parts->[2] eq '' ? -1 : $e->search_asset_call_number_suffix({label => $cn_parts->[2]}, {idlist=>1})->[0];
+ my $cns = $e->search_asset_call_number({record => $record, prefix => $cnp_id, label => $cn_parts->[1], suffix => $cns_id, deleted => 'f'}, {idlist=>1});
return [] unless @$cns;
# show all non-deleted copies in the staff client ...
Modified: branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/biblio.pm
===================================================================
--- branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/biblio.pm 2011-04-22 00:20:08 UTC (rev 20273)
+++ branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/biblio.pm 2011-04-22 00:20:26 UTC (rev 20274)
@@ -381,7 +381,7 @@
my $cn_table = asset::call_number->table;
my $cnp_table = asset::call_number_prefix->table;
- my $cns_table = asset::call_number_prefix->table;
+ my $cns_table = asset::call_number_suffix->table;
my $cp_table = asset::copy->table;
my $cl_table = asset::copy_location->table;
my $cs_table = config::copy_status->table;
@@ -389,7 +389,9 @@
my $sql = <<" SQL";
SELECT cp.circ_lib,
- CASE WHEN cnp.id > -1 THEN cnp.label || ' ' ELSE '' END || cn.label || CASE WHEN cns.id > -1 THEN ' ' || cns.label ELSE '' END,
+ CASE WHEN cnp.id > -1 THEN cnp.label ELSE '' END,
+ cn.label,
+ CASE WHEN cns.id > -1 THEN cns.label ELSE '' END,
cp.status,
count(cp.id)
FROM $cp_table cp,
@@ -410,7 +412,7 @@
AND cp.opac_visible IS TRUE
AND cp.deleted IS FALSE
AND cs.opac_visible IS TRUE
- GROUP BY 1,2,3;
+ GROUP BY 1,2,3,4,5;
SQL
my $sth = biblio::record_entry->db_Main->prepare_cached($sql);
@@ -418,13 +420,17 @@
my %data = ();
for my $row (@{$sth->fetchall_arrayref}) {
- $data{$$row[0]}{$$row[1]}{$$row[2]} += $$row[3];
+ $data{$$row[0]}{$$row[1]}{$$row[2]}{$$row[3]}{$$row[4]} += $$row[5];
}
for my $ou (keys %data) {
- for my $cn (keys %{$data{$ou}}) {
- $client->respond( [$ou, $cn, $data{$ou}{$cn}] );
- }
+ for my $cn_prefix (keys %{$data{$ou}}) {
+ for my $cn (keys %{$data{$ou}{$cn_prefix}}) {
+ for my $cn_suffix (keys %{$data{$ou}{$cn_prefix}{$cn}}) {
+ $client->respond( [$ou, $cn_prefix, $cn, $cn_suffix, $data{$ou}{$cn}{$cn_prefix}{$cn}{$cn_suffix}] );
+ }
+ }
+ }
}
return undef;
}
@@ -450,7 +456,7 @@
my $cn_table = asset::call_number->table;
my $cnp_table = asset::call_number_prefix->table;
- my $cns_table = asset::call_number_prefix->table;
+ my $cns_table = asset::call_number_suffix->table;
my $cp_table = asset::copy->table;
my $cl_table = asset::copy_location->table;
my $cs_table = config::copy_status->table;
@@ -461,7 +467,9 @@
my $sql = <<" SQL";
SELECT cp.circ_lib,
- CASE WHEN cnp.id > -1 THEN cnp.label || ' ' ELSE '' END || cn.label || CASE WHEN cns.id > -1 THEN ' ' || cns.label ELSE '' END,
+ CASE WHEN cnp.id > -1 THEN cnp.label ELSE '' END,
+ cn.label,
+ CASE WHEN cns.id > -1 THEN cns.label ELSE '' END,
oils_i18n_xlate('asset.copy_location', 'acpl', 'name', 'id', cl.id::TEXT, ?),
cp.status,
count(cp.id)
@@ -483,7 +491,7 @@
AND cp.opac_visible IS TRUE
AND cp.deleted IS FALSE
AND cs.opac_visible IS TRUE
- GROUP BY 1,2,3,4;
+ GROUP BY 1,2,3,4,5,6;
SQL
my $sth = biblio::record_entry->db_Main->prepare_cached($sql);
@@ -492,14 +500,18 @@
my %data = ();
for my $row (@{$sth->fetchall_arrayref}) {
- $data{$$row[0]}{$$row[1]}{$$row[2]}{$$row[3]} += $$row[4];
+ $data{$$row[0]}{$$row[1]}{$$row[2]}{$$row[3]}{$$row[4]}{$$row[5]} += $$row[6];
}
for my $ou (keys %data) {
- for my $cn (keys %{$data{$ou}}) {
- for my $cl (keys %{$data{$ou}{$cn}}) {
- $client->respond( [$ou, $cn, $cl, $data{$ou}{$cn}{$cl}] );
- }
+ for my $cn_prefix (keys %{$data{$ou}}) {
+ for my $cn (keys %{$data{$ou}{$cn_prefix}}) {
+ for my $cn_suffix (keys %{$data{$ou}{$cn_prefix}{$cn}}) {
+ for my $cl (keys %{$data{$ou}{$cn_prefix}{$cn}{$cn_suffix}}) {
+ $client->respond( [$ou, $cn_prefix, $cn, $cn_suffix, $cl, $data{$ou}{$cn_prefix}{$cn}{$cn_suffix}{$cl}] );
+ }
+ }
+ }
}
}
return undef;
Modified: branches/rel_2_1/Open-ILS/web/opac/skin/default/js/copy_details.js
===================================================================
--- branches/rel_2_1/Open-ILS/web/opac/skin/default/js/copy_details.js 2011-04-22 00:20:08 UTC (rev 20273)
+++ branches/rel_2_1/Open-ILS/web/opac/skin/default/js/copy_details.js 2011-04-22 00:20:26 UTC (rev 20274)
@@ -43,7 +43,7 @@
var print = $n(templateRow,'print');
print.onclick = function() { cpdBuildPrintPane(
contextRow, record, callnumber, orgid, depth) };
- if (typeof callnumber == 'object') {
+ if (callnumber == null) {
addCSSClass(print,'hide_me');
}
@@ -123,11 +123,12 @@
/* builds a friendly print window for this CNs data */
-function cpdBuildPrintPane(contextRow, record, callnumber, orgid, depth) {
+function cpdBuildPrintPane(contextRow, record, cn, orgid, depth) {
var div = cpdBuildPrintWindow( record, orgid);
- $n(div, 'cn').appendChild(text(callnumber));
+ var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+ $n(div, 'cn').appendChild(text(whole_cn_text));
unHideMe($n(div, 'copy_header'));
Modified: branches/rel_2_1/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- branches/rel_2_1/Open-ILS/web/opac/skin/default/js/rdetail.js 2011-04-22 00:20:08 UTC (rev 20273)
+++ branches/rel_2_1/Open-ILS/web/opac/skin/default/js/rdetail.js 2011-04-22 00:20:26 UTC (rev 20274)
@@ -810,7 +810,7 @@
function rdetailVolumeDetails(args) {
var row = $(args.rowid);
var tbody = row.parentNode;
- cpdBuild( tbody, row, record, args.cn, args.org, args.depth, args.copy_location );
+ cpdBuild( tbody, row, record, [args.cn_prefix, args.cn, args.cn_suffix], args.org, args.depth, args.copy_location );
return;
}
@@ -819,7 +819,7 @@
var select = $('cn_browse_selector');
var index = 0;
var arr = [];
- for( var cn in callnumberCache ) arr.push( cn );
+ for( var cn_json in callnumberCache ) arr.push( cn_json );
arr.sort();
if( arr.length == 0 ) {
@@ -828,8 +828,10 @@
}
for( var i = 0; i < arr.length; i++ ) {
- var cn = arr[i];
- var opt = new Option(cn);
+ var cn_json = arr[i];
+ var cn = JSON2js(cn_json);
+ var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+ var opt = new Option(whole_cn_text,cn_json);
select.options[index++] = opt;
}
select.onchange = rdetailGatherCN;
@@ -837,7 +839,7 @@
function rdetailGatherCN() {
var cn = getSelectorVal($('cn_browse_selector'));
- rdetailShowCNBrowse( cn, getLocation(), getDepth(), true );
+ rdetailShowCNBrowse( JSON2js(cn), getLocation(), getDepth(), true );
setSelector( $('cn_browse_selector'), cn );
}
@@ -852,7 +854,7 @@
unHideMe($('rdetail_cn_browse_select_div'));
rdetailBuildCNList();
- setSelector( $('cn_browse_selector'), cn );
+ setSelector( $('cn_browse_selector'), js2JSON(cn) );
hideMe($('rdetail_copy_info_div'));
hideMe($('rdetail_reviews_div'));
hideMe($('rdetail_summary_div'));
@@ -926,7 +928,6 @@
var method = FETCH_COPY_COUNTS_SUMMARY;
if (rdetailShowCopyLocation)
method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
-
if( rdetailShowLocal )
req = new Request(method, record.doc_id(), getLocation(), getDepth())
else
@@ -1036,7 +1037,7 @@
for( var i = 0; i < summary.length; i++ ) {
var arr = summary[i];
- globalCNCache[arr[1]] = 1;
+ globalCNCache[js2JSON([arr[1],arr[2],arr[3]])] = 1; // prefix, label, suffix. FIXME - Am I used anywhere?
var thisOrg = findOrgUnit(arr[0]);
var rowNode = $("cp_info_" + thisOrg.id());
if(!rowNode) continue;
@@ -1070,11 +1071,11 @@
var cpc_temp = rowNode.removeChild(
findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
- var statuses = arr[2];
+ var statuses = arr[4];
var cl = '';
if (rdetailShowCopyLocation) {
- cl = arr[2];
- statuses = arr[3];
+ cl = arr[4];
+ statuses = arr[5];
}
@@ -1086,7 +1087,7 @@
isLocal = true;
if(!localCNFound) {
localCNFound = true;
- defaultCN = arr[1];
+ defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix
}
}
@@ -1094,9 +1095,9 @@
unHideMe(rowNode);
rdetailSetPath( thisOrg, isLocal );
- rdetailBuildBrowseInfo( rowNode, arr[1], isLocal, thisOrg, cl );
+ rdetailBuildBrowseInfo( rowNode, [arr[1],arr[2],arr[3]], isLocal, thisOrg, cl );
- if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
+ if( i == summary.length - 1 && !defaultCN) defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix
}
if(!found) unHideMe(G.ui.rdetail.cp_info_none);
@@ -1104,16 +1105,19 @@
function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
+ var whole_cn_json = js2JSON(cn);
+ var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : '');
+
if(local) {
- var cache = callnumberCache[cn];
+ var cache = callnumberCache[whole_cn_json];
if( cache ) cache.count++;
- else callnumberCache[cn] = { count : 1 };
+ else callnumberCache[whole_cn_json] = { count : 1 };
}
var depth = getDepth();
if( !local ) depth = findOrgDepth(globalOrgTree);
- $n(row, 'rdetail_callnumber_cell').appendChild(text(cn));
+ $n(row, 'rdetail_callnumber_cell').appendChild(text(whole_cn_text));
if (rdetailShowCopyLocation) {
var cl_cell = $n(row, 'rdetail_copylocation_cell');
@@ -1121,12 +1125,12 @@
unHideMe(cl_cell);
}
- _debug('setting action clicks for cn ' + cn);
+ _debug('setting action clicks for cn ' + whole_cn_text);
var dHref = 'javascript:rdetailVolumeDetails('+
- '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn :"'+cn.replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
+ '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn_prefix :"'+cn[0].replace(/\"/g, '\\"')+'",cn :"'+cn[1].replace(/\"/g, '\\"')+'",cn_suffix :"'+cn[2].replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
- var bHref = 'javascript:rdetailShowCNBrowse("' + cn.replace(/\"/g, '\\"') + '", '+orgNode.id()+', "'+depth+'");';
+ var bHref = 'javascript:rdetailShowCNBrowse(["' + cn[0].replace(/\"/g, '\\"') + '","'+cn[1].replace(/\"/g, '\\"') + '","'+cn[2].replace(/\"/g, '\\"') + '"], '+orgNode.id()+', "'+depth+'");';
unHideMe( $n(row, 'details') )
$n(row, 'details').setAttribute('href', dHref);
More information about the open-ils-commits
mailing list