From fdb310018e69478fa317c68bcdeb94a6456727c1 Mon Sep 17 00:00:00 2001 From: Emilien Coquard Date: Thu, 8 Sep 2016 20:11:33 +0530 Subject: [PATCH] Fix time field that was not updated (#1254) --- app/core/uis/datetime/time.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/core/uis/datetime/time.js b/app/core/uis/datetime/time.js index a7c11c34be9d8..755aa659374ef 100644 --- a/app/core/uis/datetime/time.js +++ b/app/core/uis/datetime/time.js @@ -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' }, @@ -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;