From 1f2edcc6220a7cca5636b0ce3c8e81c21b309d19 Mon Sep 17 00:00:00 2001 From: nac26 Date: Fri, 21 Jan 2011 20:18:05 +0000 Subject: [PATCH] NIHVIVO-1820 Updated precision to full (Second) and requiredLevel to none for dateTimeInterval dateTimeValue custom forms. NIHVIVO-1855, NIHVIVO-1829 Corrected submit button text for dateTimeIntervalForm.jsp --- .../web/edit/forms/dateTimeIntervalForm.jsp | 22 +++-- webapp/web/edit/forms/dateTimeValueForm.jsp | 86 +++++++++++-------- .../freemarker/edit/dateTimeWithPrecision.ftl | 2 +- 3 files changed, 66 insertions(+), 44 deletions(-) diff --git a/webapp/web/edit/forms/dateTimeIntervalForm.jsp b/webapp/web/edit/forms/dateTimeIntervalForm.jsp index a5bda54b6..8661c95a2 100644 --- a/webapp/web/edit/forms/dateTimeIntervalForm.jsp +++ b/webapp/web/edit/forms/dateTimeIntervalForm.jsp @@ -138,14 +138,14 @@ %> - + <% } else { // adding new entry %> - + <% } %> @@ -223,9 +223,9 @@ //setup date time edit elements Field startField = editConfig.getField("startField"); // arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel]) - startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.DAY.uri(), VitroVocabulary.Precision.DAY.uri())); + startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri())); Field endField = editConfig.getField("endField"); - endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.DAY.uri(), VitroVocabulary.Precision.DAY.uri())); + endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri())); } editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") ); @@ -236,7 +236,19 @@ editConfig.prepareForObjPropUpdate(model); } else { // adding new editConfig.prepareForNonUpdate(model); - } + } + + List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), + JavaScript.CUSTOM_FORM_UTILS.path(), + "/edit/forms/js/customFormWithAutocomplete.js" + )); + request.setAttribute("customJs", customJs); + + List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), + Css.CUSTOM_FORM.path(), + "/edit/forms/css/customFormWithAutocomplete.css" + )); + request.setAttribute("customCss", customCss); String subjectName = ((Individual) request.getAttribute("subject")).getName(); %> diff --git a/webapp/web/edit/forms/dateTimeValueForm.jsp b/webapp/web/edit/forms/dateTimeValueForm.jsp index 63b3c4f90..d712a496b 100644 --- a/webapp/web/edit/forms/dateTimeValueForm.jsp +++ b/webapp/web/edit/forms/dateTimeValueForm.jsp @@ -27,13 +27,13 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> -<%! +<%! public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.dateTimeValueForm"); %> <% VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior + WebappDaoFactory wdf = vreq.getWebappDaoFactory(); + vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior %> @@ -48,33 +48,31 @@ <%-- Assertions for adding a new date time value --%> - - ?subject <${toDateTimeValue}> ?valueNode . - ?valueNode <${type}> <${valueType}> . + + ?subject <${toDateTimeValue}> ?valueNode . + ?valueNode <${type}> <${valueType}> . ?valueNode <${dateTimeValue}> ?dateTimeField.value . ?valueNode <${dateTimePrecision}> ?dateTimeField.precision . <%-- Queries for editing an existing role --%> - - + SELECT ?existingNode WHERE { ?subject <${toDateTimeValue}> ?existingNode . ?existingNode <${type}> <${valueType}> . } - - existingDateTimeValueQuery - - SELECT ?existingDateTimeValue WHERE { - ?subject <${toDateTimeValue}> ?existingValueNode . - ?existingValueNode <${type}> <${valueType}> . + + + SELECT ?existingDateTimeValue WHERE { + ?subject <${toDateTimeValue}> ?existingValueNode . + ?existingValueNode <${type}> <${valueType}> . ?existingValueNode <${dateTimeValue}> ?existingDateTimeValue . } - - SELECT ?existingPrecision WHERE { - ?subject <${toDateTimeValue}> ?existingValueNode . - ?existingValueNode <${type}> <${valueType}> . + + SELECT ?existingPrecision WHERE { + ?subject <${toDateTimeValue}> ?existingValueNode . + ?existingValueNode <${type}> <${valueType}> . ?existingValueNode <${dateTimePrecision}> ?existingPrecision . } @@ -87,14 +85,14 @@ %> - + <% } else { // adding new entry %> - + <% } %> @@ -103,21 +101,21 @@ "formUrl" : "${formUrl}", "editKey" : "${editKey}", "urlPatternToReturnTo" : "/individual", - + "subject" : ["subject", "${subjectUriJson}" ], "predicate" : ["toDateTimeValue", "${predicateUriJson}" ], "object" : ["valueNode", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForValue}" ], - - "n3optional" : [ ], - + + "n3required" : [ ], + + "n3optional" : [ "${n3ForValue}" ], + "newResources" : { "valueNode" : "${defaultNamespace}" }, - + "urisInScope" : { }, "literalsInScope": { }, "urisOnForm" : [ ], - "literalsOnForm" : [ ], + "literalsOnForm" : [ ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, "sparqlForUris" : { }, @@ -125,8 +123,8 @@ "dateTimeField.value" : "${existingDateTimeValueQuery}", }, "sparqlForExistingUris" : { - "valueNode" : "${existingNodeQuery}", - "dateTimeField.precision": "${existingPrecisionQuery}" + "valueNode" : "${existingNodeQuery}", + "dateTimeField.precision": "${existingPrecisionQuery}" }, "fields" : { "dateTimeField" : { @@ -137,7 +135,7 @@ "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "", - "rangeLang" : "", + "rangeLang" : "", "assertions" : ["${n3ForValue}"] } } @@ -149,13 +147,13 @@ EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); if (editConfig == null) { - editConfig = new EditConfiguration((String) request.getAttribute("editjson")); + editConfig = new EditConfiguration((String) request.getAttribute("editjson")); EditConfiguration.putConfigInSession(editConfig,session); //setup date time edit elements Field dateTimeField = editConfig.getField("dateTimeField"); // arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel]) - dateTimeField.setEditElement(new DateTimeWithPrecision(dateTimeField, VitroVocabulary.Precision.DAY.uri(), VitroVocabulary.Precision.DAY.uri())); + dateTimeField.setEditElement(new DateTimeWithPrecision(dateTimeField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri())); } Model model = (Model) application.getAttribute("jenaOntModel"); @@ -164,20 +162,32 @@ editConfig.prepareForObjPropUpdate(model); } else { // adding new editConfig.prepareForNonUpdate(model); - } + } + + List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), + JavaScript.CUSTOM_FORM_UTILS.path(), + "/edit/forms/js/customFormWithAutocomplete.js" + )); + request.setAttribute("customJs", customJs); + + List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), + Css.CUSTOM_FORM.path(), + "/edit/forms/css/customFormWithAutocomplete.css" + )); + request.setAttribute("customCss", customCss); String subjectName = ((Individual) request.getAttribute("subject")).getName(); %> -

${titleVerb} date time value for <%= subjectName %>

+

${titleVerb} date time value for <%= subjectName %>

" > - + -

+

- + \ No newline at end of file diff --git a/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl b/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl index dfe8d86c6..2a62bf78e 100644 --- a/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl +++ b/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl @@ -68,7 +68,7 @@ precisionConstants.second -- URI for precision <#assign reqLevel = 0 /> -
+
<#if precLevel gte 1> <#-- Only text input field in the mix. We should have some validation to ensure it's a valid year (4 digits, integer, etc) -->