966c1787935292fcc55313bd0e0cc08dffb89762
Merge parents a3026fd 0e0258d
tdreszer
  Mon Sep 19 13:30:46 2011 -0700
Fix merge conflict.
diff --cc src/hg/lib/hui.c
index a987a11,43c4e04..255cdd6
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@@ -3753,91 -3721,76 +3746,74 @@@
      case cfgBedFilt:    bedUi(tdb,cart,title, boxed);
                   	break;
  #ifdef USE_BAM
      case cfgBam:        bamCfgUi(cart, tdb, prefix, title, boxed);
  			break;
  #endif
      case cfgVcf:	vcfCfgUi(cart, tdb, prefix, title, boxed);
  			break;
      case cfgPsl:	pslCfgUi(db,cart,tdb,prefix,title,boxed);
                          break;
      default:            warn("Track type is not known to multi-view composites. type is: %d ", cType);
                          break;
      }
  }
  
- char *encodeRestrictionDateDisplay(char *db,struct trackDb *trackDb)
+ char *encodeRestrictionDate(char *db,struct trackDb *trackDb,boolean excludePast)
  /* Create a string for ENCODE restriction date of this track
     if return is not null, then free it after use */
  {
  if (!trackDb)
      return NULL;
  
- boolean addMonths = FALSE;
  char *date = NULL;
  
  if(metadataForTable(db,trackDb,NULL) != NULL)
      {
-     addMonths = FALSE;
      date = cloneString((char *)metadataFindValue(trackDb,"dateUnrestricted"));
-     if(date == NULL)  // TODO: The logic to calculate date based upon dateSubmitted should be removed.  However, I don't think we can do it until the mdb is used for all hg18 composites.
-         {
-         date = cloneString((char *)metadataFindValue(trackDb,"dateSubmitted"));
-         addMonths = TRUE;
-         }
-     }
- if(date == NULL)
-     {
-     date = trackDbSetting(trackDb, "dateSubmitted");
-     if(date)
-         {
-         addMonths = TRUE;
-         date = cloneString(date); // all returns should be freeable memory
-         }
-     }
- if (date != NULL)
-     {
-     date = strSwapChar(date, ' ', 0);   // Truncate time
-     if(addMonths)
-         date = dateAddTo(date, "%F", 0, 9, 0);
+     if (date != NULL)
+         date = strSwapChar(date, ' ', 0);   // Truncate time (not expected, but just in case)
+ 
+     if (excludePast && !isEmpty(date) && dateIsOld(date,"%F"))
+         freez(&date);
      }
  return date;
  }
  
 +#ifndef SUBTRACK_CFG
  static void cfgLinkToDependentCfgs(struct cart *cart, struct trackDb *tdb,char *prefix)
  /* Link composite or view level controls to all associateled lower level controls */
  {
  if (!cartVarExists(cart, "ajax") && tdbIsComposite(tdb))
 -#ifdef SUBTRACK_CFG_POPUP
 -    printf("<script type='text/javascript'>registerViewOnchangeAction('%s')</script>\n",prefix);
 -#else///ifndef SUBTRACK_CFG_POPUP
      printf("<script type='text/javascript'>compositeCfgRegisterOnchangeAction(\"%s\")</script>\n",prefix);
 -#endif///ndef SUBTRACK_CFG_POPUP
  }
 +#endif///ndef SUBTRACK_CFG
  
  static void compositeUiSubtracks(char *db, struct cart *cart, struct trackDb *parentTdb,struct hash *trackHash)
  /* Display list of subtracks and descriptions with checkboxes to control visibility and possibly other
   * nice things including links to schema and metadata and a release date. */
  {
  struct trackDb *subtrack;
  struct dyString *dyHtml = newDyString(SMALLBUF);
  //char *colors[2]   = { COLOR_BG_DEFAULT,
  //                      COLOR_BG_ALTDEFAULT };
  char *colors[2]   = { "bgLevel1",
                        "bgLevel1" };
  int colorIx = COLOR_BG_DEFAULT_IX; // Start with non-default allows alternation
 -#ifndef SUBTRACK_CFG_POPUP
 +#ifndef SUBTRACK_CFG
  boolean dependentCfgsNeedBinding = FALSE;
 -#endif///ndef SUBTRACK_CFG_POPUP
 +#endif///ndef SUBTRACK_CFG
  
  // Get list of leaf subtracks to work with
  struct slRef *subtrackRef, *subtrackRefList = trackDbListGetRefsToDescendantLeaves(parentTdb->subtracks);
  
  // Look for dividers, heirarchy, dimensions, sort and dragAndDrop!
  char **lastDivide = NULL;
  dividers_t *dividers = dividersSettingGet(parentTdb);
  if (dividers)
      lastDivide = needMem(sizeof(char*)*dividers->count);
  hierarchy_t *hierarchy = hierarchySettingGet(parentTdb);
  
  membersForAll_t* membersForAll = membersForAllSubGroupsGet(parentTdb,NULL);
  int dimCount=0,di;
  for(di=0;di<membersForAll->dimMax;di++) { if (membersForAll->members[di]) dimCount++; }
  sortOrder_t* sortOrder = sortOrderGet(cart,parentTdb);
@@@ -4184,97 -4042,99 +4160,97 @@@
      if (sortOrder != NULL)
          {
          int sIx=0;
          for(sIx=0;sIx<sortOrder->count;sIx++)
              {
              ix = stringArrayIx(sortOrder->column[sIx], membership->subgroups, membership->count); // TODO: Sort needs to expand from subGroups to labels as well
              if (ix >= 0)
                  {
                  char *titleRoot=NULL;
                  if (cvTermIsEmpty(sortOrder->column[sIx],membership->titles[ix]))
                      titleRoot = cloneString(" &nbsp;");
                  else
                      titleRoot = labelRoot(membership->titles[ix],NULL);
                  // Each sortable column requires hidden goop (in the "abbr" field currently) which is the actual sort on value
                  printf ("<TD id='%s_%s' abbr='%s' align='left'>&nbsp;",subtrack->track,sortOrder->column[sIx],membership->membership[ix]);
 -            #ifdef SUBTRACK_CFG_POPUP
 -                dyStringPrintf(dyLabel,"%s ",titleRoot);
 -                if (cType != cfgNone && sameString("view",sortOrder->column[sIx])) // configure link is on view currenntly  TODO: make a wrench next to check box/view
 -                    {
 -                    dyStringAppend(dyLabel,"Configuration");
 -                    MAKE_CFG_SUBTRACK_LINK(subtrack->track,dyStringContents(dyLabel),titleRoot);
 -                    }
 -            #else///ifndef SUBTRACK_CFG_POPUP
 -                if (cType != cfgNone && sameString("view",sortOrder->column[sIx]))
 -                    MAKE_CFG_SUBTRACK_LINK(subtrack->track,titleRoot);  // FIXME: Currently configurable under sort only supported when multiview
 -            #endif///ndef SUBTRACK_CFG_POPUP
 +            #ifndef SUBTRACK_CFG
 +                #define CFG_SUBTRACK_LINK  "<A HREF='#a_cfg_%s' onclick='return subtrackCfgShow(\"%s\");' title='Subtrack Configuration'>%s</A>"
 +                #define MAKE_CFG_SUBTRACK_LINK(table,title) printf(CFG_SUBTRACK_LINK, (table),(table),(title))
 +                if (cType != cfgNone && sameString("view",sortOrder->column[sIx])) // configure link is on view currently
 +                    MAKE_CFG_SUBTRACK_LINK(subtrack->track,titleRoot);
                  else
 +            #endif///ndef SUBTRACK_CFG
                      printf("%s",titleRoot);
                  puts ("</TD>");
                  freeMem(titleRoot);
                  }
              }
          }
      else  // Non-sortable tables do not have sort by columns but will display a short label (which may be a configurable link)
          {
          printf ("<TD>&nbsp;");
          indentIfNeeded(hierarchy,membership);
 -    #ifdef SUBTRACK_CFG_POPUP
 -        if (cType != cfgNone && cType != cfgWigMaf)  // FIXME: wigMaf restriction is temporary until configureByPopup off is set
 -            MAKE_CFG_SUBTRACK_LINK(subtrack->track,subtrack->shortLabel,subtrack->shortLabel);
 -    #else///ifndef SUBTRACK_CFG_POPUP
 +    #ifndef SUBTRACK_CFG
          if (cType != cfgNone)
              MAKE_CFG_SUBTRACK_LINK(subtrack->track,subtrack->shortLabel);
 -    #endif///ndef SUBTRACK_CFG_POPUP
          else
 +    #endif///ndef SUBTRACK_CFG
              printf("%s",subtrack->shortLabel);
          puts ("</TD>");
          }
 -#ifdef SUBTRACK_CFG_POPUP
 -    dyStringFree(&dyLabel);
 -#endif///def SUBTRACK_CFG_POPUP
  
      // The long label column (note that it may have a "..." that allows getting at all the metadata)
      printf ("<TD title='select to copy'>&nbsp;%s", subtrack->longLabel);
      if (trackDbSetting(parentTdb, "wgEncode") && trackDbSetting(subtrack, "accession"))
          printf (" [GEO:%s]", trackDbSetting(subtrack, "accession"));
      compositeMetadataToggle(db,subtrack,NULL,TRUE,FALSE, trackHash);
      printf("&nbsp;");
  
 -#ifndef SUBTRACK_CFG_POPUP
      // Embedded cfg dialogs are within the TD that contains the longLabel.  This allows a wide item to be embedded in the table
      if (cType != cfgNone)
          {
 +    #ifdef SUBTRACK_CFG
 +        // How to make this thing float to the left?  Container is overflow:visible
 +        // and contained (made in js) is position:relative; left: -{some pixels}
 +        #define CFG_SUBTRACK_DIV "<DIV id='div_cfg_%s' class='subCfg %s' style='display:none; overflow:visible;'></DIV>"
 +        #define MAKE_CFG_SUBTRACK_DIV(table,view) printf(CFG_SUBTRACK_DIV,(table),(view)?(view):"noView")
 +        char * view = NULL;
 +        if (membersForAll->members[dimV] && -1 != (ix = stringArrayIx(membersForAll->members[dimV]->groupTag, membership->subgroups, membership->count)))
 +            view = membership->membership[ix];
 +        MAKE_CFG_SUBTRACK_DIV(subtrack->track,view);
 +    #else///ifndef SUBTRACK_CFG
          dependentCfgsNeedBinding = TRUE; // configurable subtrack needs to be bound to composite settings
 -    #define CFG_SUBTRACK_DIV "<DIV id='div_%s_cfg'%s><INPUT TYPE=HIDDEN NAME='%s' value='%s'>\n"
 -    #define MAKE_CFG_SUBTRACK_DIV(table,cfgVar,open) printf(CFG_SUBTRACK_DIV,(table),((open)?"":" style='display:none'"),(cfgVar),((open)?"on":"off"))
 -        safef(htmlIdentifier,sizeof(htmlIdentifier),"%s.childShowCfg",subtrack->track);
 -        boolean open = cartUsualBoolean(cart, htmlIdentifier,FALSE);
 -        MAKE_CFG_SUBTRACK_DIV(subtrack->track,htmlIdentifier,open);
 -        safef(htmlIdentifier,sizeof(htmlIdentifier),"%s",subtrack->track);
 -        cfgByCfgType(cType,db,cart,subtrack,htmlIdentifier,"Subtrack",TRUE);
 +        #define CFG_SUBTRACK_DIV "<DIV id='div_%s_cfg'%s><INPUT TYPE=HIDDEN NAME='%s' value='%s'>\n"
 +        #define MAKE_CFG_SUBTRACK_DIV(table,cfgVar,open) printf(CFG_SUBTRACK_DIV,(table),((open)?"":" style='display:none'"),(cfgVar),((open)?"on":"off"))
 +        safef(buffer,sizeof(buffer),"%s.childShowCfg",subtrack->track);
 +        boolean open = cartUsualBoolean(cart, buffer,FALSE);
 +        MAKE_CFG_SUBTRACK_DIV(subtrack->track,buffer,open);
 +        safef(buffer,sizeof(buffer),"%s",subtrack->track);
 +        cfgByCfgType(cType,db,cart,subtrack,buffer,"Subtrack",TRUE);
          printf("</DIV>");
 +    #endif///ndef SUBTRACK_CFG
          }
 -#endif///ndef SUBTRACK_CFG_POPUP
  
      // A schema link for each track
      printf("</td>\n<TD>&nbsp;");
      makeSchemaLink(db,subtrack,"schema");
      printf("&nbsp;");
  
      // Do we have a restricted until date?
      if (restrictions)
          {
-         char *dateDisplay = encodeRestrictionDateDisplay(db,subtrack);
+         char *dateDisplay = encodeRestrictionDate(db,subtrack,FALSE); // includes dates in the past
          if (dateDisplay)
              {
              if (dateIsOld(dateDisplay,"%F"))
                  printf("</TD>\n<TD align='center' nowrap style='color: #BBBBBB;'>&nbsp;%s&nbsp;", dateDisplay);
              else
                  printf("</TD>\n<TD align='center'>&nbsp;%s&nbsp;", dateDisplay);
              }
          }
  
      // End of row and free ourselves of this subtrack
      puts("</TD></TR>\n");
      checkBoxIdFree(&id);
      }
  
  // End of the table
@@@ -6509,39 -6367,35 +6485,38 @@@
              first = FALSE;
              }
          }
      }
  dyStringPrintf(dyLink,VOCAB_MULTILINK_END,members->groupTitle,members->groupTitle);
  freeMem(vocab);
  return dyStringCannibalize(&dyLink);
  }
  
  static boolean compositeUiByFilter(char *db, struct cart *cart, struct trackDb *parentTdb, char *formName)
  /* UI for composite tracks: filter subgroups by multiselects to select subtracks. */
  {
  membersForAll_t* membersForAll = membersForAllSubGroupsGet(parentTdb,cart);
  if(membersForAll == NULL || membersForAll->filters == FALSE) // Not Matrix or filters
      return FALSE;
 -webIncludeResourceFile("ui.dropdownchecklist.css");
 -jsIncludeFile("ui.dropdownchecklist.js",NULL);
 +if(cartOptionalString(cart, "ajax") == NULL)
 +    {
-     jsIncludeFile("ui.core.js",NULL);
 +    webIncludeResourceFile("ui.dropdownchecklist.css");
 +    jsIncludeFile("ui.dropdownchecklist.js",NULL);
  #ifdef NEW_JQUERY
 -jsIncludeFile("ddcl.js",NULL);
 +    jsIncludeFile("ddcl.js",NULL);
  #endif///def NEW_JQUERY
 +    }
  
  cgiDown(0.7);
  printf("<B>Filter subtracks %sby:</B> (select multiple %sitems - %s)<BR>\n",
         (membersForAll->members[dimX] != NULL || membersForAll->members[dimY] != NULL ? "further ":""),
         (membersForAll->dimMax == dimA?"":"categories and "),FILTERBY_HELP_LINK);
  printf("<TABLE><TR valign='top'>\n");
  
  // Do All [+][-] buttons
  if(membersForAll->members[dimX] == NULL && membersForAll->members[dimY] == NULL) // No matrix
      {
      #define PM_BUTTON_FILTER_COMP "<input type='button' class='inOutButton' onclick=\"waitOnFunction(filterCompositeSet,this,%s); return false;\" id='btn_%s' value='%c'>"
      printf("<TD align='left' width='50px'><B>All:</B><BR>");
      printf(PM_BUTTON_FILTER_COMP,"true",  "plus_fc",'+');
      printf(PM_BUTTON_FILTER_COMP,"false","minus_fc",'-');
      //#define PM_BUTTON2_FILTER_COMP "<IMG height=18 width=18 onclick=\"filterCompositeSet(%s);\" id='btn_%s' src='../images/%s'>"