Browse Source

[ADD] validation

[IMP] write formatted value to back to input
pull/1106/head
Holger Brunn 10 years ago
committed by Jairo Llopis
parent
commit
29b3401c45
  1. 3
      web_widget_x2many_2d_matrix/README.rst
  2. 23
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

3
web_widget_x2many_2d_matrix/README.rst

@ -49,8 +49,7 @@ show_column_totals
Known issues / Roadmap
======================
* no validation yet
* it would be better to instantiate the proper field widget and let it render the input
* it would be worth trying to instantiate the proper field widget and let it render the input
Credits
=======

23
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -209,6 +209,14 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
// validate a value
validate_xy_value: function(val)
{
try
{
this.parse_xy_value(val);
}
catch(e)
{
return false;
}
return true;
},
@ -308,10 +316,12 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
val = $this.val()
if(self.validate_xy_value(val))
{
data = {}
data[self.field_value] = self.parse_xy_value(val);
$this.siblings('span').text(
self.format_xy_value(self.parse_xy_value(val)));
var data = {}, value = self.parse_xy_value(val);
data[self.field_value] = value;
$this.siblings('span').text(self.format_xy_value(value));
$this.val(self.format_xy_value(value));
self.dataset.write($this.data('id'), data);
$this.parent().removeClass('oe_form_invalid');
self.compute_totals();
@ -341,6 +351,11 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
this.$el.find('input').first().focus();
},
is_syntax_valid: function()
{
return this.$el.find('.oe_form_invalid').length == 0;
},
// deactivate view related functions
load_views: function() {},
reload_current_view: function() {},

Loading…
Cancel
Save