NIHVIVO-1871 Added repair mode to personInPosition custom form. Consolidated common code to determine mode into a method in FrontEndEditingUtils and removed from individual forms.
This commit is contained in:
parent
8b51f4552b
commit
c80ba7eaf3
2 changed files with 64 additions and 50 deletions
|
@ -19,6 +19,9 @@
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%>
|
||||
|
||||
<%@ page import="org.apache.commons.logging.Log" %>
|
||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||
|
@ -37,6 +40,29 @@
|
|||
|
||||
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
||||
|
||||
/*
|
||||
There are 4 modes that this form can be in:
|
||||
1. Add, there is a subject and a predicate but no position and nothing else.
|
||||
|
||||
2. normal edit where everything should already be filled out. There is a subject, a object and an individual on
|
||||
the other end of the object's core:personInOrganization stmt.
|
||||
|
||||
3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the
|
||||
other end of the object's core:personInOrganization stmt. This should be similar to an add but the form should be expanded.
|
||||
|
||||
4. Really bad node. multiple core:personInOrganization statements.
|
||||
*/
|
||||
|
||||
EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#positionInOrganization");
|
||||
|
||||
if( mode == EditMode.ADD ) {
|
||||
%> <c:set var="editMode" value="add"/><%
|
||||
} else if(mode == EditMode.EDIT){
|
||||
%> <c:set var="editMode" value="edit"/><%
|
||||
} else if(mode == EditMode.REPAIR){
|
||||
%> <c:set var="editMode" value="repair"/><%
|
||||
}
|
||||
%>
|
||||
|
||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
||||
|
@ -210,24 +236,19 @@
|
|||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
|
||||
|
||||
<%-- Configure add vs. edit --%>
|
||||
<%
|
||||
|
||||
String objectUri = (String) request.getAttribute("objectUri");
|
||||
if (objectUri != null) { // editing existing entry
|
||||
%>
|
||||
<c:set var="editMode" value="edit" />
|
||||
<c:set var="titleVerb" value="Edit" />
|
||||
<c:set var="submitButtonText" value="Edit Position" />
|
||||
<c:set var="disabledVal" value="disabled" />
|
||||
<%
|
||||
} else { // adding new entry
|
||||
%>
|
||||
<c:set var="editMode" value="add" />
|
||||
<%-- Configure add vs. edit --%>
|
||||
<c:choose>
|
||||
<c:when test='${editMode == "add"}'>
|
||||
<c:set var="titleVerb" value="Create" />
|
||||
<c:set var="submitButtonText" value="Position" />
|
||||
<c:set var="disabledVal" value="" />
|
||||
<% } %>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:set var="titleVerb" value="Edit" />
|
||||
<c:set var="submitButtonText" value="Edit Position" />
|
||||
<c:set var="disabledVal">${editMode == "repair" ? "" : "" }</c:set>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<c:set var="editjson" scope="request">
|
||||
{
|
||||
|
@ -356,7 +377,7 @@
|
|||
</c:set>
|
||||
|
||||
<%
|
||||
log.debug(request.getAttribute("editjson"));
|
||||
//log.debug(request.getAttribute("editjson"));
|
||||
|
||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
||||
if (editConfig == null) {
|
||||
|
@ -375,6 +396,7 @@
|
|||
|
||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
||||
|
||||
String objectUri = (String) request.getAttribute("objectUri");
|
||||
if (objectUri != null) { // editing existing
|
||||
editConfig.prepareForObjPropUpdate(model);
|
||||
} else { // adding new
|
||||
|
@ -398,6 +420,11 @@
|
|||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
<% if( mode == EditMode.ERROR ){ %>
|
||||
<div>This form is unable to handle the editing of this position because it is associated with
|
||||
multiple Position individuals.</div>
|
||||
<% }else{ %>
|
||||
|
||||
<h2>${titleVerb} position entry for <%= subjectName %></h2>
|
||||
|
||||
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
|
@ -441,8 +468,10 @@
|
|||
var customFormData = {
|
||||
acUrl: '${acUrl}',
|
||||
editMode: '${editMode}',
|
||||
submitButtonTextType: 'compound'
|
||||
submitButtonTextType: 'compound',
|
||||
defaultTypeName: 'organization' // used in repair mode, to generate button text and org name field label
|
||||
};
|
||||
</script>
|
||||
<% } %>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue