87a413e9d6406f600a0484ab9b434e806daca05d
galt
  Wed Oct 16 14:08:03 2019 -0700
fixes #21198. CIRM cdwWebBrowse oneFile page: Adds download link next to submit_file_name link that lets the user download the file with its original submit name (instead of accession id).

diff --git src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c
index 2dc134c..3813d0a 100644
--- src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c
+++ src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c
@@ -271,58 +271,68 @@
 char returnUrl[PATH_LEN*2];
 safef(returnUrl, sizeof(returnUrl), "../cgi-bin/cdwWebBrowse?cdwCommand=oneTag&cdwTagName=%s&%s",
     tag, cartSidUrlString(cart) );
 struct hash *outputWrappers = hashNew(0);
 hashAdd(outputWrappers, tag, wrapTagValueInFiles);
 webSortableFieldedTable(cart, table, returnUrl, "cdwOneTag", 0, outputWrappers, NULL);
 fieldedTableFree(&table);
 }
 
 void generateTableRow(struct slName *list,char **row, char *idTag , char *idVal) 
 {
 struct slName *el; 
 static char *outputFields[] = {"tag", "value"};
 struct fieldedTable *table = fieldedTableNew("File Tags", outputFields,ArraySize(outputFields));
 int fieldIx = 0;
+char *accession = NULL;
 for (el = list; el != NULL; el = el->next)
     {
     char *outRow[2];
     char *val = row[fieldIx];
     if (val != NULL)
 	{
 	outRow[0] = el->name;
 	outRow[1] = row[fieldIx];
 
 	// add a link to the accession row
 	if (sameWord(el->name, "accession"))
 	    {
 	    char link[1024];
 	    safef(link, sizeof(link), "%s <a href='cdwGetFile?acc=%s'>download</a>", outRow[1], outRow[1]);
+	    accession = cloneString(outRow[1]);
+	    outRow[1] = cloneString(link);
+	    }
+	// add a link to the submit_file_name row
+	if (sameWord(el->name, "submit_file_name"))
+	    {
+	    char link[1024];
+	    safef(link, sizeof(link), "%s <a href='cdwGetFile?acc=%s&useSubmitFname=1'>download</a>", outRow[1], accession);
 	    outRow[1] = cloneString(link);
 	    }
 	fieldedTableAdd(table, outRow, 2, fieldIx);
 	}
     ++fieldIx;
     }
 char returnUrl[PATH_LEN*2];
 safef(returnUrl, sizeof(returnUrl), 
     "../cgi-bin/cdwWebBrowse?cdwCommand=oneFile&cdwFileTag=%s&cdwFileVal=%s&%s",
     idTag, idVal, cartSidUrlString(cart) );
 struct hash *outputWrappers = hashNew(0);
 hashAdd(outputWrappers, "tag", wrapTagField);
 webSortableFieldedTable(cart, table, returnUrl, "cdwOneFile", 0, outputWrappers, NULL);
 fieldedTableFree(&table);
+freeMem(accession);
 }
 
 char *unquotedCartString(struct cart *cart, char *varName)
 /* Return unquoted cart variable */
 {
 char *val = cartOptionalString(cart, varName);
 if (val == NULL)
     return "";
 stripChar(val, '"');
 stripChar(val, '\'');
 return val;
 }
 
 char *getCdwSetting(char *setting, char *deflt)
 /* Get string cdw.<setting> */