[MERGE][IMP] web,coupon: improve inline domain editor display within modals

PURPOSE

Inline domain editor`s selector should be visible outside of modal (dialog
/ popup). This change has to work globally.

CURRENT

When inline domain editor is used in any modal (dialog) its details are
hidden inside model body. we have to scroll-down in model-body for accessing
domain-editor selection. Inline editor`s overflow is visible only
in coupon module, but this should be the default behavior.

SPECIFICATIONS

Changes overflow property of model-body if domain widget is used as
inline_model. The Inline domain editor`s selector (drop-down) will be
visible outside of modal-body.

TaskID ID-2480625

closes odoo/odoo#68586

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Odoo's Mergebot
2021-04-21 11:11:27 +02:00
committed by GitHub
6 changed files with 50 additions and 36 deletions
-5
View File
@@ -21,9 +21,4 @@
'demo/coupon_demo.xml',
],
'installable': True,
'assets': {
'web.assets_backend': [
'coupon/static/**/*',
],
}
}
-30
View File
@@ -1,30 +0,0 @@
odoo.define("coupon.CouponGenerateWizard", function (require) {
"use strict";
const FormController = require('web.FormController');
const FormView = require('web.FormView');
const viewRegistry = require('web.view_registry');
const CouponGenerateFormController = FormController.extend({
/**
* Display the domain selector popover outside the modal without scroll on modal.
* @override
*/
on_attach_callback() {
this._super(...arguments);
this.el.closest('.modal-body').style.overflow = 'visible';
},
});
const couponGenerateWizard = FormView.extend({
config: _.extend({}, FormView.prototype.config, {
Controller: CouponGenerateFormController,
}),
});
viewRegistry.add('coupons_generate_form', couponGenerateWizard);
return couponGenerateWizard;
});
@@ -4,7 +4,7 @@
<field name="name">coupon.generate.wizard.form</field>
<field name="model">coupon.generate.wizard</field>
<field name="arch" type="xml">
<form string="Generate Coupons" js_class="coupons_generate_form">
<form string="Generate Coupons">
<group>
<field name="has_partner_email" invisible="1"/>
<field name="generation_type" widget="radio"/>
@@ -3321,6 +3321,16 @@ var FieldDomain = AbstractField.extend({
this._setState();
},
/**
* We use the on_attach_callback hook here when widget is attached to the DOM, so that
* the inline 'DomainSelector' widget allows field selector to overflow if widget is
* attached within a modal.
*/
on_attach_callback() {
if (this.domainSelector && !this.inDialog) {
this.domainSelector.on_attach_callback();
}
},
//--------------------------------------------------------------------------
// Public
@@ -477,6 +477,16 @@ var DomainSelector = DomainTree.extend({
}
});
},
/**
* If 'DomainSelector' is attached within modal, the modal should have
* visible overflow to allow user to see fields drop-down.
*/
on_attach_callback() {
let $modalBodyEl = this.$el.closest('.modal-body');
if ($modalBodyEl.length !== 0) {
$modalBodyEl.css('overflow', 'visible');
}
},
//--------------------------------------------------------------------------
// Public
@@ -244,6 +244,35 @@ QUnit.module('DomainSelector', {
domainSelector.destroy();
});
QUnit.test("inline domain editor in modal", async function (assert) {
assert.expect(1);
const actions = [
{
id: 5,
name: "Partner Form",
res_model: "partner",
target: "new",
type: "ir.actions.act_window",
views: [["view_ref", "form"]],
},
];
const actionManager = await testUtils.createActionManager({
actions,
archs: {
"partner,view_ref,form": `
<form>
<field name="foo" string="Domain" widget="domain" options="{'model': 'partner'}"/>
</form>
`,
},
data: this.data,
});
await actionManager.doAction(5);
assert.strictEqual(document.querySelector('div[name="foo"]').closest('.modal-body').style.overflow,
'visible', "modal should have visible overflow if there is inline domain field widget");
actionManager.destroy();
});
});
});
});