mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[10.0][MIG]migrate web_widget_timepicker
This commit is contained in:
committed by
Kaushal Prajapati
parent
f33cf1292c
commit
b97d2f1cda
@@ -3,22 +3,22 @@ odoo.define('web_widget_timepicker', function (require) {
|
||||
|
||||
var core = require('web.core');
|
||||
var formats = require('web.formats');
|
||||
var common = require('web.form_common');
|
||||
var common = require('web.form_common');
|
||||
|
||||
var TimePickerField = common.AbstractField.extend(common.ReinitializeFieldMixin, {
|
||||
is_field_number: true,
|
||||
is_field_number: true,
|
||||
template: "TimePickerField",
|
||||
internal_format: 'float_time',
|
||||
widget_class: 'oe_form_field_time',
|
||||
widget_class: 'o_form_field_time',
|
||||
events: {
|
||||
'change input': 'store_dom_value',
|
||||
},
|
||||
init: function (field_manager, node) {
|
||||
this._super(field_manager, node);
|
||||
|
||||
|
||||
this.internal_set_value(0);
|
||||
|
||||
this.options = _.defaults( this.options, {
|
||||
this.options = _.defaults(this.options, {
|
||||
step: 15,
|
||||
selectOnBlur: true,
|
||||
timeFormat: 'H:i',
|
||||
@@ -27,14 +27,14 @@ odoo.define('web_widget_timepicker', function (require) {
|
||||
},
|
||||
initialize_content: function() {
|
||||
if(!this.get("effective_readonly")) {
|
||||
this.$el.find('input').timepicker(this.options);
|
||||
this.setupFocus(this.$('input'));
|
||||
}
|
||||
this.$el.find('input').timepicker(this.options);
|
||||
this.setupFocus(this.$('input'));
|
||||
}
|
||||
},
|
||||
is_syntax_valid: function() {
|
||||
if (!this.get("effective_readonly") && this.$("input").size() > 0) {
|
||||
try {
|
||||
this.parse_value(this.$('input').val(),'');
|
||||
this.parse_value(this.$('input').val(), '');
|
||||
return true;
|
||||
} catch(e) {
|
||||
return false;
|
||||
@@ -55,28 +55,28 @@ odoo.define('web_widget_timepicker', function (require) {
|
||||
height: height,
|
||||
width: width
|
||||
});
|
||||
},
|
||||
},
|
||||
store_dom_value: function () {
|
||||
if (!this.get('effective_readonly')) {
|
||||
this.internal_set_value(
|
||||
this.parse_value(
|
||||
this.$('input').val(),''));
|
||||
this.$('input').val(), ''));
|
||||
}
|
||||
},
|
||||
parse_value: function(val, def) {
|
||||
return formats.parse_value(val, {"widget": this.internal_format}, def);
|
||||
return formats.parse_value(val, {"widget": this.internal_format}, def);
|
||||
},
|
||||
format_value: function(val, def) {
|
||||
return formats.format_value(val, {"widget": this.internal_format}, def);
|
||||
},
|
||||
render_value: function() {
|
||||
var show_value = this.format_value(this.get('value'),'');
|
||||
var show_value = this.format_value(this.get('value'), '');
|
||||
|
||||
if (!this.get("effective_readonly")) {
|
||||
this.$input = this.$el.find('input');
|
||||
this.$input.val(show_value);
|
||||
} else {
|
||||
this.$(".oe_form_time_content").text(show_value);
|
||||
this.$(".o_form_time_content").text(show_value);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -84,6 +84,6 @@ odoo.define('web_widget_timepicker', function (require) {
|
||||
core.form_widget_registry.add('timepicker', TimePickerField);
|
||||
|
||||
return {
|
||||
TimePickerField: TimePickerField,
|
||||
TimePickerField: TimePickerField,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user