[FIX] website_forum: show normal image modal in forum

In #67893 the image icon was removed, but it contradicts the interface
and made a feature that was working for employee less available.

Since saas-12.3, we always use the full media dialog when showing the
editor on the forum so we could not add an image with the image icon if
were not an employee.

Before saas-12.3, the original summernote image dialog was shown for
everyone but website editor that saw the full media dialog (beecause we
are using the same editor to do both things).

With this change, we always have the original dialog in the forum
message editor thanks to a new option "disableFullMediaDialog".

opw-2470720

closes odoo/odoo#68166

X-original-commit: c026c360fb77ce43f47f7645f48e37bced988b85
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2021-03-19 18:30:00 +00:00
parent 5c4133f074
commit 8a5d22826c
2 changed files with 9 additions and 1 deletions
@@ -464,7 +464,12 @@ eventHandler.modules.linkDialog.showLinkDialog = function ($editable, $dialog, l
});
return def;
};
var originalShowImageDialog = eventHandler.modules.imageDialog.showImageDialog;
eventHandler.modules.imageDialog.showImageDialog = function ($editable) {
var options = $editable.closest('.o_editable, .note-editor').data('options');
if (options.disableFullMediaDialog) {
return originalShowImageDialog.apply(this, arguments);
}
var r = $editable.data('range');
if (r.sc.tagName && r.sc.childNodes.length) {
r.sc = r.sc.childNodes[r.so];
@@ -472,7 +477,6 @@ eventHandler.modules.imageDialog.showImageDialog = function ($editable) {
var media = $(r.sc).parents().addBack().filter(function (i, el) {
return dom.isImg(el);
})[0];
var options = $editable.closest('.o_editable, .note-editor').data('options');
topBus.trigger('media_dialog_demand', {
$editable: $editable,
media: media,
@@ -866,6 +870,9 @@ eventHandler.attach = function (oLayoutInfo, options) {
oLayoutInfo.editor().on('dragstart', 'img', function (e) { e.preventDefault(); });
$(document).on('mousedown', summernote_mousedown).on('mouseup', summernote_mouseup);
oLayoutInfo.editor().off('click').on('click', function (e) {e.preventDefault();}); // if the content editable is a link
oLayoutInfo.editor().find('.note-image-dialog').on('click', '.note-image-input', function (e) {
e.stopPropagation(); // let browser default happen for image file input
});
/**
* Open Media Dialog on double click on an image/video/icon.
@@ -141,6 +141,7 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
res_model: 'forum.post',
res_id: +window.location.pathname.split('-').pop(),
},
disableFullMediaDialog: true,
};
if (!hasFullEdit) {
options.plugins = {