Skip to content

Commit

Permalink
Fix time field that was not updated (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilien Coquard authored and wellingguzman committed Sep 8, 2016
1 parent 028cf1c commit fdb3100
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/core/uis/datetime/time.js
Expand Up @@ -48,6 +48,8 @@ define(['app', 'moment', 'core/UIComponent', 'core/UIView', 'core/t'], function(
template: 'datetime/input',

events: {
'blur input.time': 'updateValue',
'change input.time': 'updateValue',
'click .now': 'makeNow'
},

Expand All @@ -61,6 +63,32 @@ define(['app', 'moment', 'core/UIComponent', 'core/UIView', 'core/t'], function(
this.render();
},

getTime: function() {

var format = 'HH:mm';

if (this.options.settings.get('include_seconds') == 1) {
format += ':ss';
}

return {
value: this.$('input[type=time]').val(),
format: format
}
},

updateValue: function() {
var time = this.getTime();
var val = time.value;
var format = time.format;

if (moment(val, format).isValid()) {
this.$('#'+this.name).val(val);
} else {
this.$('#'+this.name).val('');
}
},

serialize: function() {
var date = getTimeData(this.value, this.options);
var settings = this.options.settings;
Expand Down

0 comments on commit fdb3100

Please sign in to comment.