Skip to content

Commit

Permalink
Merge pull request #686 from WildMeOrg/598_match_new_indiv_fix
Browse files Browse the repository at this point in the history
fix dead-end for "confirm no match" button without project
  • Loading branch information
TanyaStere42 authored Aug 20, 2024
2 parents aa57f24 + 00048ab commit 0146e27
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/main/webapp/iaResults.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -1879,16 +1879,24 @@ function negativeButtonClick(encId, oldDisplayName) {
var confirmMsg = 'Confirm no match?\n\n';
confirmMsg += 'By clicking \'OK\', you are confirming that there is no correct match in the results below. ';
var nextName = '<%=nextName%>';
if (nextName == 'null') nextName = false;
var nextNameInput = $('#negative-button-name').val();
console.log('negativeButtonClick(): encId=%o, oldDisplayName=%o, nextName=%o, nextNameInput=%o', encId, oldDisplayName, nextName, nextNameInput);
if (!nextName && !nextNameInput) return alert('You must provide a name for the new individual.');
if (!nextName && nextNameInput) nextName = nextNameInput; // just for displaying below
if (oldDisplayName!=="undefined" && oldDisplayName && oldDisplayName !== "" && oldDisplayName.length) {
confirmMsg+= 'The name <%=nextName%> will be added to individual '+oldDisplayName + '.';
confirmMsg+= 'The name ' + nextName + ' will be added to individual '+oldDisplayName + '.';
} else {
confirmMsg+= 'A new individual will be created with name <%=nextName%> and applied to encounter '+encDisplayString(encId) +'.';
confirmMsg+= 'A new individual will be created with name ' + nextName + ' and applied to encounter '+encDisplayString(encId) +'.';
}
confirmMsg+= 'Click \'OK\' to record your decision.';
let paramStr = 'encId='+encId+'&noMatch=true';
let projectId = '<%=projectIdPrefix%>';
if (projectId&&projectId.length) {
if (nextNameInput) {
paramStr += '&nextNameInput=' + encodeURIComponent(nextNameInput);
} else if (projectId&&projectId.length) {
paramStr += '&useNextProjectId=true&projectIdPrefix='+encodeURIComponent(projectId);
}
Expand Down Expand Up @@ -1929,10 +1937,13 @@ function addNegativeButton(encId, oldDisplayName) {
*/
//if (<%=usesAutoNames%>) {
if (true) {
console.log("Adding auto name/confirm negative button!");
var nextName = '<%=nextName%>';
console.log("Adding auto name/confirm negative button! nextName = %o", nextName);
var negativeButton = '<input onclick=\'negativeButtonClick(\"'+encId+'\", \"'+oldDisplayName+'\");\' type="button" value="Confirm No Match" />';
console.log("negativeButton = "+negativeButton);
//var negativeButton = '<input onclick="negativeButtonClick();" type="button" value="Confirm No Match" />';
if (!nextName || (nextName == 'null')) {
negativeButton = '<input id="negative-button-name" placeholder="Enter name for new individual" /> ' + negativeButton;
}
headerDefault = negativeButton;
//console.log("NEGATIVE BUTTON: About to attach "+negativeButton+" to "+JSON.stringify($('div#enc-action')));
$('div#enc-action').html(negativeButton);
Expand Down
14 changes: 12 additions & 2 deletions src/main/webapp/iaResultsNoMatch.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ if (request.getParameter("encId")!=null && request.getParameter("noMatch")!=null
String projectIdPrefix = request.getParameter("projectIdPrefix");
String researchProjectName = null;
String researchProjectUUID = null;
String nextNameString = "";
String nextNameInput = request.getParameter("nextNameInput");
String nextNameString = ""; // this is set but never used wtf? FIXME
// okay, are we going to use an incremental name from the project side?
if (Util.stringExists(projectIdPrefix)) {
Project projectForAutoNaming = myShepherd.getProjectByProjectIdPrefix(projectIdPrefix.trim());
Expand Down Expand Up @@ -87,6 +89,8 @@ if (request.getParameter("encId")!=null && request.getParameter("noMatch")!=null
validToName = true;
}
if (Util.stringExists(nextNameInput)) validToName = true;
if (!validToName) {
rtn.put("error", "Was unable to set the next automatic name. Got key="+nextNameKey+" and val="+nextName);
out.println(rtn.toString());
Expand All @@ -103,10 +107,16 @@ if (request.getParameter("encId")!=null && request.getParameter("noMatch")!=null
IndividualAddEncounter.executeEmails(myShepherd, request,mark,true, enc, context, langCode);
}
// validToName should never be false here wtf FIXME
if (validToName&&"true".equals(useNextProjectId)) {
System.out.println("trying to set next PROJECT automatic name.......");
Project projectForAutoNaming = myShepherd.getProjectByProjectIdPrefix(projectIdPrefix.trim());
mark.addIncrementalProjectId(projectForAutoNaming);
} else if (nextNameInput != null) {
System.out.println("setting manually named nextNameInput=" + nextNameInput + " onto " + mark);
mark.addName(nextNameInput);
} else {
System.out.println("trying to set USER BASED automatic name.......");
// old user based id
Expand Down Expand Up @@ -137,4 +147,4 @@ else{
}
%>
%>

0 comments on commit 0146e27

Please sign in to comment.