diff options
| author | mgh-odoo <mgh@odoo.com> | 2019-06-18 12:36:38 +0000 |
|---|---|---|
| committer | Dharmraj Jhala <dja@odoo.com> | 2019-06-21 12:48:04 +0000 |
| commit | 75fb46d848fabeaf8f46223a196390ae4a8ca47a (patch) | |
| tree | d1198205172bfa4114a787be374a47bef951dcc0 /addons/website_profile/static | |
| parent | a5b1a288a64e47200dcaa74f3892b56fff1cb5e6 (diff) | |
[FIX] website_profile: use wysiwyg editor instead of textarea for biography
Currently, while editing user profile from frontend, biography is displayed in
textarea despite of being an HTML field.
This commit fixes the behavior by providing users with wysiwyg ediotr to
update their biography while editing profile from frondend.
task-2007731
closes odoo/odoo#34207
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/website_profile/static')
| -rw-r--r-- | addons/website_profile/static/src/js/website_profile.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/addons/website_profile/static/src/js/website_profile.js b/addons/website_profile/static/src/js/website_profile.js index a3cc18f53f5..48d033d30fe 100644 --- a/addons/website_profile/static/src/js/website_profile.js +++ b/addons/website_profile/static/src/js/website_profile.js @@ -2,6 +2,7 @@ odoo.define('website_profile.website_profile', function (require) { 'use strict'; var sAnimations = require('website.content.snippets.animation'); +var Wysiwyg = require('web_editor.wysiwyg.root'); //TODO DBE : to change into publicWidget = require('web.public.widget'); after forward port in master sAnimations.registry.websiteProfile = sAnimations.Class.extend({ @@ -42,6 +43,47 @@ sAnimations.registry.websiteProfile = sAnimations.Class.extend({ }, }); +sAnimations.registry.websiteProfileEditor = sAnimations.Class.extend({ + selector: '.o_wprofile_editor_form', + read_events: { + 'click .o_wprofile_submit_btn': '_onSubmitClick', + }, + + /** + * @override + */ + start: function () { + var def = this._super.apply(this, arguments); + if (this.editableMode) { + return def; + } + var $textarea = this.$('textarea.load_editor'); + var wysiwyg = new Wysiwyg(this, { + recordInfo: { + context: this._getContext(), + res_model: 'res.users', + res_id: parseInt(this.$('input[name=user_id]').val()), + }, + }); + + if (!$textarea.val().match(/\S/)) { + $textarea.val('<p><br/></p>'); + } + return $.when(def, wysiwyg.attachTo($textarea)); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + */ + _onSubmitClick: function () { + this.$('textarea.load_editor').data('wysiwyg').save(); + }, +}); + return sAnimations.registry.websiteProfile; }); |
