working on freemarker custom forms
This commit is contained in:
parent
239e5db4b0
commit
488f71b1c8
6 changed files with 403 additions and 187 deletions
|
@ -320,6 +320,15 @@
|
|||
<servlet-name>IndexController</servlet-name>
|
||||
<url-pattern>/SearchIndex</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>N3EditFormController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.N3EditFormController</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>N3EditFormController</servlet-name>
|
||||
<url-pattern>/N3EditForm</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- This is the new navigation controller. It is not ready for the 1.1 release
|
||||
see http://issues.library.cornell.edu/browse/NIHVIVO-597
|
||||
|
|
|
@ -68,6 +68,7 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
%>
|
||||
|
||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
||||
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
|
||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||
<c:set var="label" value="${rdfs}label" />
|
||||
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
|
||||
|
@ -75,13 +76,17 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
|
||||
<%-- Define predicates used in n3 assertions and sparql queries --%>
|
||||
<c:set var="majorFieldPred" value="${vivoCore}majorField" />
|
||||
<c:set var="yearPred" value="${vivoCore}year" />
|
||||
<c:set var="deptPred" value="${vivoCore}departmentOrSchool" />
|
||||
<c:set var="infoPred" value="${vivoCore}supplementalInformation" />
|
||||
<c:set var="degreeEarned" value="${vivoCore}degreeEarned" />
|
||||
<c:set var="degreeOutcomeOf" value="${vivoCore}degreeOutcomeOf" />
|
||||
<c:set var="orgGrantingDegree" value="${vivoCore}organizationGrantingDegree" />
|
||||
|
||||
<c:set var="hasDateTimeValue" value="${vivoCore}hasDateTimeValue"/>
|
||||
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
|
||||
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
|
||||
<c:set var="edToDateTime" value="${vivoCore}dateTimeInterval"/>
|
||||
|
||||
<%-- For new datetime handling in ontology - v1.2
|
||||
<c:set var="dateTimeValue" value="${vivoCore}DateTimeValue" />
|
||||
<c:set var="hasDateTimeValue" value="${vivoCore}dateTimeValue" />
|
||||
|
@ -120,8 +125,11 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
?edTraining <${majorFieldPred}> ?majorField .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="yearAssertion" >
|
||||
?edTraining <${yearPred}> ?year .
|
||||
<v:jsonset var="dateTimeAssertions">
|
||||
?edTraining <${edToDateTime}> ?dateTimeNode .
|
||||
?dateTimeNode <${type}> <${dateTimeValueType}> .
|
||||
?dateTimeNode <${hasDateTimeValue}> ?dateTime.value .
|
||||
?dateTimeNode <${dateTimePrecision}> ?dateTime.precision .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="deptAssertion" >
|
||||
|
@ -178,11 +186,6 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
?edTraining <${majorFieldPred}> ?existingMajorField . }
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="yearQuery" >
|
||||
SELECT ?existingYear WHERE {
|
||||
?edTraining <${yearPred}> ?existingYear . }
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="deptQuery" >
|
||||
SELECT ?existingDept WHERE {
|
||||
?edTraining <${deptPred}> ?existingDept . }
|
||||
|
@ -207,25 +210,25 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
"predicate" : ["predicate", "${predicateUriJson}" ],
|
||||
"object" : ["edTraining", "${objectUriJson}", "URI" ],
|
||||
|
||||
"n3required" : [ "${n3ForNewEdTraining}", "${majorFieldAssertion}", "${orgLabelAssertion}", "${orgTypeAssertion}" ],
|
||||
"n3required" : [ "${n3ForNewEdTraining}", "${majorFieldAssertion}", "${orgLabelAssertion}", "${orgTypeAssertion}", "${dateTimeAssertions}" ],
|
||||
|
||||
"n3optional" : [ "${n3ForEdTrainingToOrg}",
|
||||
"${degreeAssertion}", "${deptAssertion}", "${infoAssertion}", "${yearAssertion}" ],
|
||||
"${degreeAssertion}", "${deptAssertion}", "${infoAssertion}" ],
|
||||
|
||||
"newResources" : { "edTraining" : "${defaultNamespace}",
|
||||
"org" : "${defaultNamespace}" },
|
||||
"org" : "${defaultNamespace}" ,
|
||||
"dateTimeNode" : "${defaultNamespace}" },
|
||||
|
||||
"urisInScope" : { },
|
||||
"literalsInScope": { },
|
||||
"urisOnForm" : [ "org", "orgType", "degree" ],
|
||||
"literalsOnForm" : [ "orgLabel", "majorField", "year", "dept", "info" ],
|
||||
"literalsOnForm" : [ "orgLabel", "majorField", "dept", "info" ],
|
||||
"filesOnForm" : [ ],
|
||||
"sparqlForLiterals" : { },
|
||||
"sparqlForUris" : { },
|
||||
"sparqlForExistingLiterals" : {
|
||||
"orgLabel" : "${orgLabelQuery}",
|
||||
"majorField" : "${majorFieldQuery}",
|
||||
"year" : "${yearQuery}",
|
||||
"dept" : "${deptQuery}",
|
||||
"info" : "${infoQuery}"
|
||||
},
|
||||
|
@ -256,18 +259,19 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : [ "${majorFieldAssertion}" ]
|
||||
},
|
||||
"year" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "datatype:${gYearDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${gYearDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${yearAssertion}"]
|
||||
},
|
||||
},
|
||||
"dateTime" : {
|
||||
"editElement" : "edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision",
|
||||
"newResource" : "true",
|
||||
"validators" : [ ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "",
|
||||
"rangeLang" : "",
|
||||
"assertions" : [ "${dateTimeAssertions}" ]
|
||||
},
|
||||
"org" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ ],
|
||||
|
@ -334,7 +338,7 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
|
||||
EditConfiguration.putConfigInSession(editConfig,session);
|
||||
}
|
||||
|
||||
|
||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
||||
String objectUri = (String) request.getAttribute("objectUri");
|
||||
if (objectUri != null) { // editing existing
|
||||
|
@ -343,26 +347,14 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
editConfig.prepareForNonUpdate(model);
|
||||
}
|
||||
|
||||
editConfig.setTemplate("personHasEducationalTraining.ftl");
|
||||
editConfig.setSubmitToUrl("/edit/processRdfForm2.jsp");
|
||||
|
||||
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
||||
%>
|
||||
|
||||
<c:set var="subjectName" value="<%= subjectName %>" />
|
||||
<%
|
||||
if (objectUri != null) { // editing existing entry
|
||||
%>
|
||||
<c:set var="editMode" value="edit" />
|
||||
<c:set var="titleVerb" value="Edit" />
|
||||
<c:set var="title" value="Edit educational background entry for ${subjectName}" />
|
||||
<c:set var="submitButtonText" value="Edit Educational Training" />
|
||||
<c:set var="disabledVal" value="disabled" />
|
||||
<%
|
||||
} else { // adding new entry
|
||||
%>
|
||||
<c:set var="editMode" value="add" />
|
||||
<c:set var="titleVerb" value="Create" />
|
||||
<c:set var="submitButtonText" value="Educational Training" />
|
||||
<c:set var="disabledVal" value="" />
|
||||
<% }
|
||||
|
||||
|
||||
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||
|
@ -377,8 +369,14 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
request.setAttribute("customCss", customCss);
|
||||
%>
|
||||
|
||||
<jsp:forward page="/N3EditForm"/>
|
||||
|
||||
<%--
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
|
||||
|
||||
|
||||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
|
@ -390,21 +388,19 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
|||
|
||||
<v:input type="text" label="Major Field of Degree ${requiredHint}" id="majorField" size="30" />
|
||||
|
||||
<v:input type="text" label="Year ${yearHint}" id="year" size="4" />
|
||||
<v:input id="dateTime" />
|
||||
|
||||
<p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p>
|
||||
|
||||
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||
|
||||
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
|
||||
returning from a validation error, we retain the values. --%>
|
||||
<c:if test="${editMode == 'edit'}">
|
||||
<v:input type="hidden" id="orgType" />
|
||||
<v:input type="hidden" id="orgLabel" />
|
||||
</c:if>
|
||||
|
||||
<div class="acSelection">
|
||||
<%-- RY maybe make this a label and input field. See what looks best. --%>
|
||||
|
||||
<p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
|
||||
<v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
@ -430,4 +426,4 @@ var customFormData = {
|
|||
};
|
||||
</script>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
--%>
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- this is in request.subject.name -->
|
||||
<#assign subjectName = "Bogus, Al">
|
||||
|
||||
<#-- where is the context path suppose to come from? -->
|
||||
<#assign contextPath = "/vivo">
|
||||
|
||||
<#assign editMode="edit">
|
||||
<#assign editMode=editConfig.object!"add">
|
||||
|
||||
<#if editMode == "edit">
|
||||
<#assign titleVerb="Edit">
|
||||
<#assign title="Edit educational background entry for subjectName" />
|
||||
<#assign submitButtonText="Edit Educational Training">
|
||||
<#assign disabledVal="disabled">
|
||||
<#else>
|
||||
<#assign titleVerb="Create">
|
||||
<#assign submitButtonText="Educational Training">
|
||||
<#assign disabledVal=""/>
|
||||
</#if>
|
||||
<#assign requiredHint="<span class='requiredHint'> *</span>"/>
|
||||
|
||||
|
||||
<div class="form">
|
||||
<h2>${titleVerb} educational training entry for ${subjectName}</h2>
|
||||
|
||||
<form class="${editMode}" action="${contextPath}${editConfig.submitToUrl}" >
|
||||
|
||||
<div class="entry">
|
||||
<label for="degreeUri">Degree</label>
|
||||
<select name="degreeUri" id="degreeUri" >
|
||||
<option value="" selected="selected">Select one</option>
|
||||
<@widget name="SelectList" fieldName="degree" />
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label for="majorField">Major Field of Degree ${requiredHint}</label>
|
||||
<input type="text" id="majorField" name="majorField" size="30" />
|
||||
|
||||
<@widget name="editElement" name="dateTime" />
|
||||
|
||||
<div class="relatedIndividual">
|
||||
<div class="existing">
|
||||
<label for="org">Organization Granting Degree ${requiredHint}</label>
|
||||
<select id="org" name="org">
|
||||
<@widget name="SelectList" fieldName="org" />
|
||||
</select>
|
||||
<span class="existingOrNew">or</span>
|
||||
</div>
|
||||
<div class="addNewLink">
|
||||
If your organization is not listed, please <a href="#">add a new organization</a>.
|
||||
</div>
|
||||
|
||||
<div class="new">
|
||||
<h6>Add a New Organization</h6>
|
||||
<label for="newOrgName">Organization Name <span class='requiredHint'> *</span></label>
|
||||
<input size="30" type="text" id="newOrgName" name="newOrgName" value="" />
|
||||
|
||||
<label for="newOrgType">Select Organization Type <span class='requiredHint'> *</span></label>
|
||||
<select id="newOrgType" name="newOrgType">
|
||||
<option value="" selected="selected">Select one</option>
|
||||
<@widget name="SelectList" fieldName="orgType" />
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="entry">
|
||||
<label for="dept">Department or School Name within the Organization</label>
|
||||
<input size="50" type="text" id="dept" name="dept" value="" />
|
||||
|
||||
<label for="info">Supplemental Information</label>
|
||||
<input size="50" type="text" id="info" name="info" value="" />
|
||||
<p>e.g., <em>Postdoctoral training</em> or <em>Transferred</em></p>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="submit">
|
||||
<input name="editKey" type="hidden" value="${editConfig.editKey}" />
|
||||
<input type="submit" id="submit" value="${submitButtonText}"/>
|
||||
|
||||
<#assign cancelParams = "editKey=${editConfig.editKey}&cancel=true" >
|
||||
<span class="or">or</span><a class="cancel" href="${contextPath}/edit/postEditCleanUp.jsp?${cancelParams?url}" title="Cancel">Cancel</a>
|
||||
</p>
|
||||
|
||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||
</form>
|
||||
|
||||
<#assign acUrl="/autocomplete?tokenize=true&stem=true" >
|
||||
|
||||
<script type="text/javascript">
|
||||
var customFormData = {
|
||||
acUrl: '${acUrl?url}',
|
||||
editMode: '${editMode}',
|
||||
submitButtonTextType: 'compound',
|
||||
defaultTypeName: 'organization'
|
||||
};
|
||||
</script>
|
||||
|
||||
</div>
|
|
@ -1,6 +1,12 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
${fieldName}<br/>
|
||||
<#--
|
||||
This is the placeholder template for the dateTime with precision input element.
|
||||
The UI team should replace any or all of the text in this file.
|
||||
-->
|
||||
|
||||
<div>
|
||||
${fieldName}
|
||||
<br/>
|
||||
year: <input name="${fieldName}.year" type="text" value="${year}"/> <br/>
|
||||
month: <input name="${fieldName}.month" type="text" value="${month}"/> <br/>
|
||||
|
@ -8,4 +14,4 @@ day: <input name="${fieldName}.day" type="text" value="${day}"/> <br/>
|
|||
hour: <input name="${fieldName}.hour" type="text" value="${hour}"/> <br/>
|
||||
minute: <input name=${fieldName}.minute" type="text" value="${minute}"/> <br/>
|
||||
second: <input name=${fieldName}.second" type="text" value="${second}"/> <br/>
|
||||
<br/>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue