19e6e03d64ce54f9db60a93734cd3b573eb0446b
kent
  Fri Jan 29 09:07:37 2021 -0800
I believe I got all the faceted variables using the varPrefix.  Tested this by having two faceted tables on the same page and it worked.  Looks clean by cartDump too.

diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c
index 93bf7f0..5b3a61a 100644
--- src/hg/lib/tablesTables.c
+++ src/hg/lib/tablesTables.c
@@ -412,37 +412,38 @@
     void (*addFunc)(int) )
 /* Show a fielded table that can be sorted by clicking on column labels and optionally
  * that includes a row of filter controls above the labels .
  * The maxLenField is maximum character length of field before truncation with ...
  * Pass in 0 for no max. */
 {
 if (strchr(returnUrl, '?') == NULL)
      errAbort("Expecting returnUrl to include ? in showFieldedTable\nIt's %s", returnUrl);
 
 if (pluralInstructions != NULL)
     showTableFilterInstructionsEtc(table, pluralInstructions, largerContext, addFunc, 
 	    visibleFacetList, varPrefix);
 
 if (visibleFacetList)
     {
-
     // Show top bar with quick-deselects for selected facet values
-    //  as well a clear restriction button that cleans out cdwFile_filter cart var. 
+    //  as well a clear restriction button that cleans out _filter cart var. 
 
     struct dyString *facetBar = dyStringNew(1024);
+    char filterVar[256];
+    safef(filterVar, sizeof(filterVar), "%s_filter", varPrefix);
 
-    char *where = cartUsualString(cart, "cdwFile_filter", "");
+    char *where = cartUsualString(cart, filterVar, "");
 
 
     boolean gotSelected = FALSE;
 
     struct slName *visList = slNameListFromComma(visibleFacetList);
     struct slName *vis;
     for (vis = visList; vis != NULL; vis = vis->next)
 	{
 	int f = fieldedTableMustFindFieldIx(table, vis->name);
 	struct facetField *field = ffArray[f];
 	if (!field->allSelected)
 	    {
 	    gotSelected = TRUE;
 	    htmlDyStringPrintf(facetBar, "<span class='card facet-card' style='display: inline-block;'><span class='card-body'>\n");
 	    htmlDyStringPrintf(facetBar, "<dt style='display: inline-block;'>\n");
@@ -450,31 +451,31 @@
 
 	    struct facetVal *val;
 
 	    // Sort values alphabetically
 	    // Make a copy to not disturb the original order 
 	    struct facetVal *valListCopy = facetsClone(field->valList);
 	    slSort(&valListCopy, facetValCmp);
 	    
 	    for (val = valListCopy; val; val=val->next)
 		{
 		boolean specificallySelected = (val->selected && !field->allSelected);
 		if (specificallySelected)
 		    {
 		    char *op = "remove";
 		    htmlDyStringPrintf(facetBar, "<dd class=\"facet\" style='display: inline-block;'>\n");
-		    htmlDyStringPrintf(facetBar, "<input type=checkbox value=%s class=cdwFSCheckBox %s>&nbsp;",
+		    htmlDyStringPrintf(facetBar, "<input type=checkbox value=%s class=ttFsCheckBox %s>&nbsp;",
 			specificallySelected ? "true" : "false", 
 			specificallySelected ? "checked" : "");
 		    htmlDyStringPrintf(facetBar, "<a href='%s"
 			    "&%s_facet_op=%s|url|"
 			    "&%s_facet_fieldName=%s|url|"
 			    "&%s_facet_fieldVal=%s|url|"
 			    "&%s_page=1' "
 			    ">",
 			returnUrl, varPrefix,
 			op, varPrefix, field->fieldName, varPrefix, val->val, varPrefix
 			);
 		    htmlDyStringPrintf(facetBar, "%s (%d)</a>", val->val, val->selectCount);
 		    htmlDyStringPrintf(facetBar, "</dd>\n");
 		    }
 		}
@@ -572,31 +573,31 @@
 	if (field->showAllValues)  // Sort alphabetically if they want all values 
 	    {
 	    slSort(&field->valList, facetValCmp);
 	    }
 	for (val = field->valList; val; val=val->next)
 	    {
 	    boolean specificallySelected = (val->selected && !field->allSelected);
 	    if ((val->selectCount > 0 && (field->showAllValues || valuesShown < facetUsualSize))
 		|| specificallySelected)
 		{
 		++valuesShown;
 		char *op = "add";
 		if (specificallySelected)
 		    op = "remove";
 		printf("<dd class=\"facet\">\n");
-		htmlPrintf("<input type=checkbox value=%s class=cdwFSCheckBox %s>&nbsp;",
+		htmlPrintf("<input type=checkbox value=%s class=ttFSCheckBox %s>&nbsp;",
 		    specificallySelected ? "true" : "false", 
 		    specificallySelected ? "checked" : "");
 		htmlPrintf("<a href='%s"
 			"&%s_facet_op=%s|none|"
 			"&%s_facet_fieldName=%s|url|"
 			"&%s_facet_fieldVal=%s|url|"
 			"&%s_page=1' "
 			">",
 		    returnUrl, varPrefix,
 		    op, varPrefix, field->fieldName, varPrefix, val->val, varPrefix
 		    );
 		htmlPrintf("%s (%d)</a>", val->val, val->selectCount);
 		printf("</dd>\n");
 		}
 	    else if (val->selectCount > 0)
@@ -628,31 +629,31 @@
 		    "&%s_facet_op=%s|url|"
 		    "&%s_facet_fieldName=%s|url|"
 		    "&%s_facet_fieldVal=%s|url|"
 		    "&%s_page=1' "
 		    ">%s</a></dd>\n",
 		returnUrl, varPrefix, op, varPrefix, field->fieldName, varPrefix, "", varPrefix,
 		"See Fewer"
 		);
 	    }
 	htmlPrintf("</div></div>\n");
 	}
     printf("</div>\n");
     // Clicking a checkbox is actually a click on the following link
     jsInlineF(
 	"$(function () {\n"
-	"  $('.cdwFSCheckBox').click(function() {\n"
+	"  $('.ttFsCheckBox').click(function() {\n"
 	"    this.nextSibling.nextSibling.click();\n"
 	"  });\n"
 	"});\n");
     }
 
 // start right column, if there are two columns
 if (visibleFacetList)
     printf("<div class='col-xs-6 col-sm-8 col-md-8 col-lg-9 col-xl-9'>\n");
 else
     printf("<div class='col-12'>\n");
     
 printf("  <div>\n");
 if (visibleFieldList != NULL)
     {
     struct slName *fieldList = slNameListFromComma(visibleFieldList);
@@ -845,36 +846,38 @@
  * separate clauses, construct and display an HTML table around results. Optionally table
  * may have a faceted search to the left or fields that can filter under the labels.  The table 
  * has column names that will sort the table, and optionally (if withFilters is set)
  * it will also allow field-by-field wildcard queries on a set of controls it draws above
  * the labels. 
  *    Much of the functionality rests on the call to webFilteredFieldedTable.  This function
  * does the work needed to bring in sections of potentially huge results sets into
  * the fieldedTable. */
 {
 struct dyString *query;
 struct dyString *where;
 struct dyString *fusedFields = fuseCsvFields(conn, from, fields, visibleFacetList);
 webTableBuildQuery(cart, from, initialWhere, varPrefix, 
     fusedFields->string, withFilters, &query, &where);
 
-char *selectedFacetValues=cartUsualString(cart, "cdwSelectedFieldValues", "");
+char selListVar[256];
+safef(selListVar, sizeof(selListVar), "%s_facet_selList", varPrefix);
+char *selectedFacetValues=cartUsualString(cart, selListVar, "");
 
 struct facetField **ffArray = NULL;
 struct fieldedTable *table = NULL;
 
-char pageVar[64];
+char pageVar[256];
 safef(pageVar, sizeof(pageVar), "%s_page", varPrefix);
 int page = 0;
 struct fieldedTableSegment context;
 page = cartUsualInt(cart, pageVar, 0) - 1;
 if (page < 0)
     page = 0;
 context.tableOffset = page * pageSize;
 
 if (visibleFacetList)
     {
     table = fieldedTableAndCountsFromDbQuery(conn, query->string, pageSize, 
 	context.tableOffset, selectedFacetValues, &ffArray, &context.tableSize);
     }
 else
     {