Skip to content
Snippets Groups Projects
Commit fb926fe8 authored by Jason Van Malder's avatar Jason Van Malder
Browse files

[FIX] web_editor: fix mail template toolbar in debug mode

Issue

    - Install Mail template
    - Enable debug mode (normal or assets)
    - Create or edit a mail template
    - Click in the text editor

    The toolbar is not showing up (it does when we're not in debug mode)

Cause

    We are doing `splice(-1, 0, ['view', ['codeview']])` on toolbar
    which is undefined, the method crashes and the toolbar doesn't
    render.

Solution

    Checking if the toolbar is defined before doing all that logic.

OPW-2151675

X-original-commit: 0e5ca50d
parent c44d8460
No related branches found
No related tags found
No related merge requests found
......@@ -200,7 +200,8 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
tabsize: 0,
height: 180,
generateOptions: function (options) {
var para = _.find(options.toolbar, function (item) {
var toolbar = options.toolbar || options.airPopover || {};
var para = _.find(toolbar, function (item) {
return item[0] === 'para';
});
if (para && para[1] && para[1].indexOf('checklist') === -1) {
......@@ -208,7 +209,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
}
if (config.isDebug()) {
options.codeview = true;
var view = _.find(options.toolbar, function (item) {
var view = _.find(toolbar, function (item) {
return item[0] === 'view';
});
if (view) {
......@@ -216,7 +217,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
view[1].splice(-1, 0, 'codeview');
}
} else {
options.toolbar.splice(-1, 0, ['view', ['codeview']]);
toolbar.splice(-1, 0, ['view', ['codeview']]);
}
}
options.prettifyHtml = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment