From f52c1358b754298ad002a3735129029a8a7753b0 Mon Sep 17 00:00:00 2001 From: chrisala Date: Tue, 20 Feb 2024 11:35:24 +1100 Subject: [PATCH] Minor usability improvements with dates. #231 --- grails-app/assets/javascripts/forms.js | 8 ++++++++ .../views/output/_dateDataTypeEditModelTemplate.gsp | 2 +- .../org/ala/ecodata/forms/EditModelWidgetRenderer.groovy | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/grails-app/assets/javascripts/forms.js b/grails-app/assets/javascripts/forms.js index 329243f..34be3c7 100644 --- a/grails-app/assets/javascripts/forms.js +++ b/grails-app/assets/javascripts/forms.js @@ -300,6 +300,14 @@ function orEmptyArray(v) { return _.isEqual(value1, value2); }; + parser.functions.formatDateForValidation = function(value) { + if (!value) { + return ''; + } + + return moment(value).format('DD-MM-YYYY'); + } + var specialBindings = function() { return { diff --git a/grails-app/views/output/_dateDataTypeEditModelTemplate.gsp b/grails-app/views/output/_dateDataTypeEditModelTemplate.gsp index 0f7ffd2..5355b7e 100644 --- a/grails-app/views/output/_dateDataTypeEditModelTemplate.gsp +++ b/grails-app/views/output/_dateDataTypeEditModelTemplate.gsp @@ -1,5 +1,5 @@
- +
diff --git a/src/main/groovy/au/org/ala/ecodata/forms/EditModelWidgetRenderer.groovy b/src/main/groovy/au/org/ala/ecodata/forms/EditModelWidgetRenderer.groovy index 2a9e5df..bcf9b52 100644 --- a/src/main/groovy/au/org/ala/ecodata/forms/EditModelWidgetRenderer.groovy +++ b/src/main/groovy/au/org/ala/ecodata/forms/EditModelWidgetRenderer.groovy @@ -86,7 +86,7 @@ public class EditModelWidgetRenderer implements ModelWidgetRenderer { @Override void renderSimpleDate(WidgetRenderContext context) { context.databindAttrs.add 'datepicker', context.source + '.date' - context.writer << "" + context.writer << "" } @Override