NIHVIVO-821 Adapt grant form for editing existing role

This commit is contained in:
rjy7 2010-07-15 15:58:41 +00:00
parent 6430e5afd1
commit d965ed0966
4 changed files with 44 additions and 18 deletions

View file

@ -66,15 +66,15 @@ String subjectName = ((Individual) request.getAttribute("subject")).getName();
if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %> if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %>
<v:jsonset var="roleType">http://vivoweb.org/ontology/core#PrincipalInvestigatorRole</v:jsonset> <v:jsonset var="roleType">http://vivoweb.org/ontology/core#PrincipalInvestigatorRole</v:jsonset>
<c:set var="submitButtonLabel">Principal Investigator</c:set> <c:set var="submitButtonLabel">Principal Investigator</c:set>
<c:set var="formHeading">Create a new principal investigator entry for <%= subjectName %></c:set> <c:set var="formHeading">principal investigator entry for <%= subjectName %></c:set>
<% }else if ( ((String)request.getAttribute("predicateUri")).endsWith("hasCo-PrincipalInvestigatorRole") ) { %> <% }else if ( ((String)request.getAttribute("predicateUri")).endsWith("hasCo-PrincipalInvestigatorRole") ) { %>
<v:jsonset var="roleType">http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole</v:jsonset> <v:jsonset var="roleType">http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole</v:jsonset>
<c:set var="submitButtonLabel">Co-Principal Investigator</c:set> <c:set var="submitButtonLabel">Co-Principal Investigator</c:set>
<c:set var="formHeading">Create a new co-principal investigator entry for <%= subjectName %></c:set> <c:set var="formHeading">co-principal investigator entry for <%= subjectName %></c:set>
<% }else { %> <% }else { %>
<v:jsonset var="roleType">http://vivoweb.org/ontology/core#InvestigatorRole</v:jsonset> <v:jsonset var="roleType">http://vivoweb.org/ontology/core#InvestigatorRole</v:jsonset>
<c:set var="submitButtonLabel">Investigator</c:set> <c:set var="submitButtonLabel">Investigator</c:set>
<c:set var="formHeading">Create a new investigator entry for <%= subjectName %></c:set> <c:set var="formHeading">investigator entry for <%= subjectName %></c:set>
<% } %> <% } %>
<c:set var="startYearUri" value="${vivoCore}startYear" /> <c:set var="startYearUri" value="${vivoCore}startYear" />
@ -252,6 +252,17 @@ PREFIX core: <${vivoCore}>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" /> <c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" /> <c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<c:choose>
<c:when test="<%= request.getAttribute("objectUri")!=null %>">
<c:set var="formHeading" value="Edit ${formHeading}" />
<c:set var="editMode" value="edit" />
</c:when>
<c:otherwise>
<c:set var="formHeading" value="Create a new ${formHeading}" />
<c:set var="editMode" value="add" />
</c:otherwise>
</c:choose>
<jsp:include page="${preForm}" /> <jsp:include page="${preForm}" />
<h2>${formHeading}</h2> <h2>${formHeading}</h2>
@ -259,7 +270,7 @@ PREFIX core: <${vivoCore}>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> <%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addGrantRoleToPerson" action="<c:url value="/edit/processRdfForm2.jsp"/>" > <form id="addGrantRoleToPerson" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p><v:input type="text" id="relatedIndLabel" name="grantLabel" label="Grant Name ${requiredHint}" cssClass="acSelector" size="50" /></p> <p><v:input type="text" id="relatedIndLabel" name="grantLabel" label="Name ${requiredHint}" cssClass="acSelector" size="50" /></p>
<div class="acSelection"> <div class="acSelection">
<p class="inline"><label>Selected Grant:</label><span class="acSelectionInfo"></span><a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p> <p class="inline"><label>Selected Grant:</label><span class="acSelectionInfo"></span><a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
@ -289,7 +300,10 @@ var customFormData = {
sparqlForAcFilter: '${sparqlForAcFilter}', sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}', sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${acUrl}', acUrl: '${acUrl}',
acType: '${vivoCore}Grant', acType: '${vivoCore}Grant',
editMode: '${editMode}',
submitButtonType: 'compound',
typeName: 'Grant'
}; };
</script> </script>

View file

@ -239,7 +239,8 @@ PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAu
var customFormData = { var customFormData = {
sparqlForAcFilter: '${sparqlForAcFilter}', sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}', sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${acUrl}' acUrl: '${acUrl}',
submitButtonType: 'simple'
}; };
</script> </script>
<jsp:include page="${postForm}"/> <jsp:include page="${postForm}"/>

View file

@ -309,12 +309,10 @@
<c:choose> <c:choose>
<c:when test="<%= request.getAttribute("objectUri")!=null %>"> <c:when test="<%= request.getAttribute("objectUri")!=null %>">
<c:set var="titleText" value="Edit" /> <c:set var="titleText" value="Edit" />
<c:set var="buttonText" value="Edit" />
<c:set var="editMode" value="edit" /> <c:set var="editMode" value="edit" />
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<c:set var="titleText" value="Create a new" /> <c:set var="titleText" value="Create a new" />
<c:set var="buttonText" value="Create" />
<c:set var="editMode" value="add" /> <c:set var="editMode" value="add" />
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
@ -363,7 +361,8 @@ var customFormData = {
sparqlForAcFilter: '${sparqlForAcFilter}', sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}', sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${acUrl}', acUrl: '${acUrl}',
editMode: '${editMode}' editMode: '${editMode}',
submitButtonType: 'compound'
}; };
</script> </script>
<jsp:include page="${postForm}"/> <jsp:include page="${postForm}"/>

View file

@ -326,7 +326,7 @@ var customForm = {
setLabelFieldLabels: function() { setLabelFieldLabels: function() {
var newLabelTextForNewInd, var newLabelTextForNewInd,
selectedTypeName = this.getSelectedTypeName(); selectedTypeName = this.getTypeName();
this.labelFieldLabel.html(selectedTypeName + ' ' + this.baseLabelText); this.labelFieldLabel.html(selectedTypeName + ' ' + this.baseLabelText);
@ -338,18 +338,30 @@ var customForm = {
}, },
toggleButtonText: function(newOrExisting) { toggleButtonText: function(newOrExisting) {
if (this.editMode == 'edit') {
if (this.editMode === 'edit') {
this.button.val('Edit ' + this.baseButtonText); this.button.val('Edit ' + this.baseButtonText);
}
// creating new related individual
else if (newOrExisting === 'new') {
if (this.submitButtonType == 'compound') { // use == to tolerate nulls
// e.g., 'Create Grant & Principal Investigator'
this.button.val('Create ' + this.getTypeName() + ' & ' + this.baseButtonText);
} else {
// e.g., 'Create Publication'
this.button.val('Create ' + this.baseButtonText);
}
} }
// RY Make this better for roles and grants forms later. The verbs // using existing related individual
// don't quite work. It should be "Create X and <role>" vs. else {
// "Create <role>" or "Add <role>"
else if (newOrExisting == 'new') {
this.button.val('Create ' + this.baseButtonText);
}
else {
this.button.val('Add ' + this.baseButtonText); this.button.val('Add ' + this.baseButtonText);
} }
},
getTypeName: function() {
// If there's no type field, the type comes hard-coded in the customFormData.
// Otherwise, get the selected type from the type selector field.
return this.typeName ? this.typeName : this.getSelectedTypeName();
} }
}; };