diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/elements/DateTimeWithPrecision.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/elements/DateTimeWithPrecision.java index 4f3673b40..a4f660c17 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/elements/DateTimeWithPrecision.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/elements/DateTimeWithPrecision.java @@ -71,14 +71,14 @@ public class DateTimeWithPrecision extends BaseEditElement { } private static final Log log = LogFactory.getLog(DateTimeWithPrecision.class); - protected String TEMPATE_NAME = "DateTimeWithPrecision.ftl"; + protected String TEMPLATE_NAME = "dateTimeWithPrecision.ftl"; @Override public String draw(String fieldName, EditConfiguration editConfig, EditSubmission editSub, Configuration fmConfig) { Map map = getMapForTemplate( editConfig, editSub); map.putAll( FreemarkerHttpServlet.getDirectives()); - return merge( fmConfig, TEMPATE_NAME, map); + return merge( fmConfig, TEMPLATE_NAME, map); } /** diff --git a/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl b/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl new file mode 100644 index 000000000..5168c5d94 --- /dev/null +++ b/webapp/web/templates/freemarker/edit/dateTimeWithPrecision.ftl @@ -0,0 +1,123 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- This is an example of how we could call this macro from a custom form if we end up +implementing this like the other freemarker "widgets". For now I just have this here as +an example and I didn't really see any other way to get the jsp custom forms to call +this at the moment. Needless to say, we need to be able to call the macro and pass +parameters from within the original custom form --> + +<@dateTime specificity="${precision}" required="${requiredMinimumPrecision}" /> + +<#macro dateTime specificity="full" required=specificity> + <#assign specLevel = 10 /> + <#assign reqLevel = 10 /> + <#if specificity == "${precisions.year}"> + <#assign specLevel = 1 /> + <#elseif specificity == "${precisions.month}"> + <#assign specLevel = 2 /> + <#-- allow to specify year, month and day using "date" --> + <#elseif specificity == "${precisions.day}" || specificity == "date"> + <#assign specLevel = 3 /> + <#elseif specificity == "${precisions.hour}"> + <#assign specLevel = 4 /> + <#-- allow to specify hours and minutes using "time" --> + <#elseif specificity == "${precisions.minute}" || specificity == "time"> + <#assign specLevel = 5 /> + <#elseif specificity == "${precisions.second}"> + <#assign specLevel = 6 /> + + <#if required == "${precisions.year}"> + <#assign reqLevel = 1 /> + <#elseif required == "${precisions.month}"> + <#assign reqLevel = 2 /> + <#-- allow to require year, month and day using "date" --> + <#elseif required == "${precisions.day}" || required == "date"> + <#assign reqLevel = 3 /> + <#elseif required == "${precisions.hour}"> + <#assign reqLevel = 4 /> + <#-- allow to require hours and minutes using "time" --> + <#elseif required == "${precisions.minute}" || required == "time"> + <#assign reqLevel = 5 /> + <#elseif required == "${precisions.second}"> + <#assign reqLevel = 6 /> + <#elseif required == "${precisions.none}"> + <#assign reqLevel = 0 /> + + +
+ + <#if specLevel 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) --> + + required /> + + + <#if specLevel gte 2> + + + + + <#if specLevel gte 3> + + + + + <#if specLevel gte 4> + <#-- We'll need to make this more flexible to support 24 hour display down the road. For now assuming 12h with am/pm --> + + + + + <#if specLevel gte 5> + + + + + <#if specLevel gte 6> + + + +
+ \ No newline at end of file diff --git a/webapp/web/templates/freemarker/widgets/edit/DateTimeWithPrecision.ftl b/webapp/web/templates/freemarker/widgets/edit/DateTimeWithPrecision.ftl deleted file mode 100644 index 403d909a9..000000000 --- a/webapp/web/templates/freemarker/widgets/edit/DateTimeWithPrecision.ftl +++ /dev/null @@ -1,276 +0,0 @@ -<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> - -<#-- This is an example of how we could call this macro from a custom form if we end up -implementing this like the other freemarker "widgets". For now I just have this here as -an example and I didn't really see any other way to get the jsp custom forms to call -this at the moment. Needless to say, we need to be able to call the macro and pass -parameters from within the original custom form --> - -<@dateTime specificity="${precision}" required="${requiredMinimumPrecision}" /> - -<#macro dateTime specificity="full" required=specificity> - <#assign specLevel = 10 /> - <#assign reqLevel = 10 /> - <#if specificity == "${precisions.year}"> - <#assign specLevel = 1 /> - <#elseif specificity == "${precisions.month}"> - <#assign specLevel = 2 /> - <#-- allow to specify year, month and day using "date" --> - <#elseif specificity == "${precisions.day}" || specificity == "date"> - <#assign specLevel = 3 /> - <#elseif specificity == "${precisions.hour}"> - <#assign specLevel = 4 /> - <#-- allow to specify hours and minutes using "time" --> - <#elseif specificity == "${precisions.minute}" || specificity == "time"> - <#assign specLevel = 5 /> - <#elseif specificity == "${precisions.second}"> - <#assign specLevel = 6 /> - - <#if required == "${precisions.year}"> - <#assign reqLevel = 1 /> - <#elseif required == "${precisions.month}"> - <#assign reqLevel = 2 /> - <#-- allow to require year, month and day using "date" --> - <#elseif required == "${precisions.day}" || required == "date"> - <#assign reqLevel = 3 /> - <#elseif required == "${precisions.hour}"> - <#assign reqLevel = 4 /> - <#-- allow to require hours and minutes using "time" --> - <#elseif required == "${precisions.minute}" || required == "time"> - <#assign reqLevel = 5 /> - <#elseif required == "${precisions.second}"> - <#assign reqLevel = 6 /> - <#elseif required == "${precisions.none}"> - <#assign reqLevel = 0 /> - - -
- - <#if specLevel 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) --> - - required /> - - - <#if specLevel gte 2> - - - - - <#if specLevel gte 3> - - - - - <#if specLevel gte 4> - <#-- We'll need to make this more flexible to support 24 hour display down the road. For now assuming 12h with am/pm --> - - - - - <#if specLevel gte 5> - - - - - <#if specLevel gte 6> - - - -
- \ No newline at end of file