bd69e1cc71b97c282db26088b8d1e59981a3b7d5
tdreszer
  Tue Mar 8 14:37:41 2011 -0800
Added support for showing downloadsOnly tracks in hgTracks (but only if they are part of a superTrack with other visible tracks).  Also standardized links for downloadsOnly tacks between hgTracks and hgTrackUi
diff --git src/hg/hgTracks/config.c src/hg/hgTracks/config.c
index 66ea94c..cfdf501 100644
--- src/hg/hgTracks/config.c
+++ src/hg/hgTracks/config.c
@@ -3,30 +3,35 @@
 #include "common.h"
 #include "dystring.h"
 #include "cheapcgi.h"
 #include "htmshell.h"
 #include "hdb.h"
 #include "hCommon.h"
 #include "cart.h"
 #include "web.h"
 #include "customTrack.h"
 #include "hgTracks.h"
 #include "hgConfig.h"
 #include "jsHelper.h"
 #include "imageV2.h"
 #include "searchTracks.h"
 
+#define DOWNLOADS_ONLY_TRACKS_INCLUDED
+#ifdef DOWNLOADS_ONLY_TRACKS_INCLUDED
+#include "fileUi.h"
+#endif///def DOWNLOADS_ONLY_TRACKS_INCLUDED
+
 static void textSizeDropDown()
 /* Create drop down for font size. */
 {
 static char *sizes[] = {"6", "8", "10", "12", "14", "18", "24", "34"};
 hDropList(textSizeVar, sizes, ArraySize(sizes), tl.textSize);
 }
 
 #ifdef PRIORITY_CHANGES_IN_CONFIG_UI
 static void printGroupListHtml(char *groupCgiName, struct group *groupList, char *defaultGroup)
 /* Make an HTML select input listing the groups. */
 {
 char *groups[128];
 char *labels[128];
 char *defaultLabel = NULL;
 int numGroups = 0;
@@ -177,136 +182,159 @@
         if (withPriorityOverride)
             {
             hPrintf("<TD>");
             hPrintf("</TD>");
             hPrintf("<TD>");
             hPrintf("</TD>");
             }
 #endif///def PRIORITY_CHANGES_IN_CONFIG_UI
 	hPrintf("</TR>\n");
 	}
     if (differentString(group->name, "user"))
         isFirstNotCtGroup = FALSE;
     /* Scan track list to determine which supertracks have visible member
      * tracks, and to insert a track in the list for the supertrack.
      * Sort tracks and supertracks together by priority */
+    makeGlobalTrackHash(trackList);
     groupTrackListAddSuper(cart, group);
 
     if (!withPriorityOverride)
         {
         /* sort hierarchically by priority, considering supertracks */
         struct trackRef *refList = NULL, *ref;
         for (tr = group->trackList; tr != NULL; tr = tr->next)
             {
             struct track *track = tr->track;
             if (tdbIsSuperTrackChild(track->tdb))
                 /* ignore supertrack member tracks till supertrack is found */
                 continue;
             AllocVar(ref);
             ref->track = track;
             slAddTail(&refList, ref);
             if (tdbIsSuper(track->tdb))
                 {
-                struct trackRef *tr2;
-                for (tr2 = group->trackList; tr2 != NULL; tr2 = tr2->next)
+                struct slRef *child = track->tdb->children;
+                for (; child != NULL; child=child->next)
+                    {
+                    struct trackDb *childTdb = child->val;
+                    struct track *childTrack = hashFindVal(trackHash, childTdb->track);
+#ifdef DOWNLOADS_ONLY_TRACKS_INCLUDED
+                    // Try adding downloadsOnly track
+                    if (childTrack == NULL && tdbIsDownloadsOnly(childTdb))
                     {
-                    char *parent = tr2->track->tdb->parentName;
-                    if (parent && sameString(parent, track->track))
+                        AllocVar(childTrack);           // Fake a track!
+                        childTrack->tdb = childTdb;
+                        childTrack->hasUi = FALSE;
+                        }
+#endif///def DOWNLOADS_ONLY_TRACKS_INCLUDED
+                    if (childTrack != NULL)
                         {
                         AllocVar(ref);
-                        ref->track = tr2->track;
+                        ref->track = childTrack;
                         slAddTail(&refList, ref);
                         }
                     }
                 }
             }
         group->trackList = refList;
         }
 
     /* Loop through this group and display */
     int rowCount=1;
     for (tr = group->trackList; tr != NULL; tr = tr->next)
 	{
 	struct track *track = tr->track;
         struct trackDb *tdb = track->tdb;
 
 	hPrintf("<TR %sid='%s-%d'>",(isOpen ? "" : "style='display: none'"),group->name, rowCount++);
 	hPrintf("<TD NOWRAP>");
         if (tdbIsSuperTrackChild(tdb))
             /* indent members of a supertrack */
             hPrintf("&nbsp;&nbsp;&nbsp;&nbsp;");
 
         // Print an icon before the title when one is defined
-        hPrintPennantIcon(track->tdb);
+        hPrintPennantIcon(tdb);
 
 	if (track->hasUi)
-	    hPrintf("<A %s%s%s HREF=\"%s?%s=%u&g=%s&hgTracksConfigPage=configure\">",
-                tdb->parent ? "TITLE=\"Part of super track: " : "",
-                tdb->parent ? tdb->parent->shortLabel : "",
-                tdb->parent ? "...\"" : "", hgTrackUiName(),
-		cartSessionVarName(), cartSessionId(cart), track->track);
-        hPrintf(" %s", track->shortLabel);
-        if (tdbIsSuper(track->tdb))
+	    hPrintf("<A TITLE='%s%s...' HREF='%s?%s=%u&g=%s&hgTracksConfigPage=configure'>",
+                tdb->parent ? "Part of super track: " : "Configure ",
+                tdb->parent ? tdb->parent->shortLabel : tdb->shortLabel,
+                hgTrackUiName(),cartSessionVarName(), cartSessionId(cart), track->track);
+        hPrintf(" %s", tdb->shortLabel);
+        if (tdbIsSuper(tdb))
             hPrintf("...");
 	if (track->hasUi)
 	    hPrintf("</A>");
 	hPrintf("</TD>");
         hPrintf("<TD NOWRAP>");
         if (tdbIsSuperTrackChild(tdb))
             /* indent members of a supertrack */
             hPrintf("&nbsp;&nbsp;&nbsp;&nbsp;");
 
 	/* If track is not on this chrom print an informational
 	   message for the user. */
+#ifdef DOWNLOADS_ONLY_TRACKS_INCLUDED
+        if (tdbIsDownloadsOnly(tdb))
+            hPrintf("<A TITLE='Downloadable files...' HREF='%s?%s=%u&g=%s'>Downloads</A>", // No vis display for downloadsOnly
+                hgFileUiName(),cartSessionVarName(), cartSessionId(cart), tdb->track);
+        else
+#endif///def DOWNLOADS_ONLY_TRACKS_INCLUDED
 	if (hTrackOnChrom(track->tdb, chromName))
 	    {
             if (tdbIsSuper(track->tdb))
                 {
                 /* supertrack dropdown is hide/show */
                 superTrackDropDown(cart, track->tdb, 1);
                 }
             else
                 {
                 /* check for option of limiting visibility to one mode */
                 hTvDropDownClassVisOnly(track->track, track->visibility,
                             track->canPack, (track->visibility == tvHide) ?
                             "hiddenText" : "normalText",
                             trackDbSetting(track->tdb, "onlyVisibility"));
                 }
 	    }
 	else
 	    hPrintf("[No data-%s]", chromName);
 	hPrintf("</TD>");
 	hPrintf("<TD NOWRAP>");
-	hPrintf("%s", track->longLabel);
+	hPrintf("%s", tdb->longLabel);
 	hPrintf("</TD>");
 #ifdef PRIORITY_CHANGES_IN_CONFIG_UI
         if (withPriorityOverride)
             {
             hPrintf("<TD>");
+#ifdef DOWNLOADS_ONLY_TRACKS_INCLUDED
+            if (tdbIsDownloadsOnly(tdb))
+                hPrintf("&nbsp</TD><TD>\n&nbsp");
+            else
+#endif///def DOWNLOADS_ONLY_TRACKS_INCLUDED
+                {
             safef(pname, sizeof(pname), "%s.priority",track->track);
             hDoubleVar(pname, (double)track->priority, 4);
             hPrintf("</TD>");
             hPrintf("<TD>\n");
             /* suppress group pull-down for supertrack members */
             if (tdbIsSuperTrackChild(track->tdb))
                 hPrintf("&nbsp");
             else
                 {
                 safef(gname, sizeof(gname), "%s.group",track->track);
                 printGroupListHtml(gname, groupList, track->groupName);
                 }
+                }
             hPrintf("</TD>");
             }
 #endif///def PRIORITY_CHANGES_IN_CONFIG_UI
 	hPrintf("</TR>\n");
 	}
     hTableEnd();
     hPrintf("<BR>");
     }
 }
 
 void configPageSetTrackVis(int vis)
 /* Do config page after setting track visibility. If vis is -2, then visibility
  * is unchanged.  If -1 then set visibility to default, otherwise it should
  * be tvHide, tvDense, etc. */
 {