NIHVIVO-161 Change how the Individual page shows images, editable or non-editable; for Persons or non-Persons, in accordance with the wireframes.
This commit is contained in:
parent
bf0d9bdb08
commit
8dc823f663
3 changed files with 114 additions and 61 deletions
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.jsp.JspException;
|
import javax.servlet.jsp.JspException;
|
||||||
|
@ -44,6 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.filestorage.FileModelHelper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||||
|
|
||||||
|
@ -157,8 +159,10 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(subjectUri, predicateUri, data);
|
ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(subjectUri, predicateUri, data);
|
||||||
links = doObjPropStmt( prop, policyToAccess(ids, policy, prop), contextPath );
|
links = doObjPropStmt( prop, policyToAccess(ids, policy, prop), contextPath );
|
||||||
}
|
}
|
||||||
}
|
} else if (VitroVocabulary.IND_MAIN_IMAGE.equals(predicateUri)) {
|
||||||
else {
|
|
||||||
|
links = doImageLinks(entity, ids, policy, contextPath);
|
||||||
|
} else {
|
||||||
log.error("PropertyEditLinks cannot make links for an object of type " + predicateUri);
|
log.error("PropertyEditLinks cannot make links for an object of type " + predicateUri);
|
||||||
return SKIP_BODY;
|
return SKIP_BODY;
|
||||||
}
|
}
|
||||||
|
@ -234,18 +238,14 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
if( contains( allowedAccessTypeArray, EditLinkAccess.ADDNEW ) ){
|
if( contains( allowedAccessTypeArray, EditLinkAccess.ADDNEW ) ){
|
||||||
log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link");
|
log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link");
|
||||||
LinkStruct ls = null;
|
LinkStruct ls = null;
|
||||||
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp",
|
||||||
ls = getImageLink(subjectUri, contextPath, "add");
|
"subjectUri", subjectUri,
|
||||||
} else {
|
"predicateUri", propertyUri,
|
||||||
String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp",
|
"vitroNsProp", "true");
|
||||||
"subjectUri", subjectUri,
|
ls = new LinkStruct();
|
||||||
"predicateUri", propertyUri,
|
ls.setHref( url );
|
||||||
"vitroNsProp", "true");
|
ls.setType("add");
|
||||||
ls = new LinkStruct();
|
ls.setMouseoverText("add a new entry");
|
||||||
ls.setHref( url );
|
|
||||||
ls.setType("add");
|
|
||||||
ls.setMouseoverText("add a new entry");
|
|
||||||
}
|
|
||||||
links[0] = ls;
|
links[0] = ls;
|
||||||
} else {
|
} else {
|
||||||
log.debug("no add link generated for vitro namespace property "+propertyUri);
|
log.debug("no add link generated for vitro namespace property "+propertyUri);
|
||||||
|
@ -345,17 +345,6 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
|
|
||||||
LinkStruct[] links = new LinkStruct[2];
|
LinkStruct[] links = new LinkStruct[2];
|
||||||
|
|
||||||
if (predicateUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
|
||||||
if( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){
|
|
||||||
log.debug("permission found to UPDATE vitro namepsace property statement "+ predicateUri);
|
|
||||||
links[0] = getImageLink(subjectUri, contextPath, "edit");
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.debug("NO permission found to DELETE vitro namespace property " + predicateUri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String value = dpropStmt.getData();
|
String value = dpropStmt.getData();
|
||||||
Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel");
|
Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel");
|
||||||
|
|
||||||
|
@ -479,6 +468,53 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected LinkStruct[] doImageLinks(Individual entity,
|
||||||
|
IdentifierBundle ids, PolicyIface policy, String contextPath) {
|
||||||
|
Individual mainImage = FileModelHelper.getMainImage(entity);
|
||||||
|
|
||||||
|
String subjectUri = entity.getURI();
|
||||||
|
String predicateUri = VitroVocabulary.IND_MAIN_IMAGE;
|
||||||
|
|
||||||
|
if (mainImage == null) {
|
||||||
|
EditLinkAccess[] accesses = policyToAccess(ids, policy, subjectUri,
|
||||||
|
predicateUri);
|
||||||
|
|
||||||
|
if (contains(accesses, EditLinkAccess.ADDNEW)) {
|
||||||
|
log.debug("permission to ADD main image to " + subjectUri);
|
||||||
|
return new LinkStruct[] { getImageLink(subjectUri, contextPath,
|
||||||
|
"edit", "upload an image") };
|
||||||
|
} else {
|
||||||
|
log.debug("NO permission to ADD main image to " + subjectUri);
|
||||||
|
return empty_array;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(
|
||||||
|
subjectUri, predicateUri, mainImage.getURI());
|
||||||
|
EditLinkAccess[] allowedAccessTypeArray = policyToAccess(ids,
|
||||||
|
policy, prop);
|
||||||
|
|
||||||
|
List<LinkStruct> links = new ArrayList<LinkStruct>();
|
||||||
|
if (contains(allowedAccessTypeArray, EditLinkAccess.MODIFY)) {
|
||||||
|
log.debug("permission to MODIFY main image to " + subjectUri);
|
||||||
|
links.add(getImageLink(subjectUri, contextPath, "edit",
|
||||||
|
"replace this image"));
|
||||||
|
} else {
|
||||||
|
log.debug("NO permission to MODIFY main image to "
|
||||||
|
+ subjectUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contains(allowedAccessTypeArray, EditLinkAccess.DELETE)) {
|
||||||
|
log.debug("permission to DELETE main image to " + subjectUri);
|
||||||
|
links.add(getImageLink(subjectUri, contextPath, "delete",
|
||||||
|
"delete this image"));
|
||||||
|
} else {
|
||||||
|
log.debug("NO permission to DELETE main image to "
|
||||||
|
+ subjectUri);
|
||||||
|
}
|
||||||
|
return links.toArray(new LinkStruct[links.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ********************* utility methods ********************************* */
|
/* ********************* utility methods ********************************* */
|
||||||
protected static String makeRelativeHref( String baseUrl, String ... queries ) {
|
protected static String makeRelativeHref( String baseUrl, String ... queries ) {
|
||||||
|
@ -636,15 +672,16 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
|
|
||||||
private LinkStruct[] empty_array = {};
|
private LinkStruct[] empty_array = {};
|
||||||
|
|
||||||
private LinkStruct getImageLink(String subjectUri, String contextPath, String action) {
|
private LinkStruct getImageLink(String subjectUri, String contextPath,
|
||||||
LinkStruct ls = new LinkStruct();
|
String action, String mouseOverText) {
|
||||||
String url = makeRelativeHref(contextPath + "uploadimages.jsp",
|
LinkStruct ls = new LinkStruct();
|
||||||
"entityUri", subjectUri);
|
String url = makeRelativeHref(contextPath + "uploadimages.jsp",
|
||||||
ls.setHref(url);
|
"entityUri", subjectUri);
|
||||||
ls.setType(action);
|
ls.setHref(url);
|
||||||
ls.setMouseoverText("upload a new image");
|
ls.setType(action);
|
||||||
return ls;
|
ls.setMouseoverText(mouseOverText);
|
||||||
}
|
return ls;
|
||||||
|
}
|
||||||
|
|
||||||
private String getObjPropMouseoverLabel(String propertyUri) {
|
private String getObjPropMouseoverLabel(String propertyUri) {
|
||||||
String mouseoverText = "relationship"; // default
|
String mouseoverText = "relationship"; // default
|
||||||
|
|
BIN
webapp/web/images/dummyImages/person.thumbnail.jpg
Normal file
BIN
webapp/web/images/dummyImages/person.thumbnail.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -76,6 +76,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
||||||
<c:set var='portal' value='${currentPortalId}'/>
|
<c:set var='portal' value='${currentPortalId}'/>
|
||||||
<c:set var='portalBean' value='${currentPortal}'/>
|
<c:set var='portalBean' value='${currentPortal}'/>
|
||||||
|
|
||||||
|
|
||||||
<c:set var='themeDir'><c:out value='${portalBean.themeDir}' /></c:set>
|
<c:set var='themeDir'><c:out value='${portalBean.themeDir}' /></c:set>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
@ -186,38 +187,53 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
||||||
<%-- Thumbnail (with citation) --%>
|
<%-- Thumbnail (with citation) --%>
|
||||||
<c:if test="${showEdits || !empty entity.thumbUrl}">
|
<c:set var="isPerson" value="<%= entity.isVClass("http://xmlns.com/foaf/0.1/Person") %>" />
|
||||||
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
|
<c:set var="hasImage" value="${!empty entity.thumbUrl}" />
|
||||||
<c:set var="mayEditImage"><edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" icons="false" /></c:set>
|
<c:set var="imageLinks"><edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" icons="false" /></c:set>
|
||||||
<c:if test="${showEdits and !empty mayEditImage}">
|
<c:choose>
|
||||||
<h3 class="propertyName">image</h3>
|
<c:when test="${!isPerson && !hasImage}">
|
||||||
<edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" icons="false" />
|
<c:if test="${showEdits && !empty imageLinks}">
|
||||||
</c:if>
|
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
|
||||||
<c:if test="${!empty entity.thumbUrl}">
|
<h3 class="propertyName">image</h3>
|
||||||
|
${imageLinks}
|
||||||
|
</div>
|
||||||
|
</c:if>
|
||||||
|
</c:when>
|
||||||
|
<c:when test="${isPerson && !hasImage}">
|
||||||
|
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
|
||||||
<div class="datatypeProperties">
|
<div class="datatypeProperties">
|
||||||
<div class="datatypePropertyValue">
|
<div class="datatypePropertyValue">
|
||||||
<div class="statementWrap thumbnail">
|
<div class="statementWrap thumbnail">
|
||||||
<c:set var="imageTitle" value="${entity.name}" />
|
<img src="<c:url value='/images/dummyImages/person.thumbnail.jpg'/>"
|
||||||
<c:if test="${!empty entity.imageUrl}">
|
title="no image" alt="" width="150"/>
|
||||||
<a class="image" href="<c:url value='${entity.imageUrl}'/>">
|
<c:if test="${showEdits}">
|
||||||
<c:set var="imageTitle" value="click to view larger image in new window" />
|
<span class="editLinks">${imageLinks}</span>
|
||||||
</c:if>
|
</c:if>
|
||||||
<img src="<c:url value='${entity.thumbUrl}'/>" title="${imageTitle}" alt="" width="150"/>
|
|
||||||
<c:if test="${!empty entity.imageUrl}"></a></c:if>
|
|
||||||
<c:if test="${showEdits}">
|
|
||||||
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" data="${entity.thumbUrl}" icons="false"/></c:set>
|
|
||||||
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
|
|
||||||
</c:if>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<%-- Citation --%>
|
</c:when>
|
||||||
<jsp:include page="entityCitation.jsp" />
|
<c:otherwise> <%-- hasImage --%>
|
||||||
|
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
|
||||||
</c:if>
|
<div class="datatypeProperties">
|
||||||
</div>
|
<div class="datatypePropertyValue">
|
||||||
</c:if>
|
<div class="statementWrap thumbnail">
|
||||||
|
<a class="image" href="<c:url value='${entity.imageUrl}'/>">
|
||||||
|
<img src="<c:url value='${entity.thumbUrl}'/>"
|
||||||
|
title="click to view larger image in new window"
|
||||||
|
alt="" width="150"/>
|
||||||
|
</a>
|
||||||
|
<c:if test="${showEdits}">
|
||||||
|
<span class="editLinks">${imageLinks}</span>
|
||||||
|
</c:if>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<jsp:include page="entityCitation.jsp" />
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
|
||||||
<%-- Description --%>
|
<%-- Description --%>
|
||||||
<c:if test="${ showEdits || !empty entity.description}">
|
<c:if test="${ showEdits || !empty entity.description}">
|
||||||
|
|
Loading…
Add table
Reference in a new issue