[open-ils-commits] r17216 - in branches/rel_1_6/Open-ILS: web/opac/common/js web/opac/locale/en-US web/opac/skin/default/js web/opac/skin/default/xml/myopac xul/staff_client/server/admin (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Aug 13 14:42:48 EDT 2010
Author: phasefx
Date: 2010-08-13 14:42:43 -0400 (Fri, 13 Aug 2010)
New Revision: 17216
Modified:
branches/rel_1_6/Open-ILS/web/opac/common/js/opac_utils.js
branches/rel_1_6/Open-ILS/web/opac/common/js/org_utils.js
branches/rel_1_6/Open-ILS/web/opac/locale/en-US/lang.dtd
branches/rel_1_6/Open-ILS/web/opac/skin/default/js/depth_selector.js
branches/rel_1_6/Open-ILS/web/opac/skin/default/js/myopac.js
branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js
branches/rel_1_6/Open-ILS/web/opac/skin/default/js/result_common.js
branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml
branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
Log:
opac.org_unit_hiding.depth
This org unit setting will hide certain org units in the public OPAC if the Original Location (url param 'ol') for the OPAC inherits this setting. This setting specifies an org unit depth, that together with the OPAC Original
Location determines which section of the Org Hierarchy should be visible in the OPAC. For example, a stock Evergreen installation will have a 3-tier hierarchy (Consortium/System/Branch), where System has a depth of 1 and Branch
has a depth of 2. If this setting contains a depth of 1 in such an installation, then every library in the System in which the Original Location belongs will be visible, and everything else will be hidden. A depth of 0 will
effectively make every org visible. The embedded OPAC in the staff client ignores this setting.
Thanks to Bill Ott for trailblazing this area and blogging about it.
We're modifying the library selector in the default skin, the depth selector (search This Branch, Local Library System, etc.), the availability summary columns in search results, the copy details in the Record Summary page, and
the search preferences under My Account (we're simply hiding those if needed).
TODO: forward-port to trunk (which handles org unit settings a bit differently). port to craftsman?
Modified: branches/rel_1_6/Open-ILS/web/opac/common/js/opac_utils.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/common/js/opac_utils.js 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/common/js/opac_utils.js 2010-08-13 18:42:43 UTC (rev 17216)
@@ -797,20 +797,43 @@
setTimeout( 'buildOrgSelector(G.ui.common.org_tree, orgTreeSelector);', 1 );
}
+function checkOrgHiding() {
+ var context_org = getOrigLocation() || globalOrgTree.id();
+ var depth = fetchOrgSettingDefault( context_org, 'opac.org_unit_hiding.depth');
+ if (isXUL()) {
+ return false; // disable org hiding for staff client
+ }
+ if ( findOrgDepth( context_org ) < depth ) {
+ return false; // disable org hiding if Original Location doesn't make sense with setting depth (avoids disjointed org selectors)
+ }
+ return { 'org' : findOrgUnit(context_org), 'depth' : depth };
+}
+
var orgTreeSelector;
function buildOrgSelector(node) {
var tree = new SlimTree(node,'orgTreeSelector');
orgTreeSelector = tree;
+ var orgHiding = checkOrgHiding();
for( var i in orgArraySearcher ) {
var node = orgArraySearcher[i];
if( node == null ) continue;
- if(!isXUL() && !isTrue(node.opac_visible())) continue;
- if(node.parent_ou() == null)
+ if(!isXUL() && !isTrue(node.opac_visible())) continue;
+ if (orgHiding) {
+ if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) {
+ continue;
+ }
+ }
+ if(node.parent_ou() == null) {
tree.addNode(node.id(), -1, node.name(),
"javascript:orgSelect(" + node.id() + ");", node.name());
- else {
- tree.addNode(node.id(), node.parent_ou(), node.name(),
- "javascript:orgSelect(" + node.id() + ");", node.name());
+ } else {
+ if (orgHiding && orgHiding.depth == findOrgDepth(node)) {
+ tree.addNode(node.id(), -1, node.name(),
+ "javascript:orgSelect(" + node.id() + ");", node.name());
+ } else {
+ tree.addNode(node.id(), node.parent_ou(), node.name(),
+ "javascript:orgSelect(" + node.id() + ");", node.name());
+ }
}
}
hideMe($('org_loading_div'));
Modified: branches/rel_1_6/Open-ILS/web/opac/common/js/org_utils.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/common/js/org_utils.js 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/common/js/org_utils.js 2010-08-13 18:42:43 UTC (rev 17216)
@@ -92,13 +92,26 @@
function findSiblingOrgs(node) { return findOrgUnit(node.parent_ou()).children(); }
-/* true if 'org' is 'me' or a child of mine */
-function orgIsMine(me, org) {
- if(!me || !org) return false;
- if(me.id() == org.id()) return true;
+/* true if 'org' is 'me' or a child of mine, or optionally, a child of an ancestor org within the specified depth */
+function orgIsMine(me, org, depth) {
+ if(!me || !org) {
+ return false;
+ }
+ if(me.id() == org.id()) {
+ return true;
+ }
+ if (depth) {
+ while (depth < findOrgDepth(me)) {
+ me = findOrgUnit( me.parent_ou() );
+ }
+ if(me.id() == org.id()) {
+ return true;
+ }
+ }
for( var i in me.children() ) {
- if(orgIsMine(me.children()[i], org))
+ if(orgIsMine(me.children()[i], org, false)) {
return true;
+ }
}
return false;
}
Modified: branches/rel_1_6/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/locale/en-US/lang.dtd 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/locale/en-US/lang.dtd 2010-08-13 18:42:43 UTC (rev 17216)
@@ -1687,6 +1687,8 @@
<!ENTITY staff.server.admin.org_settings.circ.lost_immediately_available.desc "Lost items are usable on checkin instead of going \'home\' first">
<!ENTITY staff.server.admin.org_settings.opac.allow_pending_address "OPAC: Allow pending addresses">
<!ENTITY staff.server.admin.org_settings.opac.allow_pending_address.desc "If enabled, patrons can create and edit existing addresses. Addresses are kept in a pending state until staff approves the changes">
+<!ENTITY staff.server.admin.org_settings.opac.org_unit_hiding.depth "OPAC: Org Unit Hiding Depth">
+<!ENTITY staff.server.admin.org_settings.opac.org_unit_hiding.depth.desc "This will hide certain org units in the public OPAC if the Original Location (url param \'ol\') for the OPAC inherits this setting. This setting specifies an org unit depth, that together with the OPAC Original Location determines which section of the Org Hierarchy should be visible in the OPAC. For example, a stock Evergreen installation will have a 3-tier hierarchy (Consortium/System/Branch), where System has a depth of 1 and Branch has a depth of 2. If this setting contains a depth of 1 in such an installation, then every library in the System in which the Original Location belongs will be visible, and everything else will be hidden. A depth of 0 will effectively make every org visible. The embedded OPAC in the staff client ignores this setting.">
<!ENTITY staff.server.admin.org_settings.ui.circ.show_billing_tab_on_bills "Show billing tab first when bills are present">
<!ENTITY staff.server.admin.org_settings.ui.circ.show_billing_tab_on_bills.desc "If enabled and a patron has outstanding bills and the alert page is not required, show the billing tab by default, instead of the checkout tab, when a patron is loaded">
<!ENTITY staff.server.admin.org_settings.ui.circ.patron_display_timeout_interval "GUI: Patron display timeout interval">
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/js/depth_selector.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/js/depth_selector.js 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/js/depth_selector.js 2010-08-13 18:42:43 UTC (rev 17216)
@@ -78,6 +78,7 @@
var type;
if (location) type = findOrgType(location.ou_type());
+ var orgHiding = checkOrgHiding();
while( type && location ) {
var n = node.cloneNode(true);
n.setAttribute("value", type.depth());
@@ -85,8 +86,14 @@
n.appendChild(text(type.opac_label()));
selector.appendChild(n);
location = findOrgUnit(location.parent_ou());
- if(location) type = findOrgType(location.ou_type());
- else type = null;
+ if(location) {
+ type = findOrgType(location.ou_type());
+ if (orgHiding && orgHiding.depth > type.depth()) {
+ type = null;
+ }
+ } else {
+ type = null;
+ }
}
selector.appendChild(node);
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/js/myopac.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/js/myopac.js 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/js/myopac.js 2010-08-13 18:42:43 UTC (rev 17216)
@@ -21,6 +21,12 @@
function myOPACInit() {
+ var orgHiding = checkOrgHiding();
+ if (orgHiding) {
+ hideMe($('prefs_def_location_row'));
+ hideMe($('prefs_def_range_row'));
+ }
+
if(!(G.user && G.user.session)) {
initLogin();
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js 2010-08-13 18:42:43 UTC (rev 17216)
@@ -42,6 +42,8 @@
var rdetailStart = null;
var rdetailEnd = null;
+var orgHiding = false;
+
/* serials are currently the only use of Dojo strings in the OPAC */
if (rdetailDisplaySerialHoldings) {
dojo.require("dijit.Menu");
@@ -736,6 +738,14 @@
if(!isXUL() && !isTrue(node.opac_visible())) return;
+ if (orgHiding) {
+ if (isTrue( findOrgType(node.ou_type()).can_have_vols() )) {
+ if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) {
+ return;
+ }
+ }
+ }
+
var row = copyRow.cloneNode(true);
row.id = "cp_info_" + node.id();
@@ -785,6 +795,8 @@
removeChildren(copyRowParent);
+ orgHiding = checkOrgHiding();
+
_rdetailRows();
var summary = r.getResultObject();
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/js/result_common.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/js/result_common.js 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/js/result_common.js 2010-08-13 18:42:43 UTC (rev 17216)
@@ -631,7 +631,17 @@
var ccell = $n(countsrow, config.names.result.count_cell);
var nodes = orgNodeTrail(findOrgUnit(getLocation()));
- var node = nodes[0];
+ var start_here = 0;
+ var orgHiding = checkOrgHiding();
+ if (orgHiding) {
+ for (var i = 0; i < nodes.length; i++) {
+ if (orgHiding.depth == findOrgDepth(nodes[i])) {
+ start_here = i;
+ }
+ }
+ }
+
+ var node = nodes[start_here];
var type = findOrgType(node.ou_type());
ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
ccell.title = type.opac_label();
@@ -652,10 +662,10 @@
resultCCHeaderApplied = true;
}
- if(nodes[1]) {
+ if(nodes[start_here+1]) {
- var x = 1;
- var d = findOrgDepth(nodes[1]);
+ var x = start_here+1;
+ var d = findOrgDepth(nodes[start_here+1]);
var d2 = findOrgDepth(nodes[nodes.length -1]);
for( var i = d; i <= d2 ; i++ ) {
@@ -732,20 +742,22 @@
var i = 0;
while(copy_counts[i] != null) {
var cell = $("copy_count_cell_" + i +"_" + pagePosition);
- var cts = copy_counts[i];
- cell.appendChild(text(cts.available + " / " + cts.count));
+ if (cell) {
+ var cts = copy_counts[i];
+ cell.appendChild(text(cts.available + " / " + cts.count));
- if(isXUL()) {
- /* here we style opac-invisible records for xul */
+ if(isXUL()) {
+ /* here we style opac-invisible records for xul */
- if( cts.depth == 0 ) {
- if(cts.transcendant == null && cts.unshadow == 0) {
- _debug("found an opac-shadowed record: " + rec.doc_id());
- var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode;
- if( cts.count == 0 )
- addCSSClass( row, 'no_copies' );
- else
- addCSSClass( row, 'shadowed' );
+ if( cts.depth == 0 ) {
+ if(cts.transcendant == null && cts.unshadow == 0) {
+ _debug("found an opac-shadowed record: " + rec.doc_id());
+ var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode;
+ if( cts.count == 0 )
+ addCSSClass( row, 'no_copies' );
+ else
+ addCSSClass( row, 'shadowed' );
+ }
}
}
}
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml 2010-08-13 18:42:43 UTC (rev 17216)
@@ -56,7 +56,7 @@
</tr>
- <tr>
+ <tr id='prefs_def_location_row'>
<td>&myopac.prefs.search.location;</td>
<td>
<div style='margin-bottom: 5px;'>
@@ -71,7 +71,7 @@
</td>
</tr>
- <tr>
+ <tr id='prefs_def_range_row'>
<td>&myopac.prefs.search.range;</td>
<td>
<select id='prefs_def_range'>
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml 2010-08-13 18:15:46 UTC (rev 17215)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml 2010-08-13 18:42:43 UTC (rev 17216)
@@ -225,6 +225,11 @@
desc : '&staff.server.admin.org_settings.opac.allow_pending_address.desc;',
type : 'bool'
},
+ 'opac.org_unit_hiding.depth' : {
+ label : '&staff.server.admin.org_settings.opac.org_unit_hiding.depth;',
+ desc : '&staff.server.admin.org_settings.opac.org_unit_hiding.depth.desc;',
+ type : 'integer'
+ },
'circ.holds_fifo' : {
label : 'Holds: FIFO',
desc : 'Force holds to a more strict First-In, First-Out capture',
More information about the open-ils-commits
mailing list