From 54c50193476647ffbf000b98cef1fbfa3492d801 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Tue, 23 Mar 2010 17:28:11 +0000 Subject: [PATCH] NIHVIVO-142 Add/edit/delete blurb on front end --- .../vitro/webapp/utils/StringUtils.java | 14 +++- .../vitro/webapp/utils/StringUtilsTest.java | 10 +++ .../web/edit/forms/defaultVitroNsPropForm.jsp | 42 +++++++--- webapp/web/templates/entity/entityBasic.jsp | 79 +++++++++++-------- 4 files changed, 98 insertions(+), 47 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/StringUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/StringUtils.java index 33f713e43..a2d5d9235 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/StringUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/StringUtils.java @@ -38,12 +38,22 @@ public class StringUtils { 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); } + // Because we can't use Java 1.6 String.isEmpty() public static boolean isEmpty(String s) { 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; + } } diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/StringUtilsTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/StringUtilsTest.java index 2df88f273..720a54544 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/StringUtilsTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/utils/StringUtilsTest.java @@ -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, 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)); + } } diff --git a/webapp/web/edit/forms/defaultVitroNsPropForm.jsp b/webapp/web/edit/forms/defaultVitroNsPropForm.jsp index d401afefd..d4926a673 100644 --- a/webapp/web/edit/forms/defaultVitroNsPropForm.jsp +++ b/webapp/web/edit/forms/defaultVitroNsPropForm.jsp @@ -2,7 +2,6 @@ <%@ page import="java.util.ArrayList"%> <%@ 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.Model"%> @@ -21,9 +20,18 @@ <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <%@ 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"); - log.debug("Starting defaultVitroNsPropForm.jsp"); + org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms." + thisPage); + log.debug("Starting " + thisPage); VitroRequest vreq = new VitroRequest(request); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); @@ -40,7 +48,7 @@ Individual subject = (Individual)vreq.getAttribute("subject"); 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"); @@ -53,17 +61,17 @@ rangeDatatypeUri = dps.getDatatypeURI(); 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 { - 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(); 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 = ""; } 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 { @@ -161,18 +169,26 @@ 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 submitLabel = actionText + propertyName; - String title = actionText + propertyName + " for " + subject.getName(); + String submitLabel = actionText + propertyLabel; + String title = actionText + "" + propertyLabel + " 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); %> - + + +

<%= title %>

" > - +

diff --git a/webapp/web/templates/entity/entityBasic.jsp b/webapp/web/templates/entity/entityBasic.jsp index a289493a6..3c17d00d6 100644 --- a/webapp/web/templates/entity/entityBasic.jsp +++ b/webapp/web/templates/entity/entityBasic.jsp @@ -111,6 +111,8 @@ RY Description not working - FIX

← return to ${relatedSubject.name}

+ + <%-- Label --%>

${entity.name}

@@ -120,12 +122,12 @@ RY Description not working - FIX
- <%-- 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. --%>

moniker

- - <%-- Here's where we add the plus link, but only if there isn't already a moniker. --%> +
@@ -140,10 +142,12 @@ RY Description not working - FIX
- + <%-- end dprop-vitro-moniker --%>
+ + <%-- Links --%>
@@ -179,6 +183,8 @@ RY Description not working - FIX
+ + <%-- Thumbnail --%>
@@ -189,6 +195,7 @@ RY Description not working - FIX " title="click to view larger image in new window" alt="" width="150"/>
+ <%-- Citation --%>
@@ -202,19 +209,32 @@ RY Description not working - FIX
+ - -
-
-
${entity.blurb}
- <%-- - - - ${editLinks} - --%> + + <%-- Blurb --%> +
+ +

blurb

+ +
+ +
+
+
+
${entity.blurb}
+ + + ${editLinks} + +
+
+
-
- + +
+ + <%-- Description --%>
@@ -228,24 +248,19 @@ RY Description not working - FIX
- - - - - - <%-- unless a value is provided, properties not assigned to a group will not have a tab or appear on the page --%> - - - - - - - <%-- unless a value is provided, properties not assigned to a group will not have a tab or appear on the page --%> - - - - + + <%-- Properties --%> + + + <%-- --%> + + <%-- unless a value is provided, properties not assigned to a group will not have a tab or appear on the page --%> + + + + + <%-- Citation, if no thumbnail --%>