420f3d256e332531c49df90c76fd4a303d2d8137
tdreszer
  Mon Nov 29 14:04:39 2010 -0800
Made filterComposite work with matrix.
diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index da294d7..45c059e 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -6144,36 +6144,37 @@
 freeMem(vocab);
 return dyStringCannibalize(&dyLink);
 }
 
 static boolean hCompositeUiByFilter(char *db, struct cart *cart, struct trackDb *parentTdb, char *formName)
 /* UI for composite tracks: filter subgroups by multiselects to select subtracks. */
 {
 membersForAll_t* membersForAll = membersForAllSubGroupsGet(parentTdb,cart);
 if(membersForAll == NULL || membersForAll->filters == FALSE) // Not Matrix or filters
     return FALSE;
 jsIncludeFile("ui.core.js",NULL);
 jsIncludeFile("ui.dropdownchecklist.js",NULL);
 webIncludeResourceFile("ui.dropdownchecklist.css");
 
 // TODO:
-// 1) Make this work with matrix
-// 2) Scroll long lists should be configurable through tdb setting
+// 1) Scroll long lists should be configurable through tdb setting
 //    #define FILTER_COMPOSITE_OPEN_SIZE 16
-// 3) columnCount (Number of filterBoxes per row) should be configurable through tdb setting
+// 2) columnCount (Number of filterBoxes per row) should be configurable through tdb setting
 
-printf("<B>Filter subtracks by:</B> (select multiple %sitems - %s)<BR>\n",(membersForAll->dimMax == dimA?"":"categories and "),FILTERBY_HELP_LINK);
+printf("<B>Filter subtracks %sby:</B> (select multiple %sitems - %s)<BR>\n",
+       (membersForAll->members[dimX] != NULL || membersForAll->members[dimY] != NULL ? "further ":""),
+       (membersForAll->dimMax == dimA?"":"categories and "),FILTERBY_HELP_LINK);
 printf("<TABLE><TR valign='top'>\n");
 
 // Do All [+][-] buttons
 if(membersForAll->members[dimX] == NULL && membersForAll->members[dimY] == NULL) // No matrix
     {
     #define PM_BUTTON_FILTER_COMP "<input type='button' class='inOutButton' onclick=\"waitOnFunction(filterCompositeSet,this,%s); return false;\" id='btn_%s' value='%c'>"
     printf("<TD align='left' width='50px'><B>All:</B><BR>");
     printf(PM_BUTTON_FILTER_COMP,"true",  "plus_fc",'+');
     printf(PM_BUTTON_FILTER_COMP,"false","minus_fc",'-');
     //#define PM_BUTTON2_FILTER_COMP "<IMG height=18 width=18 onclick=\"filterCompositeSet(%s);\" id='btn_%s' src='../images/%s'>"
     //printf(PM_BUTTON2_FILTER_COMP,"true",  "plus_fc",   "add_sm.gif");
     //printf(PM_BUTTON2_FILTER_COMP,"false","minus_fc","remove_sm.gif");
     printf("</TD>\n");
     }
 
@@ -6274,55 +6275,60 @@
             cells[ixX][ixY]++;
             int fourState = subtrackFourStateChecked(subtrack,cart);
             if(fourStateEnabled(fourState))  // hidden views are handled by 4-way CBs: only count enabled
                 {
                 if(subtrackInAllCurrentABCs(subtrack,membersForAll))  // Only bother if the subtrack is found in all ABC dims checked
                     {
                     enabd[ixX][ixY]++;
                     if(fourStateChecked(fourState) == 1)
                         chked[ixX][ixY]++;
                     }
                 }
             }
         }
     }
 
-if(!hCompositeUiByFilter(db, cart, parentTdb, formName))
+// If there is no matrix and if there is a filterComposite, then were are done.
+if(dimensionX == NULL && dimensionY == NULL)
     {
+    if (hCompositeUiByFilter(db, cart, parentTdb, formName))
+        return FALSE;
+    }
+
+// Tell the user what to do:
     char javascript[JBUFSIZE];
     //puts("<B>Select subtracks by characterization:</B><BR>");
     printf("<B>Select subtracks by ");
     if(dimensionX && !dimensionY)
         safef(javascript, sizeof(javascript), "%s:</B>",dimensionX->groupTitle);
     else if(!dimensionX && dimensionY)
         safef(javascript, sizeof(javascript), "%s:</B>",dimensionY->groupTitle);
     else if(dimensionX && dimensionY)
         safef(javascript, sizeof(javascript), "%s and %s:</B>",dimensionX->groupTitle,dimensionY->groupTitle);
     else
         safef(javascript, sizeof(javascript), "multiple variables:</B>");
     puts(strLower(javascript));
 
     if(!subgroupingExists(parentTdb,"view"))
         puts("(<A HREF=\"../goldenPath/help/multiView.html\" title='Help on subtrack selection' TARGET=_BLANK>help</A>)\n");
 
     puts("<BR>\n");
 
-    if(membersForAll->abcCount > 0)
+if(membersForAll->abcCount > 0 && membersForAll->filters == FALSE)
         {
         displayABCdimensions(db,cart,parentTdb,subtrackRefList,membersForAll);
         }
-    }
 
 if(dimensionX == NULL && dimensionY == NULL) // Could have been just filterComposite. Must be an X or Y dimension
     return FALSE;
 
 printf("<TABLE class='greenBox' bgcolor='%s' borderColor='%s'>\n",COLOR_BG_DEFAULT,COLOR_BG_DEFAULT);
 
 matrixXheadings(db,parentTdb,membersForAll,TRUE);
 
 // Now the Y by X matrix
 int cntX=0,cntY=0;
 for (ixY = 0; ixY < sizeOfY; ixY++)
     {
     if(dimensionY == NULL || (dimensionY->tags[ixY]))
         {
         cntY++;
@@ -6403,30 +6409,33 @@
                     //puts("<TD>&nbsp;</TD>");
                     }
                 }
             }
         if(dimensionX && cntX>MATRIX_RIGHT_BUTTONS_AFTER)
             matrixYheadings(db,parentTdb, membersForAll,ixY,FALSE);
         puts("</TR>\n");
         }
     }
 if(dimensionY && cntY>MATRIX_BOTTOM_BUTTONS_AFTER)
     matrixXheadings(db,parentTdb,membersForAll,FALSE);
 
 puts("</TD></TR></TABLE>");
 puts("<BR>\n");
 
+// If any filter additional filter composites, they can be added at the end.
+hCompositeUiByFilter(db, cart, parentTdb, formName);
+
 return TRUE;
 }
 
 static boolean hCompositeUiAllButtons(char *db, struct cart *cart, struct trackDb *parentTdb, char *formName)
 /* UI for composite tracks: all/none buttons only (as opposed to matrix or lots of buttons */
 {
 if (trackDbCountDescendantLeaves(parentTdb) <= 1)
     return FALSE;
 
 if(dimensionsExist(parentTdb))
     return FALSE;
 
 #define PM_BUTTON_GLOBAL "<IMG height=18 width=18 onclick=\"matSubCBsCheck(%s);\" id='btn_%s' src='../images/%s'>"
 #define    BUTTON_PLUS_ALL_GLOBAL()  printf(PM_BUTTON_GLOBAL,"true",  "plus_all",   "add_sm.gif")
 #define    BUTTON_MINUS_ALL_GLOBAL() printf(PM_BUTTON_GLOBAL,"false","minus_all","remove_sm.gif")