mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[ADD] validation
[IMP] write formatted value to back to input
This commit is contained in:
committed by
Simone Orsi
parent
6eb62bb572
commit
d5c0a478b9
@@ -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
|
||||
=======
|
||||
|
||||
@@ -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() {},
|
||||
|
||||
Reference in New Issue
Block a user