07c4566bd0dc7ca669b4720b5b3a3e0b70f5a92b jcasper Mon Mar 28 01:48:37 2022 -0700 Prevent adding a public session with no description from the 'edit details' checkbox, refs #21229 diff --git src/hg/hgSession/hgSession.c src/hg/hgSession/hgSession.c index d7f20df..c18ecbf 100644 --- src/hg/hgSession/hgSession.c +++ src/hg/hgSession/hgSession.c @@ -1083,33 +1083,43 @@ "Session Name: " "<INPUT TYPE=TEXT NAME=\"%s\" id='%s' SIZE=%d VALUE=\"%s\" >\n", sessionName, hgSessionName(), cartSessionVarName(cart), cartSessionId(cart), hgsOldSessionName, sessionName, hgsNewSessionName, hgsNewSessionName, 32, sessionName); jsOnEventById("change" , hgsNewSessionName, highlightAccChanges); jsOnEventById("keydown", hgsNewSessionName, highlightAccChanges); dyStringPrintf(dyMessage, " <INPUT TYPE=SUBMIT ID=\"%s\" NAME=\"%s\" VALUE=\"accept changes\">" " <INPUT TYPE=SUBMIT NAME=\"%s\" VALUE=\"cancel\"> " "<BR>\n", hgsDoSessionChange, hgsDoSessionChange, hgsCancel); struct slName *existingSessionNames = getUserSessionNames(encUserName); - struct dyString *js = dyPrintCheckExistingSessionJs( existingSessionNames, sessionName); - jsOnEventById("click", hgsDoSessionChange, js->string); - dyStringFree(&js); + struct dyString *checkExistingNameJs = dyPrintCheckExistingSessionJs( existingSessionNames, sessionName); + struct dyString *onClickJs = dyStringCreate( + "var pattern = /^\\s*$/;" + "if (document.getElementById(\"detailsGalleryCheckbox\").checked &&" + " pattern.test(document.getElementById(\"%s\").value)) {" + " warn('Please add a description to allow this session to be included in the Public Gallery');" + " event.preventDefault();" + "} else {" + " %s" + "}", hgsNewSessionDescription, checkExistingNameJs->string); + jsOnEventById("click", hgsDoSessionChange, onClickJs->string); + dyStringFree(&onClickJs); + dyStringFree(&checkExistingNameJs); dyStringPrintf(dyMessage, "Share with others? <INPUT TYPE=CHECKBOX NAME=\"%s%s\"%s VALUE=on " "id=\"detailsSharedCheckbox\">\n" "<INPUT TYPE=HIDDEN NAME=\"%s%s%s\" VALUE=0><BR>\n", hgsSharePrefix, encSessionName, (shared>0 ? " CHECKED" : ""), cgiBooleanShadowPrefix(), hgsSharePrefix, encSessionName); jsOnEventByIdF("change", "detailsSharedCheckbox", "{%s %s}", highlightAccChanges, toggleGalleryDisable); jsOnEventByIdF("click" , "detailsSharedCheckbox", "{%s %s}", highlightAccChanges, toggleGalleryDisable); dyStringPrintf(dyMessage, "List in Public Sessions? <INPUT TYPE=CHECKBOX NAME=\"%s%s\"%s VALUE=on " "id=\"detailsGalleryCheckbox\">\n" "<INPUT TYPE=HIDDEN NAME=\"%s%s%s\" VALUE=0><BR>\n", hgsGalleryPrefix, encSessionName, (shared>=2 ? " CHECKED" : ""),