Skip to content

Commit f52c135

Browse files
committed
Minor usability improvements with dates. #231
1 parent 36ea780 commit f52c135

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

grails-app/assets/javascripts/forms.js

+8
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,14 @@ function orEmptyArray(v) {
300300
return _.isEqual(value1, value2);
301301
};
302302

303+
parser.functions.formatDateForValidation = function(value) {
304+
if (!value) {
305+
return '';
306+
}
307+
308+
return moment(value).format('DD-MM-YYYY');
309+
}
310+
303311
var specialBindings = function() {
304312

305313
return {

grails-app/views/output/_dateDataTypeEditModelTemplate.gsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div id="${context.source}Date" class="input-group">
2-
<input class="form-control form-control-sm inputDatePicker" ${context.attributes} data-bind="${context.databindAttrs}" type="text" size="12" ${context.validationAttr}/>
2+
<input class="form-control form-control-sm inputDatePicker" ${context.attributes} data-bind="${context.databindAttrs}" type="text" size="12" autocomplete="off" ${context.validationAttr}/>
33
<div class="input-group-append">
44
<span class="add-on input-group-text open-datepicker"><i class="fa fa-th"></i></span>
55
</div>

src/main/groovy/au/org/ala/ecodata/forms/EditModelWidgetRenderer.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class EditModelWidgetRenderer implements ModelWidgetRenderer {
8686
@Override
8787
void renderSimpleDate(WidgetRenderContext context) {
8888
context.databindAttrs.add 'datepicker', context.source + '.date'
89-
context.writer << "<input${context.attributes.toString()} data-bind='${context.databindAttrs.toString()}'${context.validationAttr} type='text' class='form-control form-control-sm input-small'/>"
89+
context.writer << "<input${context.attributes.toString()} data-bind='${context.databindAttrs.toString()}'${context.validationAttr} type='text' autocomplete='off' class='form-control form-control-sm input-small'/>"
9090
}
9191

9292
@Override

0 commit comments

Comments
 (0)