From f62dc28df9dd18c7a62e3b9d730c6c2c3bb53db0 Mon Sep 17 00:00:00 2001
From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 7 Apr 2010 14:55:14 +0000
Subject: [PATCH] safer still metarecord constituent type/form matching

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16155 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/web/opac/skin/default/js/holds.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Open-ILS/web/opac/skin/default/js/holds.js b/Open-ILS/web/opac/skin/default/js/holds.js
index d2d153df8d..4c7c1697c3 100644
--- a/Open-ILS/web/opac/skin/default/js/holds.js
+++ b/Open-ILS/web/opac/skin/default/js/holds.js
@@ -584,6 +584,7 @@ function holdsSetFormatSelector() {
 	for( var i = 0; i < avail_formats.length; i++ ) {
 		var form = avail_formats[i];
 		var opt = findFormatSelectorOptByParts(selector,form);
+        if (!opt) continue;
 		if(type=='M') opt.selected=true;
 		unHideMe(opt);
 	}
@@ -595,7 +596,7 @@ function findFormatSelectorOptByParts( sel, val ) {
         var opt = sel.options[i];
         var oval = opt.value;
         var oparts = oval.split('-');
-        if( oparts[0].indexOf(parts[0]) > -1 && ((!oparts[1] && !parts[1]) || (oparts[1].indexOf(parts[1]) > -1)) ) return opt;
+        if( oparts[0].indexOf(parts[0]) > -1 && (!parts[1] || oparts[1].indexOf(parts[1]) > -1) ) return opt;
     }
     return null;
 }
@@ -650,8 +651,7 @@ function holdsGetFormats() {
 function _t_f_2_format(type, form) {
 	if( (type == 'a' || type == 't') && form == 's' ) return 'at-s';
 	if( form == 'd' ) return 'at-d';
-	return (type == 'a' || type == 't') ? 'at' : 
-		( type == 'i' || type == 'g' || type == 'j' ) ? type : null;
+	return (type == 'a' || type == 't') ? 'at' : type;
 }
 
 function holdsSetSelectedFormats() {
-- 
2.11.0