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("<div>\n"); if (!isEmpty(initialWhere)) { + // left column + printf("<div>\n"); printf("Restricting files to where %s. ", initialWhere); printf("  "); printf("<input class='btn btn-secondary' type='button' id='clearRestrictionButton' VALUE=\"Clear Restriction\">"); 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("<br>"); } - if (haveSelectedValues) - { - htmlPrintf("<dl style='display: inline-block;'>\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("<div>\n"); + } + htmlPrintf("<dl style='display: inline-block;'>\n"); + gotSelected = TRUE; + } htmlPrintf("<span class='card facet-card' style='display: inline-block;'><span class='card-body'>\n"); htmlPrintf("<dt style='display: inline-block;'>\n"); htmlPrintf("<h6 class='card-title'>%s</h6></dt>\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)</a>", val->val, val->selectCount); printf("</dd>\n"); } } slFreeList(&valListCopy); htmlPrintf("</span></span>\n"); } } } + if (gotSelected) htmlPrintf("</dl>\n"); - } + if (!isEmpty(initialWhere) || gotSelected) printf("</div><br>\n"); } printf("<div class='row'>\n"); // parent container if (visibleFacetList) { // left column printf("<div class='col-xs-6 col-sm-4 col-md-4 col-lg-3 col-xl-3'>\n"); // reset all facet value selections char *op = "resetAll"; htmlPrintf("<a class='btn btn-secondary' href='../cgi-bin/cdwWebBrowse?%s=%s|url|&cdwCommand=browseFiles"