[FIX] web_editor: properly set media dialog onlyImages and find video
Media dialog was trying to reach the current media's parent node, which was not possible as it was cloned on instantiation. To fix this, the `showImageDialog` now passes the `onlyImages` option upon instantiation, checking the parent's data. It also passes the media's parent if said parent is a video. This way, neither of these two things need to be done in media dialog. closes odoo/odoo#31634 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
@@ -54,7 +54,14 @@ var MediaPlugin = AbstractPlugin.extend({
|
||||
this.context.invoke('editor.saveRange');
|
||||
var media = this.context.invoke('editor.restoreTarget');
|
||||
|
||||
var mediaDialog = new weWidgets.MediaDialog(this.options.parent, {},
|
||||
var $mediaParent = $(media).parent();
|
||||
if ($mediaParent.hasClass('media_iframe_video')) {
|
||||
media = $mediaParent[0];
|
||||
$mediaParent = $mediaParent.parent();
|
||||
}
|
||||
var mediaDialog = new weWidgets.MediaDialog(this.options.parent, {
|
||||
onlyImages: $mediaParent.data('oeField') === 'image' || $mediaParent.data('oeType') === 'image',
|
||||
},
|
||||
$(media).clone()[0]
|
||||
);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ var MediaDialog = Dialog.extend({
|
||||
this.$media = $(media);
|
||||
|
||||
this.multiImages = options.multiImages;
|
||||
var onlyImages = options.onlyImages || this.multiImages || (this.media && (this.$media.parent().data('oeField') === 'image' || this.$media.parent().data('oeType') === 'image'));
|
||||
var onlyImages = options.onlyImages || this.multiImages;
|
||||
this.noImages = options.noImages;
|
||||
this.noDocuments = onlyImages || options.noDocuments;
|
||||
this.noIcons = onlyImages || options.noIcons;
|
||||
@@ -80,10 +80,6 @@ var MediaDialog = Dialog.extend({
|
||||
this.active = this.documentDialog;
|
||||
} else if (this.videoDialog && this.$media.hasClass('media_iframe_video')) {
|
||||
this.active = this.videoDialog;
|
||||
} else if (this.videoDialog && this.$media.parent().hasClass('media_iframe_video')) {
|
||||
this.$media = this.$media.parent();
|
||||
this.media = this.$media[0];
|
||||
this.active = this.videoDialog;
|
||||
} else if (this.iconDialog && this.$media.is('span, i')) {
|
||||
this.active = this.iconDialog;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user