[FIX] web: dialog should not use field value footer items

Issue: display the footer tag from snippet in the modal and replace the
save and cancel button.
Steps to see: Email marketing -> mailing lists -> option icon of a
kanban -> Edit -> Website popups -> add a line

X-original-commit: 073699749401adadeec029de6534b4d205e41067
This commit is contained in:
Gorash
2020-12-14 14:40:21 +00:00
committed by David Monjoie
parent ae7aae7140
commit 720ea747f0
2 changed files with 43 additions and 2 deletions
@@ -141,7 +141,11 @@ var FormController = BasicController.extend({
* @param {jQuery} [$node]
*/
renderButtons: function ($node) {
var $footer = this.footerToButtons ? this.renderer.$el && this.renderer.$('footer') : null;
var $footer = this.footerToButtons
? this.renderer.$el && this.renderer.$('footer').filter(function () {
return !this.closest('.oe_form_field');
})
: null;
var mustRenderFooterButtons = $footer && $footer.length;
if ((this.defaultButtons && !this.$buttons) || mustRenderFooterButtons) {
this.$buttons = $('<div/>');
@@ -280,7 +284,9 @@ var FormController = BasicController.extend({
return;
}
if (this.footerToButtons) {
var $footer = this.renderer.$el && this.renderer.$('footer');
var $footer = this.renderer.$el && this.renderer.$('footer').filter(function () {
return !this.closest('.oe_form_field');
});
if ($footer && $footer.length) {
this.$buttons.empty().append($footer);
}
@@ -6,6 +6,7 @@ var BasicModel = require('web.BasicModel');
var concurrency = require('web.concurrency');
var core = require('web.core');
var fieldRegistry = require('web.field_registry');
var basicFields = require('web.basic_fields');
const fieldRegistryOwl = require('web.field_registry_owl');
var FormView = require('web.FormView');
var mixins = require('web.mixins');
@@ -2254,6 +2255,40 @@ QUnit.module('Views', {
form.destroy();
});
QUnit.test("modal should not use the widget footer elements", async function (assert) {
assert.expect(2);
var MyWidget = basicFields.FieldChar.extend({
_renderEdit: function () {
var $el = $(`<div class="oe_form_field">Coucou<footer>this should not be moved</footer></div>`);
this.$el.replaceWith($el);
this.$el = $el;
},
});
fieldRegistry.add('test', MyWidget);
var form = await createView({
View: FormView,
model: 'user',
data: this.data,
arch: '<form><field name="partner_ids"/></form>',
archs: {
'partner,false,list': '<tree><field name="foo"/></tree>',
'partner,false,form': '<form><field name="display_name" widget="test"/></form>',
},
res_id: 17,
});
await testUtils.form.clickEdit(form);
await testUtils.dom.click(form.$('table td[title="yop"]'));
assert.strictEqual($('.modal-content main.modal-body div footer').html(), 'this should not be moved', "modal should display the custom widget");
assert.strictEqual($('.modal-content footer.modal-footer button').text(), 'SaveDiscard', "modal footer should contains 2 buttons");
form.destroy();
delete fieldRegistry.map.test;
});
QUnit.test('toolbar is hidden when switching to edit mode', async function (assert) {
assert.expect(3);