84769302d77939430b003999bd6397ecc64207b5 galt Fri Feb 7 15:33:28 2020 -0800 CIRM cdwWebBrowse: Placing the Clear-All-Facets button in a more logical location. Now only visble if some facets have been chosen. diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c index dab9121..77e170c 100644 --- src/hg/lib/tablesTables.c +++ src/hg/lib/tablesTables.c @@ -393,147 +393,152 @@ boolean withFilters, char *itemPlural, int pageSize, struct fieldedTableSegment *largerContext, struct hash *suggestHash, struct facetField **ffArray, char *visibleFacetList, 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 (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. - if (visibleFacetList) { - char *where = cartUsualString(cart, "cdwFile_filter", ""); - if (!isEmpty(where)) - { - // left column - printf("
\n"); + // Show top bar with quick-deselects for selected facet values + // as well a clear restriction button that cleans out cdwFile_filter cart var. - printf("Restricting files to where %s. ", where); + struct dyString *facetBar = dyStringNew(1024); - printf("  "); - printf(""); - jsOnEventById("click", "clearRestrictionButton", - "$('[name=cdwBrowseFiles_page]').val('1');\n" - "$('[name=clearRestriction]').val('1');\n" - "$('#submit').click();\n"); + char *where = cartUsualString(cart, "cdwFile_filter", ""); - printf("
"); - } 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(where)) // we still need to do this - { - // left column - printf("
\n"); - } - htmlPrintf("
\n"); gotSelected = TRUE; - } - htmlPrintf("\n"); - htmlPrintf("
\n"); - htmlPrintf("
%s
\n", field->fieldName); + htmlDyStringPrintf(facetBar, "\n"); + htmlDyStringPrintf(facetBar, "
\n"); + htmlDyStringPrintf(facetBar, "
%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) { char *op = "remove"; - printf("
\n"); - htmlPrintf(" ", + htmlDyStringPrintf(facetBar, "
\n"); + htmlDyStringPrintf(facetBar, " ", specificallySelected ? "true" : "false", specificallySelected ? "checked" : ""); - htmlPrintf("", cartSessionVarName(), cartSessionId(cart), op, field->fieldName, val->val ); - htmlPrintf("%s (%d)", val->val, val->selectCount); - printf("
\n"); + htmlDyStringPrintf(facetBar, "%s (%d)", val->val, val->selectCount); + htmlDyStringPrintf(facetBar, "\n"); } } slFreeList(&valListCopy); - htmlPrintf("
\n"); + htmlDyStringPrintf(facetBar, "
\n"); } } } - if (gotSelected) - htmlPrintf("
\n"); - if (!isEmpty(where) || gotSelected) - printf("

\n"); - + { + printf("
\n"); } -printf("
\n"); // parent container - -if (visibleFacetList) + if (!isEmpty(where)) { - // left column - printf("
\n"); - // reset all facet value selections + printf("Restricting files to where %s. ", where); + + printf("  "); + printf(""); + jsOnEventById("click", "clearRestrictionButton", + "$('[name=cdwBrowseFiles_page]').val('1');\n" + "$('[name=clearRestriction]').val('1');\n" + "$('#submit').click();\n"); + + printf("
"); + } + + + if (gotSelected) + { + // reset all facet value selections button char *op = "resetAll"; htmlPrintf("%s

\n", + ">%s\n", cartSessionVarName(), cartSessionId(cart), op, "", "", "Clear All" ); + printf("
\n"); + printf("%s\n", facetBar->string); + printf("
\n"); + } + + if (!isEmpty(where) || gotSelected) + printf("

\n"); + + dyStringFree(&facetBar); + } + +printf("
\n"); // parent container + +if (visibleFacetList) + { + + // left column + printf("
\n"); + 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? { htmlPrintf("
\n"); htmlPrintf("
%s
\n", field->fieldName); struct facetVal *val; if (!field->allSelected) // add reset facet link { char *op = "reset"; htmlPrintf("