|
@ -1,4 +1,12 @@ |
|
|
openerp.web_widget_color = function (instance) { |
|
|
|
|
|
|
|
|
odoo.define('web.web_widget_color', function(require) { |
|
|
|
|
|
"use strict"; |
|
|
|
|
|
|
|
|
|
|
|
var core = require('web.core'); |
|
|
|
|
|
var widget = require('web.form_widgets'); |
|
|
|
|
|
var FormView = require('web.FormView'); |
|
|
|
|
|
|
|
|
|
|
|
var QWeb = core.qweb; |
|
|
|
|
|
var _lt = core._lt; |
|
|
|
|
|
|
|
|
var _super_getDir = jscolor.getDir.prototype; |
|
|
var _super_getDir = jscolor.getDir.prototype; |
|
|
jscolor.getDir = function () { |
|
|
jscolor.getDir = function () { |
|
@ -9,9 +17,7 @@ openerp.web_widget_color = function (instance) { |
|
|
return jscolor.dir; |
|
|
return jscolor.dir; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
instance.web.form.widgets.add('color', 'instance.web.form.FieldColor'); |
|
|
|
|
|
|
|
|
|
|
|
instance.web.form.FieldColor = instance.web.form.FieldChar.extend({ |
|
|
|
|
|
|
|
|
var FieldColor = widget.FieldChar.extend({ |
|
|
template: 'FieldColor', |
|
|
template: 'FieldColor', |
|
|
widget_class: 'oe_form_field_color', |
|
|
widget_class: 'oe_form_field_color', |
|
|
is_syntax_valid: function () { |
|
|
is_syntax_valid: function () { |
|
@ -31,6 +37,21 @@ openerp.web_widget_color = function (instance) { |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
}, |
|
|
}, |
|
|
|
|
|
store_dom_value: function() { |
|
|
|
|
|
if (!this.silent) { |
|
|
|
|
|
if (!this.get('effective_readonly') && |
|
|
|
|
|
this.$('input').val() !== '' && |
|
|
|
|
|
this.is_syntax_valid()) { |
|
|
|
|
|
// We use internal_set_value because we were called by
|
|
|
|
|
|
// ``.commit_value()`` which is called by a ``.set_value()``
|
|
|
|
|
|
// itself called because of a ``onchange`` event
|
|
|
|
|
|
this.internal_set_value( |
|
|
|
|
|
this.parse_value( |
|
|
|
|
|
this.$('input').val()) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
render_value: function () { |
|
|
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")) { |
|
|
if (!this.get("effective_readonly")) { |
|
@ -45,13 +66,19 @@ openerp.web_widget_color = function (instance) { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
core.form_widget_registry.add('color', FieldColor); |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* Init jscolor for each editable mode on view form |
|
|
* Init jscolor for each editable mode on view form |
|
|
*/ |
|
|
*/ |
|
|
instance.web.FormView.include({ |
|
|
|
|
|
|
|
|
FormView.include({ |
|
|
to_edit_mode: function () { |
|
|
to_edit_mode: function () { |
|
|
this._super(); |
|
|
this._super(); |
|
|
jscolor.init(this.$el[0]); |
|
|
jscolor.init(this.$el[0]); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
FieldColor: FieldColor |
|
|
}; |
|
|
}; |
|
|
|
|
|
}); |