[FIX] web_editor: display a dialog if posting a translation fails
When editing a translation on the website, if the user copy/pastes directly in the web editor, then the html formatting is also copied. Since the translation matching takes the html code into account when matching the translations, this breaks the pairing. When trying to save, the backend function validating the new translation thus fails and return a server error. However nothing was done with this error, and the user just witnesses that saving doesn't work (unless he opens the console to notice the rpc failure). We now display an alert dialog that notifies which tranlation causes the error. opw 1862784
This commit is contained in:
@@ -8,6 +8,7 @@ var Widget = require('web.Widget');
|
||||
var weContext = require('web_editor.context');
|
||||
var rte = require('web_editor.rte');
|
||||
var weWidgets = require('web_editor.widget');
|
||||
var Dialog = require('web.Dialog');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
@@ -26,6 +27,7 @@ var RTETranslatorWidget = rte.Class.extend({
|
||||
* @override
|
||||
*/
|
||||
_saveElement: function ($el, context, withLang) {
|
||||
var self = this;
|
||||
if ($el.data('oe-translation-id')) {
|
||||
return this._rpc({
|
||||
model: 'ir.translation',
|
||||
@@ -35,7 +37,9 @@ var RTETranslatorWidget = rte.Class.extend({
|
||||
this._getEscapedElement($el).html(),
|
||||
context || weContext.get()
|
||||
],
|
||||
});
|
||||
}).fail(function (error) {
|
||||
Dialog.alert(null, error.data.message);
|
||||
});
|
||||
}
|
||||
return this._super($el, context, withLang === undefined ? true : withLang);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user