|
|
@ -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; |
|
|
|
jscolor.getDir = function () { |
|
|
@ -9,9 +17,7 @@ openerp.web_widget_color = function (instance) { |
|
|
|
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', |
|
|
|
widget_class: 'oe_form_field_color', |
|
|
|
is_syntax_valid: function () { |
|
|
@ -31,6 +37,21 @@ openerp.web_widget_color = function (instance) { |
|
|
|
} |
|
|
|
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 () { |
|
|
|
var show_value = this.format_value(this.get('value'), ''); |
|
|
|
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 |
|
|
|
*/ |
|
|
|
instance.web.FormView.include({ |
|
|
|
FormView.include({ |
|
|
|
to_edit_mode: function () { |
|
|
|
this._super(); |
|
|
|
jscolor.init(this.$el[0]); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
|
FieldColor: FieldColor |
|
|
|
}; |
|
|
|
}); |