efffc477cc2f67d7668905675361447edff7bec8
jcasper
Wed Mar 16 13:36:04 2022 -0700
Initial commit of requiring a description when adding a session to the public
listing. Also fixing a typo in an update statement. refs #21229
diff --git src/hg/hgSession/hgSession.c src/hg/hgSession/hgSession.c
index 422fe4d..d7f20df 100644
--- src/hg/hgSession/hgSession.c
+++ src/hg/hgSession/hgSession.c
@@ -330,30 +330,31 @@
else
sqlSafef(query, sizeof(query), "SELECT sessionName, shared, firstUse, contents from %s "
"WHERE userName = '%s' ORDER BY sessionName;",
namedSessionTable, encUserName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
char *encSessionName = row[0];
char *sessionName = cgiDecodeClone(encSessionName);
char *link = NULL;
int shared = atoi(row[1]);
char *firstUse = row[2];
char buf[512];
boolean inGallery = FALSE;
+ boolean hasDescription = FALSE;
if (shared >=2)
inGallery = TRUE;
printf("
| ");
struct dyString *dy = dyStringNew(1024);
addSessionLink(dy, encUserName, encSessionName, FALSE, TRUE);
printf("%s", dyStringContents(dy), sessionName);
dyStringFree(&dy);
struct tm firstUseTm;
ZeroVar(&firstUseTm);
strptime(firstUse, "%Y-%m-%d %T", &firstUseTm);
char *spacePt = strchr(firstUse, ' ');
@@ -371,50 +372,57 @@
{
char *dbEnd = strchr(dbIdx, '&');
char *db = NULL;
if (dbEnd != NULL)
db = cloneStringZ(dbIdx, dbEnd-dbIdx);
else
db = cloneString(dbIdx);
printf("%s | ", db);
}
else
printf("n/a | ");
if (gotSettings)
{
safef(buf, sizeof(buf), "%s%s", hgsEditPrefix, encSessionName);
- cgiMakeButton(buf, "details");
+ cgiMakeButton(buf, "view/edit");
+ char *description = getSetting(row[4], "description");
+ if (!isEmpty(description))
+ hasDescription = TRUE;
}
else
printf("unavailable");
printf(" | ");
safef(buf, sizeof(buf), "%s%s", hgsDeletePrefix, encSessionName);
char command[512];
safef(command, sizeof(command), confirmDeleteFormat, encSessionName);
cgiMakeOnClickSubmitButton(command, buf, "delete");
printf(" | ");
safef(buf, sizeof(buf), "%s%s", hgsSharePrefix, encSessionName);
cgiMakeCheckBoxWithId(buf, shared>0, buf);
- jsOnEventById("change",buf,"console.log('new status' + this.checked); document.mainForm.submit();");
+ jsOnEventById("change",buf,"document.mainForm.submit();");
printf(" | ");
safef(buf, sizeof(buf), "%s%s", hgsGalleryPrefix, encSessionName);
cgiMakeCheckBoxFourWay(buf, inGallery, shared>0, buf, NULL, NULL);
+ if (hasDescription || inGallery)
jsOnEventById("change", buf, "document.mainForm.submit();");
+ else
+ jsOnEventById("change", buf, "warn('Please first use the view/edit option to "
+ "add a description for this session.'); this.checked = false;");
link = getSessionEmailLink(encUserName, encSessionName);
printf(" | %s |
", link);
freez(&link);
foundAny = TRUE;
struct slName *sn = slNameNew(sessionName);
slAddHead(&existingSessionNames, sn);
}
if (!foundAny)
printf("