NIHVIVO-142 Add/edit/delete blurb on front end
This commit is contained in:
parent
bcbe290c51
commit
54c5019347
4 changed files with 98 additions and 47 deletions
|
@ -38,12 +38,22 @@ public class StringUtils {
|
||||||
return join(list, false, ",");
|
return join(list, false, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String quotedList(List<?> list, String glue) {
|
public static String quotedList(List<?> list, String glue) {
|
||||||
|
|
||||||
return join(list, true, glue);
|
return join(list, true, glue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Because we can't use Java 1.6 String.isEmpty()
|
||||||
public static boolean isEmpty(String s) {
|
public static boolean isEmpty(String s) {
|
||||||
return s == null || s.length() <= 0;
|
return s == null || s.length() <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean equalsOneOf(String s, String... strings) {
|
||||||
|
|
||||||
|
for (String item : strings) {
|
||||||
|
if (item.equals(s)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,4 +71,14 @@ public class StringUtilsTest extends AbstractTestClass {
|
||||||
Assert.assertEquals("\"apple\"|\"banana\"|\"orange\"", StringUtils.quotedList(stringList, "|"));
|
Assert.assertEquals("\"apple\"|\"banana\"|\"orange\"", StringUtils.quotedList(stringList, "|"));
|
||||||
Assert.assertEquals("\"apple\",\"banana\",\"orange\"", StringUtils.quotedList(stringList, null));
|
Assert.assertEquals("\"apple\",\"banana\",\"orange\"", StringUtils.quotedList(stringList, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqualsOneOf() {
|
||||||
|
|
||||||
|
String s1 = "cat";
|
||||||
|
Assert.assertTrue(StringUtils.equalsOneOf(s1, "dog", "mouse", "cat", "horse"));
|
||||||
|
Assert.assertTrue(StringUtils.equalsOneOf(s1, "cat"));
|
||||||
|
Assert.assertFalse(StringUtils.equalsOneOf(s1, "dog", "mouse", "horse"));
|
||||||
|
Assert.assertFalse(StringUtils.equalsOneOf(s1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
<%@ page import="java.util.ArrayList"%>
|
<%@ page import="java.util.ArrayList"%>
|
||||||
<%@ page import="java.util.Arrays"%>
|
<%@ page import="java.util.Arrays"%>
|
||||||
<%@ page import="java.util.HashMap"%>
|
|
||||||
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Model"%>
|
<%@ page import="com.hp.hpl.jena.rdf.model.Model"%>
|
||||||
|
@ -21,9 +20,18 @@
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
private String getInputType(String propertyName) {
|
||||||
|
String inputType = StringUtils.equalsOneOf(propertyName, "blurb", "description") ? "textarea" : "text";
|
||||||
|
return inputType;
|
||||||
|
}
|
||||||
|
String thisPage = "defaultVitroNsPropForm.jsp";
|
||||||
|
String inThisPage = " in " + thisPage;
|
||||||
|
|
||||||
|
%>
|
||||||
<%
|
<%
|
||||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultVitroNsPropForm.jsp");
|
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms." + thisPage);
|
||||||
log.debug("Starting defaultVitroNsPropForm.jsp");
|
log.debug("Starting " + thisPage);
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
|
@ -40,7 +48,7 @@
|
||||||
|
|
||||||
Individual subject = (Individual)vreq.getAttribute("subject");
|
Individual subject = (Individual)vreq.getAttribute("subject");
|
||||||
if( subject == null ) {
|
if( subject == null ) {
|
||||||
throw new Error("In defaultVitroNsPropForm.jsp, could not find subject " + subjectUri);
|
throw new Error("In " + thisPage + ", could not find subject " + subjectUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||||
|
@ -53,17 +61,17 @@
|
||||||
|
|
||||||
rangeDatatypeUri = dps.getDatatypeURI();
|
rangeDatatypeUri = dps.getDatatypeURI();
|
||||||
if (rangeDatatypeUri == null) {
|
if (rangeDatatypeUri == null) {
|
||||||
log.debug("no range datatype uri set on vitro namespace property statement for property " + predicateUri + " in defaultVitroNsPropForm.jsp");
|
log.debug("no range datatype uri set on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||||
} else {
|
} else {
|
||||||
log.debug("range datatype uri of [" + rangeDatatypeUri + "] on vitro namespace property statement for property " + predicateUri + " in defaultVitroNsPropForm.jsp");
|
log.debug("range datatype uri of [" + rangeDatatypeUri + "] on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
rangeLang = dps.getLanguage();
|
rangeLang = dps.getLanguage();
|
||||||
if( rangeLang == null ) {
|
if( rangeLang == null ) {
|
||||||
log.debug("no language attribute on vitro namespace property statement for property " + predicateUri + " in defaultVitroNsPropForm.jsp");
|
log.debug("no language attribute on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||||
rangeLang = "";
|
rangeLang = "";
|
||||||
} else {
|
} else {
|
||||||
log.debug("language attribute of ["+rangeLang+"] on vitro namespace property statement for property " + predicateUri + " in defaultVitroNsPropForm.jsp");
|
log.debug("language attribute of ["+rangeLang+"] on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,18 +169,26 @@
|
||||||
editConfig.prepareForDataPropUpdate(model,dps);
|
editConfig.prepareForDataPropUpdate(model,dps);
|
||||||
}
|
}
|
||||||
|
|
||||||
String propertyLabel = propertyName == "label" ? "name" : propertyName;
|
// Configure form
|
||||||
|
String propertyLabel = propertyName.equals("label") ? "name" : propertyName;
|
||||||
String actionText = dps == null ? "Add new " : "Edit ";
|
String actionText = dps == null ? "Add new " : "Edit ";
|
||||||
String submitLabel = actionText + propertyName;
|
String submitLabel = actionText + propertyLabel;
|
||||||
String title = actionText + propertyName + " for " + subject.getName();
|
String title = actionText + "<em>" + propertyLabel + "</em> for " + subject.getName();
|
||||||
|
|
||||||
|
String inputType = getInputType(propertyName);
|
||||||
|
log.debug(propertyName + " needs input type " + inputType + inThisPage);
|
||||||
|
boolean useTinyMCE = inputType.equals("textarea");
|
||||||
|
log.debug( (useTinyMCE ? "" : "not ") + "using tinyMCE to edit " + propertyName + inThisPage);
|
||||||
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<jsp:include page="${preForm}"/>
|
<jsp:include page="${preForm}">
|
||||||
|
<jsp:param name="useTinyMCE" value="<%= useTinyMCE %>"/>
|
||||||
|
</jsp:include>
|
||||||
|
|
||||||
<h2><%= title %></h2>
|
<h2><%= title %></h2>
|
||||||
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
||||||
<v:input type="text" id="${propertyName}" size="30" />
|
<v:input type="<%= inputType %>" id="${propertyName}" size="30" />
|
||||||
<input type="hidden" name="vitroNsProp" value="true" />
|
<input type="hidden" name="vitroNsProp" value="true" />
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="<%= submitLabel %>" cancel="${param.subjectUri}"/></p>
|
<p class="submit"><v:input type="submit" id="submit" value="<%= submitLabel %>" cancel="${param.subjectUri}"/></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -111,6 +111,8 @@ RY Description not working - FIX
|
||||||
<p><a href="${backToSubjectLink}">← return to ${relatedSubject.name}</a></p>
|
<p><a href="${backToSubjectLink}">← return to ${relatedSubject.name}</a></p>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
|
|
||||||
|
<%-- Label --%>
|
||||||
<div class="datatypePropertyValue" id="label">
|
<div class="datatypePropertyValue" id="label">
|
||||||
<div class="statementWrap">
|
<div class="statementWrap">
|
||||||
<h2><p:process>${entity.name}</p:process></h2>
|
<h2><p:process>${entity.name}</p:process></h2>
|
||||||
|
@ -120,12 +122,12 @@ RY Description not working - FIX
|
||||||
</c:if>
|
</c:if>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%-- For moniker, only wrap in the div if editing. Otherwise, displays inline next to label. --%>
|
|
||||||
|
<%-- Moniker. Wrap in the div only if editing. If not editing, displays inline next to label. --%>
|
||||||
<c:if test="${showEdits}">
|
<c:if test="${showEdits}">
|
||||||
<div id="dprop-vitro-moniker" class="propsItem editing" style="display:block;">
|
<div id="dprop-vitro-moniker" class="propsItem editing" style="display:block;">
|
||||||
<h3 class="propertyName">moniker</h3>
|
<h3 class="propertyName">moniker</h3>
|
||||||
<c:if test="${showEdits}"><edLnk:editLinks item="<%= VitroVocabulary.MONIKER %>" icons="false"/></c:if>
|
<edLnk:editLinks item="<%= VitroVocabulary.MONIKER %>" icons="false"/>
|
||||||
<%-- Here's where we add the plus link, but only if there isn't already a moniker. --%>
|
|
||||||
</c:if>
|
</c:if>
|
||||||
<c:if test="${!empty entity.moniker}">
|
<c:if test="${!empty entity.moniker}">
|
||||||
<div class="datatypeProperties">
|
<div class="datatypeProperties">
|
||||||
|
@ -140,10 +142,12 @@ RY Description not working - FIX
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
<c:if test="${showEdits}"></div></c:if>
|
<c:if test="${showEdits}"></div></c:if> <%-- end dprop-vitro-moniker --%>
|
||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:choose>
|
</c:choose>
|
||||||
</div><!-- end labelAndMoniker -->
|
</div><!-- end labelAndMoniker -->
|
||||||
|
|
||||||
|
<%-- Links --%>
|
||||||
<c:if test="${ (!empty entity.anchor) || (!empty entity.linksList) }">
|
<c:if test="${ (!empty entity.anchor) || (!empty entity.linksList) }">
|
||||||
<div class="datatypePropertyValue">
|
<div class="datatypePropertyValue">
|
||||||
<div class="statementWrap">
|
<div class="statementWrap">
|
||||||
|
@ -179,6 +183,8 @@ RY Description not working - FIX
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
||||||
|
<%-- Thumbnail --%>
|
||||||
<c:if test="${!empty entity.imageThumb}">
|
<c:if test="${!empty entity.imageThumb}">
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
<c:if test="${!empty entity.imageFile}">
|
<c:if test="${!empty entity.imageFile}">
|
||||||
|
@ -189,6 +195,7 @@ RY Description not working - FIX
|
||||||
<img src="<c:out value="${imageSrc}"/>" title="click to view larger image in new window" alt="" width="150"/>
|
<img src="<c:out value="${imageSrc}"/>" title="click to view larger image in new window" alt="" width="150"/>
|
||||||
<c:if test="${!empty entity.imageFile}"></a></c:if>
|
<c:if test="${!empty entity.imageFile}"></a></c:if>
|
||||||
</div>
|
</div>
|
||||||
|
<%-- Citation --%>
|
||||||
<c:if test="${!empty entity.citation}">
|
<c:if test="${!empty entity.citation}">
|
||||||
<div class="datatypePropertyValue">
|
<div class="datatypePropertyValue">
|
||||||
<div class="statementWrap">
|
<div class="statementWrap">
|
||||||
|
@ -202,19 +209,32 @@ RY Description not working - FIX
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
||||||
<p:process>
|
<p:process>
|
||||||
<c:if test="${!empty entity.blurb}">
|
|
||||||
<div class="datatypePropertyValue">
|
<%-- Blurb --%>
|
||||||
<div class="statementWrap">
|
<div id="dprop-vitro-blurb" class="propsItem ${editingClass}" style="display:block;">
|
||||||
<div class="description">${entity.blurb}</div>
|
<c:if test="${showEdits}">
|
||||||
<%--
|
<h3 class="propertyName">blurb</h3>
|
||||||
<c:if test="${showEdits}">
|
<edLnk:editLinks item="<%= VitroVocabulary.BLURB %>" icons="false"/>
|
||||||
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.BLURB %>" data="${entity.blurb}" icons="false"/></c:set>
|
</c:if>
|
||||||
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
|
<c:if test="${!empty entity.blurb}">
|
||||||
</c:if> --%>
|
<div class="datatypeProperties">
|
||||||
|
<div class="datatypePropertyValue">
|
||||||
|
<div class="statementWrap">
|
||||||
|
<div class="description">${entity.blurb}</div>
|
||||||
|
<c:if test="${showEdits}">
|
||||||
|
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.BLURB %>" data="${entity.blurb}" icons="false"/></c:set>
|
||||||
|
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
|
||||||
|
</c:if>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</c:if>
|
||||||
</c:if>
|
</div>
|
||||||
|
|
||||||
|
<%-- Description --%>
|
||||||
<c:if test="${!empty entity.description}">
|
<c:if test="${!empty entity.description}">
|
||||||
<div class="datatypePropertyValue">
|
<div class="datatypePropertyValue">
|
||||||
<div class="statementWrap">
|
<div class="statementWrap">
|
||||||
|
@ -228,24 +248,19 @@ RY Description not working - FIX
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
</p:process>
|
</p:process>
|
||||||
<c:choose>
|
|
||||||
<c:when test="${showEdits}">
|
<%-- Properties --%>
|
||||||
<c:import url="${entityMergedPropsListJsp}">
|
|
||||||
<c:param name="mode" value="edit"/>
|
<c:import url="${entityMergedPropsListJsp}">
|
||||||
<c:param name="grouped" value="false"/>
|
<%-- <c:param name="mode" value="edit"/> --%>
|
||||||
<%-- unless a value is provided, properties not assigned to a group will not have a tab or appear on the page --%>
|
<c:param name="grouped" value="false"/>
|
||||||
<c:param name="unassignedPropsGroupName" value=""/>
|
<%-- unless a value is provided, properties not assigned to a group will not have a tab or appear on the page --%>
|
||||||
</c:import>
|
<c:param name="unassignedPropsGroupName" value=""/>
|
||||||
</c:when>
|
</c:import>
|
||||||
<c:otherwise>
|
|
||||||
<c:import url="${entityMergedPropsListJsp}">
|
|
||||||
<c:param name="grouped" value="false"/>
|
|
||||||
<%-- unless a value is provided, properties not assigned to a group will not have a tab or appear on the page --%>
|
|
||||||
<c:param name="unassignedPropsGroupName" value=""/>
|
|
||||||
</c:import>
|
|
||||||
</c:otherwise>
|
|
||||||
</c:choose>
|
|
||||||
<p:process>
|
<p:process>
|
||||||
|
<%-- Citation, if no thumbnail --%>
|
||||||
<c:if test="${(!empty entity.citation) && (empty entity.imageThumb)}">
|
<c:if test="${(!empty entity.citation) && (empty entity.imageThumb)}">
|
||||||
<div class="datatypePropertyValue">
|
<div class="datatypePropertyValue">
|
||||||
<div class="statementWrap">
|
<div class="statementWrap">
|
||||||
|
|
Loading…
Add table
Reference in a new issue