aba9ee18d932daaa659dc3298c0ea4db250fc704 tdreszer Tue Aug 24 15:47:41 2010 -0700 Added clear button and fixed bombing simple search, among other things diff --git src/hg/hgTracks/searchTracks.c src/hg/hgTracks/searchTracks.c index 95573ab..447af60 100644 --- src/hg/hgTracks/searchTracks.c +++ src/hg/hgTracks/searchTracks.c @@ -231,6 +231,7 @@ char trixFile[HDB_MAX_PATH_STRING]; char **descWords = NULL; int descWordCount = 0; +boolean searchTermsExist = FALSE; if(sameString(currentTab, "simpleTab")) { @@ -277,10 +278,14 @@ "</ul>\n" "<div id='simpleTab'>\n"); -hPrintf("<input type='text' name='hgt.simpleSearch' id='simpleSearch' value='%s' size='80'>\n", descSearch == NULL ? "" : descSearch); +hPrintf("<input type='text' name='hgt.simpleSearch' id='simpleSearch' value='%s' size='80' onkeyup='findTracksSearchButtonsEnable(true);'>\n", descSearch == NULL ? "" : descSearch); +if (simpleSearch && descSearch) + searchTermsExist = TRUE; -hPrintf("<br><input type='submit' name='%s' id='searchSubmit' value='Search' style='font-size:14px;'>\n", searchTracks); -hPrintf("<input type='submit' name='submit' value='Cancel' style='font-size:14px;'>\n"); +hPrintf("<BR>"); +hPrintf("<input type='submit' name='%s' id='searchSubmit' value='Search' style='font-size:14px;'%s>\n", searchTracks,(searchTermsExist && !doSearch?"":" disabled=true")); +hPrintf("<input type='button' name='clear' value='Clear' class='clear' style='font-size:14px;' onclick='findTracksClear();'%s>\n",(searchTermsExist || doSearch?"":" disabled=true")); +hPrintf("<input type='submit' name='submit' value='Cancel' class='cancel' style='font-size:14px;'>\n"); hPrintf("</div>\n" "<div id='advancedTab'>\n" "<table>\n"); @@ -290,15 +295,21 @@ //char *op_labels[] = {"is", "contains"}; //char *nameOp = cartOptionalString(cart, "hgt.nameOp"); //cgiMakeDropListFull("hgt.nameOp", op_labels, ops, ArraySize(ops), nameOp == NULL ? "contains" : nameOp, NULL); -hPrintf("</td>\n<td><input type='text' name='hgt.nameSearch' id='nameSearch' value='%s'></td></tr>\n", nameSearch == NULL ? "" : nameSearch); +hPrintf("</td>\n<td><input type='text' name='hgt.nameSearch' id='nameSearch' value='%s' onkeyup='findTracksSearchButtonsEnable(true);'></td></tr>\n", nameSearch == NULL ? "" : nameSearch); +if (!simpleSearch && nameSearch) + searchTermsExist = TRUE; hPrintf("<tr><td></td><td></td><td>and</td><td><b>Description:</b></td><td align='right'>contains</td>\n"); -hPrintf("<td><input type='text' name='hgt.descSearch' id='descSearch' value='%s' size='80'></td></tr>\n", descSearch == NULL ? "" : descSearch); +hPrintf("<td><input type='text' name='hgt.descSearch' id='descSearch' value='%s' size='80' onkeyup='findTracksSearchButtonsEnable(true);'></td></tr>\n", descSearch == NULL ? "" : descSearch); +if (!simpleSearch && descSearch) + searchTermsExist = TRUE; hPrintf("<tr><td></td><td></td><td>and</td>\n"); hPrintf("<td><b>Group</b></td><td align='right'>is</td>\n<td>\n"); -cgiMakeDropListFull("hgt.groupSearch", labels, groups, numGroups, groupSearch, NULL); +cgiMakeDropListFull("hgt.groupSearch", labels, groups, numGroups, groupSearch, "class='groupSearch'"); hPrintf("</td></tr>\n"); +if (!simpleSearch && groupSearch) + searchTermsExist = TRUE; // figure out how many metadata selects are visible. @@ -397,19 +408,22 @@ hPrintf("</td><td colspan=2 nowrap>\n"); safef(buf, sizeof(buf), "%s%i", METADATA_NAME_PREFIX, i + 1); cgiMakeDropListClassWithStyleAndJavascript(buf, metaValues, count, metadataName[i], - NULL, NULL, "onchange=metadataSelectChanged(this)"); + "mdbVar", NULL, "onchange=findTracksMdbVarChanged(this)"); hPrintf("is</td>\n<td>\n"); len = getTermArray(conn, &terms, metadataName[i]); safef(buf, sizeof(buf), "%s%i", METADATA_VALUE_PREFIX, i + 1); - cgiMakeDropListFull(buf, terms, terms, len, metadataValue[i], NULL); + cgiMakeDropListFull(buf, terms, terms, len, metadataValue[i], "class='mdbVal' onchange='findTracksSearchButtonsEnable(true)'"); + if(!simpleSearch && metadataValue[i]) + searchTermsExist = TRUE; hPrintf("</td></tr>\n"); } } hPrintf("</table>\n"); -hPrintf("<input type='submit' name='%s' id='searchSubmit' value='Search' style='font-size:14px;'>\n", searchTracks); -hPrintf("<input type='submit' name='submit' value='Cancel' style='font-size:14px;'>\n"); +hPrintf("<input type='submit' name='%s' id='searchSubmit' value='Search' style='font-size:14px;'%s>\n", searchTracks,(searchTermsExist && !doSearch?"":" disabled=true")); +hPrintf("<input type='button' name='clear' value='Clear' class='clear' style='font-size:14px;' onclick='findTracksClear();'%s>\n",(searchTermsExist || doSearch?"":" disabled=true")); +hPrintf("<input type='submit' name='submit' value='Cancel' class='cancel' style='font-size:14px;'>\n"); hPrintf("</div>\n</div>\n"); hPrintf("</form>\n"); @@ -461,9 +475,14 @@ for(tsList = trixSearch(trix, descWordCount, descWords, TRUE); tsList != NULL; tsList = tsList->next) { struct track *track = (struct track *) hashFindVal(trackHash, tsList->itemId); + if(track != NULL) + { refAdd(&tracks, track); tracksFound++; } + //else // FIXME: Should get to the bottom of why some of these are null + // warn("found trix track is NULL."); + } slReverse(&tracks); } else if(!isEmpty(nameSearch) || descSearch != NULL || groupSearch != NULL || numMetadataNonEmpty) @@ -518,9 +537,14 @@ (isEmpty(descSearch) || isDescriptionMatch(track, descWords, descWordCount)) && (!numMetadataNonEmpty || hashLookup(matchingTracks, track->track) != NULL)) { + if(track != NULL) + { tracksFound++; refAdd(&tracks, track); } + else + warn("found group track is NULL."); + } if (track->subtracks != NULL) { struct track *subTrack; @@ -532,9 +556,14 @@ { // XXXX to parent hash. - use tdb->parent instead. hashAdd(parents, subTrack->track, track); + if(track != NULL) + { tracksFound++; refAdd(&tracks, subTrack); } + else + warn("found subtrack is NULL."); + } } } } @@ -545,6 +574,7 @@ } } +hPrintf("<div id='foundTracks' style='display:none;'>\n"); // This div allows the clear button to empty it if(tracksFound < 1) { if(doSearch) @@ -583,6 +613,7 @@ // FIXME: I believe that only data tracks should appear in found tracks. If composite is found, show its children instead int trackCount=0; + boolean containerTrackCount = 0; struct slRef *ptr; while((ptr = slPopHead(&tracks))) { @@ -624,9 +655,13 @@ { checked = fourStateVisible(subtrackFourStateChecked(track->tdb,cart)); // Don't need all 4 states here. Visible=checked&&enabled track->visibility = limitedVisFromComposite(track); + // Must distinguish between subtrack with explicit vis and inherited vis + if (track->visibility != tvHide && NULL == cartOptionalString(cart, track->track)) + { struct trackDb *parentTdb = trackDbCompositeParent(track->tdb); - if(parentTdb != NULL) - track->visibility = tvMin(track->visibility,parentTdb->visibility); + assert(parentTdb != NULL); + track->visibility = tvMin(track->visibility,parentTdb->visibility); // inherited vis must explicitly be filtered by composite. + } checked = (checked && ( track->visibility != tvHide )); // Checked is only if subtrack level vis is also set! // Only subtracks get "_sel" var @@ -656,6 +691,13 @@ safef(extra,sizeof(extra),"id='%s_id' onchange='findTracksChangeVis(this)'",track->track); hTvDropDownClassWithJavascript(NULL, track->visibility,track->canPack,"normalText seenVis",extra); } + + // If this is a container track, allow configuring... + if (tdbIsComposite(track->tdb) || tdbIsSuper(track->tdb)) + { + containerTrackCount++; + hPrintf(" <a href='hgTrackUi?db=%s&g=%s&hgt_searchTracks=1' title='Configure this container track...'>*</a> ",database,track->track); + } hPrintf("</td>\n"); //if(tdbIsSuper(track->tdb) || tdbIsComposite(track->tdb)) // hPrintf("<td><a target='_top' href='%s' title='Configure track...'>%s</a></td>\n", trackUrl(track->track, NULL), track->shortLabel); @@ -666,6 +708,8 @@ hPrintf("</td></tr>\n"); } hPrintf("</table>\n"); + if(containerTrackCount > 0) + hPrintf("* Tracks so marked are containers which group related data tracks. These may not be visible unless further configuration is done. Click on the * to configure these.<BR>\n"); hPrintf("<INPUT TYPE=SUBMIT NAME='submit' VALUE='View in Browser' class='viewBtn'>"); hPrintf(" <FONT class='selCbCount'></font>"); hPrintf("\n</form>\n"); @@ -676,29 +720,26 @@ } hPrintf("<p><b>Recently Done</b><ul>\n" - "<li>Deleting/Adding selection criteria with [-][+] buttons in 'Advanced Search'.</li>" - "<li>Found track list shows only the first 100 tracks with warning to narrow search.\"</li>\n" - "<li>Clicks in menu bar up top now work correctly.</li>\n" - "<li>Found tracks are selected by checkboxes.</li>" - "<li>Checkbox state should be persistent. Subtracks selected will be checked in their composite.</li>" + "<li>'Clear' button added and search and clear buttons should be meaningfully enabled/disabled.</li>" + "<li>Clicking on shortLabel for found track will popup the description text. Subtracks should show their composite description.</li>" + "<li>Non-data 'container' tracks (composites and supertracks) have '*' to mark them, and can be configured before displaying. Better suggestions?</li>" + "<li>Simple search had been bombing on NULL tracks. This should be solved.</li>" + "<li>Short and long label searched on advanced 'Track Name' search.</li>" + "<li>Deleting/Adding selection criteria with [-][+] buttons in 'Advanced Search' should work.</li>" + "<li>Found track list shows only the first 100 tracks with warning to narrow search. Larry suggests this could be done by pages of results in v2.0.</li>\n" "<li>Full descriptions of metadata items are indexed in simple search index (e.g. cell descriptions).</li>" "</ul></p>" "<p><b>Known Problems</b><ul>" - "<li>Search results should be cleared when switching between simple and advanced tabs (do we agree on that?)</li>" - "<li>Subtracks often come up with the wrong visibility (but saving visibility for subtracks does work)." - "<BR>QUESTION: Upon selecting with checkbox, what is correct default vis for any track? Perhaps 'full' for wigs, 'pack' for others?</li>" - "<li>Too large of found track list results in slow scripts.</li>" + "<li>Updating the value drop-down when a new variable is chosen is only working in Larry's browser." "<li>Strangeness seen in finding tracks: 'ENCODE' in description combined with antibody selection results in no tracks found." "<BR>QUESTION: Is that a bug? REM that description search is NOT inherited. (* Suggestions below.)</li>" "</ul></p>" "<p><b>Suggested improvments:</b><ul>\n" - "<li>Only data tracks should be seen in found track list. Found superTracks/composites should be converted into their children.</li>" - "<li>Configuring found tracks should be by pop-up dialog box.</li>" - "<li>Look and feel of found track list (here) and composite subtrack list (hgTrackUi) should converge.</li>" - "<li>Drop-down list of terms (cells, antibodies, etc.) should be multi-select with checkBoxes as seen in filterComposites.</li>" - "<li>* 'Descrtiption' and 'Track Name' should be merged into a single search term.</li>" + "<li>Look and feel of found track list (here) and composite subtrack list (hgTrackUi) should converge. Jim suggests look and feel of hgTracks 'Configure Tracks...' list instead.</li>" + "<li>Drop-down list of terms (cells, antibodies, etc.) should be multi-select with checkBoxes as seen in filterComposites. Perhaps saved for v2.0.</li>" "<li>* 'Descrtiption' should be inherited by subtracks?</li>" "</ul></p>\n"); +hPrintf("</div"); // This div allows the clear button to empty it webEndSectionTables(); }