[FIX] mass_mailing: preserve changes on preview templates
Previewing templates in the "SELECT A TEMPLATE" tab of mass_mailing made one lose all their changes. This makes sure they are preserved and restored when needed. task-2778411 closes odoo/odoo#85932 X-original-commit: e96e11d6ab8e5f7a6d5da498409cc0d5fb26cad1 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> Signed-off-by: Antoine Guenet <age@odoo.com>
This commit is contained in:
@@ -244,6 +244,8 @@ var MassMailingFieldHtml = FieldHtml.extend({
|
||||
}
|
||||
this.switchThemeLast = themeParams;
|
||||
|
||||
this.$lastContent = this.$content.find('.o_mail_wrapper_td').contents();
|
||||
|
||||
this.$content.closest('body').removeClass(this._allClasses).addClass(themeParams.className);
|
||||
|
||||
const old_layout = this.$content.find('.o_layout')[0];
|
||||
@@ -475,7 +477,11 @@ var MassMailingFieldHtml = FieldHtml.extend({
|
||||
self._switchThemes(themeParams);
|
||||
});
|
||||
$themeSelector.on("mouseleave", ".dropdown-item", function (e) {
|
||||
self._switchThemes(selectedTheme);
|
||||
if (self.$lastContent) {
|
||||
self._switchThemes(Object.assign({}, selectedTheme, {template: self.$lastContent}));
|
||||
} else {
|
||||
self._switchThemes(selectedTheme);
|
||||
}
|
||||
});
|
||||
$themeSelector.on("click", '[data-toggle="dropdown"]', function (e) {
|
||||
var $menu = $themeSelector.find('.dropdown-menu');
|
||||
@@ -498,6 +504,9 @@ var MassMailingFieldHtml = FieldHtml.extend({
|
||||
// Notify form view
|
||||
$themeSelector.find('.dropdown-item.selected').removeClass('selected');
|
||||
$themeSelector.find('.dropdown-item:eq(' + themesParams.indexOf(selectedTheme) + ')').addClass('selected');
|
||||
|
||||
// Invalidate previous content.
|
||||
self.$lastContent = undefined;
|
||||
};
|
||||
|
||||
$themeSelector.on("click", ".dropdown-item", selectTheme);
|
||||
|
||||
Reference in New Issue
Block a user