34dac715181e69197f764d512b19f3ff1de88886
tdreszer
  Fri Jan 20 16:05:34 2012 -0800
Allow the unexpected case of a composite of tracks that cannot be packed.  HapMap LD Phased is that case.  Now if the composite has no dense/squish options then none of the children can. 4665
diff --git src/hg/js/subCfg.js src/hg/js/subCfg.js
index 275b2c4..7ffbb9f 100644
--- src/hg/js/subCfg.js
+++ src/hg/js/subCfg.js
@@ -22,30 +22,31 @@
 // - DECIDED: When parent vis makes subs hidden, should they go to unchecked?   No, disabled!
 // - DECIDED: Should user be able to click on disabled vis to check the CB?  No, not important.
 // - DECIDED: Make vis changes "reshape" composite!  NO, I am against this as too disruptive.  We may want to end reshaping in CGIs as well!
 // - Verified all composites work (hg19 hg18 mm9 mm8 panTro3 galGal3 braFlo1 dm3 ce10 homPan20 sacCer3 hg19Patch5 tested so far)
 // - Speed up massive composites!  HAIB TFBS SYDH TFBS
 // - subVis DOES NOT set compVis to full (when compVis set to hide, but subVis already populated) OK because this slips towords reshaping.
 // NOTE:
 // Current implementation relies upon '.' delimiter in name and no '_-' in name.  Nothing breaks rule yet...
 // Can remove "DEBUG" messages when fully QA'd.  They are asserts.
 
 var subCfg = { // subtrack config module.
     //mySelf: null, // There is no need for a "mySelf" unless this object is being instantiated.
 
     // There is one instance and these vars are page wide
     compositeName: undefined,
+    canPack: true,  // if composite vis is only hide,dense,full, then all children will also be restricted.
     visIndependent: false,
     viewTags: [],
 
     markChange: function (eventObj, obj)
     { // Marks a control as having been changed by the user.  Naming will send value to cart.
       // Note this is often called directly as the onchange event function
         if (obj == undefined || $.type(obj) === "string")
             obj = this;
         $(obj).addClass('changed');
 
         // checkboxes have hidden boolshads which should be marked when unchecked
         if(obj.type === "checkbox") {
             var boolshad = normed($("input.cbShadow[name='boolshad\\." + obj.name+"']"));
             if (boolshad != undefined) {
                 $(boolshad).addClass('changed');
@@ -371,33 +372,36 @@
             $(children).each(function (i) {                      // Should never be filterComp
                 $(this).val(parentVal);
                 subCfg.clearChange(this);
                 if (updateDdcl)
                     ddcl.onComplete(this);
             });
         }
     },
 
     propagateViewVis: function (viewObj,compositeVis)
     { // propagate vis from a view limiting with compositeVis
         var limitedVis = Math.min(compositeVis,viewObj.selectedIndex);
         var visText = 'hide';
         if (limitedVis == 1)
             visText = 'dense';
-        else if (limitedVis == 2)
+        else if (limitedVis == 2) {
+            if (subCfg.canPack)
             visText = 'squish';
-        else if (limitedVis == 3)
+            else
+                visText = 'full';
+        } else if (limitedVis == 3)
             visText = 'pack';
         else if (limitedVis == 4)
             visText = 'full';
 
         var children = subCfg.visChildrenFind(viewObj);
         $(children).each(function (i) {
             if ($(this).hasClass('fauxInput')) {
                 $(this).text(visText);
             } else {
                 $(this).attr('selectedIndex',limitedVis);
                 subCfg.clearChange(this);
             }
         });
     },
 
@@ -405,33 +409,36 @@
     { // propagate vis settings to subtrack children
         if (viewTag == undefined) {
             // Walk through views and set with this
             var parentVis = parentObj.selectedIndex;
             if (subCfg.viewTags.length > 0) {
                 for (var ix=0;ix<subCfg.viewTags.length;ix++) {
                     var viewObj = subCfg.viewObjFind(subCfg.viewTags[ix]);//,undefined);
                     if (viewObj != undefined)
                         subCfg.propagateViewVis(viewObj,parentVis);
                 }
             } else { // No view so, simple
 
                 var visText = 'hide';
                 if (parentVis == 1)
                     visText = 'dense';
-                else if (parentVis == 2)
+                else if (parentVis == 2) {
+                    if (subCfg.canPack)
                     visText = 'squish';
-                else if (parentVis == 3)
+                    else
+                        visText = 'full';
+                } else if (parentVis == 3)
                     visText = 'pack';
                 else if (parentVis == 4)
                     visText = 'full';
                 var children = subCfg.visChildrenFind(parentObj);
                 $(children).each(function (i) {
                     if ($(this).hasClass('fauxInput')) {
                         $(this).text(visText);
                     } else {
                         $(this).attr('selectedIndex',parentVis);
                         subCfg.clearChange(this);
                     }
                 });
             }
         } else {
             // First get composite vis to limit with
@@ -597,40 +604,42 @@
         });
     },
 
     replaceWithVis: function (obj,subtrack,open)
     { // Replaces the current fauxVis object with a true visibility selector
 
         if ($(obj).hasClass('disabled'))
             return;
         var classList = $( obj ).attr("class").split(" ");
         classList = aryRemove(classList,["disabled"]);
         var view = classList[classList.length - 1]; // This relies on view being the last class!!!
         var selectHtml  = "<SELECT name='"+subtrack+"' class='normalText subVisDD "+view+"'";
             selectHtml += " style='width:70px;'>";
         var selected = $(obj).text();
         var visibilities = ['hide','dense','squish','pack','full'];
+        if (subCfg.canPack == false)
+            visibilities = ['hide','dense','full'];
         $(visibilities).each( function (ix) {
              selectHtml += "<OPTION"+(visibilities[ix] == selected ? " SELECTED":"")+">";
              selectHtml += visibilities[ix]+"</OPTION>";
         });
         selectHtml += "</SELECT>";
         $(obj).replaceWith(selectHtml);
         var newObj = $("select[name='"+subtrack+"']");
         if (open) {
             $(newObj).css({'zIndex':'2','vertical-align':'top'});
-            $(newObj).attr('size',5);
+            $(newObj).attr('size',visibilities.length);
             $(newObj).one('blur',function (e) {
                 $(this).attr('size',1);
                 $(this).unbind('click');
             });
             $(newObj).one('click',function (e) {
                 $(this).attr('size',1);
                 $(this).unbind('blur');
             });
             $(newObj).focus();
         }
         $(newObj).change(function (e) {
             if ($(this).attr('size') > 1) {
                 $(this).attr('size',1);
                 $(this).unbind('blur');
                 $(this).unbind('click');
@@ -754,30 +763,32 @@
 
     initialize: function ()
     { // sets up all composite controls and then all view controls
       // onchange gets set to mark controls as 'changed'.  Unchanged controls will
       // be disabled on 'submit'.  Disabled controls will not get to the cart!
 
         var compVis = $('.visDD');
         if (compVis == undefined || compVis.length < 1) {
             warn('DEBUG: Did not find visibility control for composite.');
             return;
         }
         if (compVis.length > 1) {
             warn('DEBUG: Multiple visibility controls for composite???');
             return;
         }
+        if ($(compVis).children('option').length < 5)
+            subCfg.canPack = false; // Note that if composite vis has no pack then no child should have pack
 
         subCfg.compositeName = $(compVis).attr('name');
         subCfg.visIndependent = ($('.subVisDD').length > 0);  // Can subtracks have their own vis?
 
         // Set up vis propagation and change flagging
         compVis = compVis[0];
         $(compVis).bind('change',function (e) {
             subCfg.markChange(e,compVis);
             subCfg.propagateVis(compVis,undefined);
         });
 
         // SubCBs will may enable/diable vis/wrench and will be flagged on change
         var subCbs = $('input.subCB');
         $(subCbs).change( function (e) {
             subCfg.enableCfg(this, (this.checked && !isFauxDisabled(this, true)));