NIHVIVO-200 Incorporate the <span> tag that wraps front end editing links into the custom tag, so that if there are no links, we don't get the span.
NIHVIVO-142 Various tweaks to front end editing.
This commit is contained in:
parent
e8c272e4ff
commit
8cd54743d5
6 changed files with 52 additions and 40 deletions
|
@ -21,7 +21,8 @@ public class VitroVocabulary {
|
|||
public static final String RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
public static final String RDFS = "http://www.w3.org/2000/01/rdf-schema#";
|
||||
public static final String RDF_TYPE = RDF+"type";
|
||||
|
||||
public static final String LABEL = RDFS + "label";
|
||||
|
||||
public static final String SUBCLASS_OF = RDFS+"subClassOf";
|
||||
|
||||
public static final String OWL = "http://www.w3.org/2002/07/owl#";
|
||||
|
|
|
@ -45,7 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
/**
|
||||
* JSP tag to generate the HTML of links for edit, delete or
|
||||
|
@ -146,12 +146,15 @@ public class PropertyEditLinks extends TagSupport{
|
|||
} else {
|
||||
try{
|
||||
JspWriter out = pageContext.getOut();
|
||||
if( links != null ){
|
||||
if( links != null && links.length > 0){
|
||||
// Include the wrapping span here, rather than in the JSP, so if there are no links we don't get the span.
|
||||
out.print("<span class=\"editLinks\">");
|
||||
for( LinkStruct ln : links ){
|
||||
if( ln != null ){
|
||||
out.print( makeElement( ln ) + '\n' );
|
||||
}
|
||||
}
|
||||
out.print("</span>");
|
||||
}
|
||||
} catch(IOException ioe){
|
||||
log.error( ioe );
|
||||
|
@ -327,7 +330,7 @@ public class PropertyEditLinks extends TagSupport{
|
|||
int index = 0;
|
||||
|
||||
boolean deleteAllowed = ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) &&
|
||||
!( predicateUri.endsWith("#label") || predicateUri.endsWith("#type") ) );
|
||||
!( predicateUri.equals(VitroVocabulary.LABEL)) || predicateUri.equals(VitroVocabulary.RDF_TYPE) );
|
||||
|
||||
if( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){
|
||||
log.debug("permission found to UPDATE vitro namepsace property statement "+ predicateUri);
|
||||
|
@ -495,25 +498,6 @@ public class PropertyEditLinks extends TagSupport{
|
|||
return access;
|
||||
}
|
||||
|
||||
// protected EditLinkAccess[] policyToAccess( IdentifierBundle ids, PolicyIface policy, String subjectUri, String propertyUri) {
|
||||
//
|
||||
// ArrayList<EditLinkAccess> list = new ArrayList<EditLinkAccess>(2);
|
||||
//
|
||||
// RequestedAction action = new EditDataPropStmt(subjectUri, propertyUri, (String) null);
|
||||
// PolicyDecision dec = policy.isAuthorized(ids, action);
|
||||
// if ( dec != null && dec.getAuthorized() == Authorization.AUTHORIZED ){
|
||||
// list.add( EditLinkAccess.MODIFY);
|
||||
// }
|
||||
//
|
||||
// action = new DropDataPropStmt(subjectUri, propertyUri, (String) null);
|
||||
// dec = policy.isAuthorized(ids, action);
|
||||
// if( dec != null && dec.getAuthorized() == Authorization.AUTHORIZED ){
|
||||
// list.add( EditLinkAccess.DELETE );
|
||||
// }
|
||||
//
|
||||
// return list.toArray(ACCESS_TEMPLATE);
|
||||
// }
|
||||
|
||||
public enum EditLinkAccess{ MODIFY, DELETE, ADDNEW, INFO, ADMIN };
|
||||
|
||||
public class LinkStruct {
|
||||
|
|
|
@ -204,10 +204,16 @@ public class RdfLiteralHashTest {
|
|||
|
||||
int hash = RdfLiteralHash.makeVitroNsLiteralHash(bob,VitroVocabulary.MONIKER, "great", model);
|
||||
DataPropertyStatement stmt = RdfLiteralHash.getVitroNsPropertyStmtByHash(bob, model, hash);
|
||||
|
||||
Assert.assertEquals("great", stmt.getData());
|
||||
Assert.assertEquals(XSD.xstring.getURI(), stmt.getDatatypeURI());
|
||||
Assert.assertEquals(VitroVocabulary.MONIKER, stmt.getDatapropURI());
|
||||
Assert.assertEquals("http://example.com/bob", stmt.getIndividualURI());
|
||||
|
||||
String data = stmt.getData();
|
||||
String datatypeUri = stmt.getDatatypeURI();
|
||||
String predicateUri = stmt.getDatapropURI();
|
||||
String subjectUri = stmt.getIndividualURI();
|
||||
|
||||
Assert.assertEquals("great", data);
|
||||
Assert.assertEquals(XSD.xstring.getURI(), datatypeUri);
|
||||
Assert.assertEquals(VitroVocabulary.MONIKER, predicateUri);
|
||||
Assert.assertEquals("http://example.com/bob", subjectUri);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
"literalOptions" : [ ${rangeDefaultJson} ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${rangeDatatypeUriJson}" ,
|
||||
"rangeDatatypeUri" : "${rangeDatatypeUriJson}",
|
||||
"rangeLang" : "${rangeLangJson}",
|
||||
"assertions" : ["${n3ForEdit}"]
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
||||
|
@ -34,6 +35,14 @@
|
|||
if( subject == null ) {
|
||||
throw new Error("In vitroNsEditLabelForm.jsp, could not find subject " + subjectUri);
|
||||
}
|
||||
|
||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||
|
||||
// RY ***** Get the rangeDatatypeUri - need to get it from the
|
||||
//String rangeDatatypeUri = vreq.getWebappDaoFactory().getDataPropertyDao().getRequiredDatatypeURI(subject, prop);
|
||||
//String rangeDatatypeUri = prop.getRangeDatatypeURI();
|
||||
String rangeDatatypeUri = "http://www.w3.org/2001/XMLSchema#string";
|
||||
vreq.setAttribute("rangeDatatypeUriJson", MiscWebUtils.escape(rangeDatatypeUri));
|
||||
|
||||
%>
|
||||
|
||||
|
@ -97,7 +106,7 @@
|
|||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "",
|
||||
"rangeDatatypeUri" : "${rangeDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : [ "${dataAssertion}" ]
|
||||
}
|
||||
|
@ -117,7 +126,6 @@
|
|||
}
|
||||
|
||||
if ( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
|
||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||
editConfig.prepareForDataPropUpdate(model,dps);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginFormBean" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
|
||||
|
||||
<%@ page import="org.apache.commons.logging.Log" %>
|
||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||
|
||||
<%@ page import="java.util.List" %>
|
||||
|
||||
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
|
||||
|
@ -24,6 +27,10 @@ log.debug("Starting entityBasic.jsp");
|
|||
Individual entity = (Individual)request.getAttribute("entity");
|
||||
%>
|
||||
|
||||
<c:set var="labelUri" value="http://www.w3.org/2000/01/rdf-schema#label" />
|
||||
<c:set var="typeUri" value="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" />
|
||||
<c:set var="vitroUri" value="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" />
|
||||
|
||||
<c:if test="${!empty entityURI}">
|
||||
<c:set var="myEntityURI" scope="request" value="${entityURI}"/>
|
||||
<%
|
||||
|
@ -78,9 +85,12 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<c:set var='portal' value='${currentPortalId}'/>
|
||||
<c:set var='portalBean' value='${currentPortal}'/>
|
||||
|
||||
<%-- Using VitroVocabulary constants instead.
|
||||
RY Description not working - FIX
|
||||
<c:set var="labelUri" value="http://www.w3.org/2000/01/rdf-schema#label" />
|
||||
<c:set var="typeUri" value="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" />
|
||||
<c:set var="vitroNsUri" value="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" />
|
||||
<c:set var="vitroUri" value="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" />
|
||||
--%>
|
||||
|
||||
<c:set var='themeDir'><c:out value='${portalBean.themeDir}' /></c:set>
|
||||
|
||||
|
@ -104,7 +114,8 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<div class="statementWrap">
|
||||
<h2><p:process>${entity.name}</p:process></h2>
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${labelUri}" data="${entity.name}" icons="false"/></span>
|
||||
<%-- <span class="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.LABEL %>" data="${entity.name}" icons="false"/></span> --%>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.LABEL %>" data="${entity.name}" icons="false"/>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -114,7 +125,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<div class="statementWrap">
|
||||
<p:process><em class="moniker">${entity.moniker}</em></p:process>
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${vitroNsUri}moniker" data="${entity.moniker}" icons="false"/></span>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.MONIKER %>" data="${entity.moniker}" icons="false"/>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -140,9 +151,11 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<li class="primary"><span class="externalLink"><p:process>${entity.anchor}</p:process></span></li>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<%--
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${vitroNsUri}url" data="${entity.url}" icons="false"/></span>
|
||||
</c:if>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.LINK_ANCHOR %>" data="${entity.anchor}" icons="false"/>
|
||||
</c:if>
|
||||
--%>
|
||||
</c:if>
|
||||
<c:if test="${!empty entity.linksList }">
|
||||
<c:forEach items="${entity.linksList}" var='link' varStatus="count">
|
||||
|
@ -173,7 +186,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<div class="statementWrap">
|
||||
<div class="citation">${entity.citation}</div>
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${vitroNsUri}citation" data="${entity.citation}" icons="false"/></span>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.CITATION %>" data="${entity.citation}" icons="false"/>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -185,7 +198,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<div class="statementWrap">
|
||||
<div class="description">${entity.blurb}</div>
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${vitroNsUri}blurb" data="${entity.blurb}" icons="false"/></span>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.BLURB %>" data="${entity.blurb}" icons="false"/>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -195,7 +208,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<div class="statementWrap">
|
||||
<div class="description">${entity.description}</div>
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${vitroNsUri}description" data="${entity.description}" icons="false"/></span>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.DESCRIPTION %>" data="${entity.description}" icons="false"/>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -224,7 +237,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
|||
<div class="statementWrap">
|
||||
<div class="citation">${entity.citation}</div>
|
||||
<c:if test="${showEdits}">
|
||||
<span class="editLinks"><edLnk:editLinks item="${vitroNsUri}citation" data="${entity.citation}" icons="false"/></span>
|
||||
<edLnk:editLinks item="<%= VitroVocabulary.CITATION %>" data="${entity.citation}" icons="false"/>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue