[FIX] website: remove data-editor-message attributes on save
When the edit mode is entered, some elements receive data-editor-message attributes. These were not removed on save which could in some cases make the attributes be saved in the database. For this to happen it would require an `.oe_structure.oe_empty` element to be put *inside* an editable element (instead of being the one which is editable). In that case the `.oe_structure` content would be saved in an inheriting view but the parent view would also be COW'd for no reason because of that attribute. Difficult to say if such a case exist in the current views but as it technically possible and that some of our tests use that configuration, it is worth fixing. Note: this fix was in fact done in the new editor in master and allowed to detect that one of our test was not testing a feature correctly because of that. This will be adapted in a different commit of this PR. closes odoo/odoo#30834
This commit is contained in:
@@ -83,7 +83,8 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
self.$welcomeMessage.remove();
|
||||
}
|
||||
var $wrapwrap = $('#wrapwrap'); // TODO find this element another way
|
||||
$wrapwrap.find('.oe_structure.oe_empty, [data-oe-type="html"]').attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE'));
|
||||
self.$editorMessageElements = $wrapwrap.find('.oe_structure.oe_empty, [data-oe-type="html"]')
|
||||
.attr('data-editor-message', _t('DRAG BUILDING BLOCKS HERE'));
|
||||
var def = $.Deferred();
|
||||
self.trigger_up('animation_start_demand', {
|
||||
editableMode: true,
|
||||
@@ -102,10 +103,19 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
* expects that the save action is performed. So, this empty action is
|
||||
* defined here so that all users have an 'on_save' related action.
|
||||
*
|
||||
* As explained above, that action should always be defined in the current
|
||||
* implementation (even an empty one) but in fact it is also needed to
|
||||
* remove the data-editor-message attributes which are added when entering
|
||||
* edition.
|
||||
*
|
||||
* @private
|
||||
* @todo improve the system to somehow declare required/optional actions
|
||||
*/
|
||||
_onSave: function () {},
|
||||
_onSave: function () {
|
||||
if (this.$editorMessageElements) {
|
||||
this.$editorMessageElements.removeAttr('data-editor-message');
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
|
||||
Reference in New Issue
Block a user