30b62c9240f4136e4b92c2606a786c2da8f77241 galt Fri Jan 31 16:40:57 2020 -0800 little more optimization diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c index 42dd8ec..89cb7cd 100644 --- src/hg/lib/tablesTables.c +++ src/hg/lib/tablesTables.c @@ -397,81 +397,72 @@ void (*addFunc)(int), char *initialWhere) /* 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 (withFilters || visibleFacetList) showTableFilterInstructionsEtc(table, itemPlural, largerContext, addFunc, visibleFacetList); // Show top bar with quick-deselects for selected facet values // as well a clear restriction button that cleans out cdwFile_filter cart var. -boolean haveSelectedValues = FALSE; -// pre-scan to see if we will have any selected values. - { - struct slName *nameList = slNameListFromComma(visibleFacetList); - int f; - for (f = 0; f < table->fieldCount; ++f) - { - struct facetField *field = ffArray[f]; - if (slNameInListUseCase(nameList, field->fieldName)) // i.e. is this field a visible facet? - { - if (!field->allSelected) - { - haveSelectedValues = TRUE; - } - } - } - } -if (visibleFacetList && (!isEmpty(initialWhere) || haveSelectedValues)) +if (visibleFacetList) { - // left column - printf("
\n"); if (!isEmpty(initialWhere)) { + // left column + printf("
\n"); printf("Restricting files to where %s. ", initialWhere); printf("  "); printf(""); jsOnEventById("click", "clearRestrictionButton", "$(':input').not(':button, :submit, :reset, :hidden, :checkbox, :radio').val('');\n" "$('[name=cdwBrowseFiles_page]').val('1');\n" "$('[name=clearRestriction]').val('1');\n" "$('#submit').click();\n"); printf("
"); } - if (haveSelectedValues) - { - htmlPrintf("
\n"); + boolean gotSelected = FALSE; struct slName *nameList = slNameListFromComma(visibleFacetList); int f; for (f = 0; f < table->fieldCount; ++f) { struct facetField *field = ffArray[f]; if (slNameInListUseCase(nameList, field->fieldName)) // i.e. is this field a visible facet? { if (!field->allSelected) { + if (!gotSelected) + { + if (isEmpty(initialWhere)) // we still need to do this + { + // left column + printf("
\n"); + } + htmlPrintf("
\n"); + gotSelected = TRUE; + } htmlPrintf("\n"); htmlPrintf("
\n"); htmlPrintf("
%s
\n", field->fieldName); 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) @@ -491,33 +482,34 @@ op, field->fieldName, val->val ); htmlPrintf("%s (%d)", val->val, val->selectCount); printf("\n"); } } slFreeList(&valListCopy); htmlPrintf("
\n"); } } } + if (gotSelected) htmlPrintf("
\n"); - } + if (!isEmpty(initialWhere) || gotSelected) printf("

\n"); } printf("
\n"); // parent container if (visibleFacetList) { // left column printf("
\n"); // reset all facet value selections char *op = "resetAll"; htmlPrintf("