Browse Source

publish muk_web_utils - 12.0

pull/35/head
MuK IT GmbH 6 years ago
parent
commit
aef7e363fc
  1. 4
      muk_web_utils/__manifest__.py
  2. 26
      muk_web_utils/static/src/js/fields/color.js

4
muk_web_utils/__manifest__.py

@ -17,10 +17,10 @@
# #
################################################################################### ###################################################################################
{
{
"name": "MuK Web Utils", "name": "MuK Web Utils",
"summary": """Utility Features""", "summary": """Utility Features""",
"version": "12.0.2.5.1",
"version": "12.0.2.5.2",
"category": "Extra Tools", "category": "Extra Tools",
"license": "AGPL-3", "license": "AGPL-3",
"author": "MuK IT", "author": "MuK IT",

26
muk_web_utils/static/src/js/fields/color.js

@ -39,10 +39,32 @@ var FieldColor = fields.InputField.extend({
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
}, },
_renderEdit: function () { _renderEdit: function () {
this.$('.mk_field_color_input').val(this._formatValue(this.value));
this.$('.mk_field_color_input').val(
this._formatValue(this.value)
);
this.$('.mk_field_color_input').css({
'background-color': this._formatValue(this.value),
});
}, },
_renderReadonly: function () { _renderReadonly: function () {
this.$el.text(this._formatValue(this.value)); this.$el.text(this._formatValue(this.value));
this.$el.css({'color': this._formatValue(this.value)});
},
_doAction: function() {
this._super.apply(this, arguments);
this.$('.mk_field_color_input').css({
'background-color': this._getValue(),
});
},
_formatValue: function (value) {
return value;
},
_parseValue: function (value) {
if((/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i).test(value)) {
return value;
} else {
throw new Error(_.str.sprintf(core._t("'%s' is not a correct color value"), value));
}
}, },
_onCustomColorButtonClick: function () { _onCustomColorButtonClick: function () {
var ColorpickerDialog = new colorpicker(this, { var ColorpickerDialog = new colorpicker(this, {
@ -51,7 +73,7 @@ var FieldColor = fields.InputField.extend({
}); });
ColorpickerDialog.on('colorpicker:saved', this, function (event) { ColorpickerDialog.on('colorpicker:saved', this, function (event) {
this.$input.val(event.data.hex); this.$input.val(event.data.hex);
this._setValue(event.data.hex);
this._doAction();
}); });
ColorpickerDialog.open(); ColorpickerDialog.open();
}, },

Loading…
Cancel
Save