[IMP] web_dialog_size: Migration to 16.0

[IMP] web_dialog_size: Migration to 16.0

[REM] Remove duplicate configuration readme file

[FIX] Make it work for normal dialogs also

[FIX] SelectCreateDialog

precommit
pull/2919/head
tarteo 2023-03-02 15:17:23 +01:00 committed by Carlos Roca
parent de7f74d8d8
commit 0b8750db7c
18 changed files with 181 additions and 168 deletions

View File

@ -2,10 +2,13 @@
Web Dialog Size
===============
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:12e664b8d9a56a20606514048d61cfecbade928aa7878d88fb6530eec6c732f1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@ -14,14 +17,14 @@ Web Dialog Size
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/15.0/web_dialog_size
:target: https://github.com/OCA/web/tree/16.0/web_dialog_size
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_dialog_size
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_dialog_size
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/15.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -37,6 +40,7 @@ It also adds draggable support to the dialogs.
Configuration
=============
By default, the module respects the caller's ``dialog_size`` option.
If you want to set dialog boxes maximized by default, you need to:
#. Go to *Settings -> Technical -> Parameters -> System Parameters*
@ -53,8 +57,8 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_dialog_size%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_dialog_size%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -103,6 +107,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_dialog_size>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_dialog_size>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -15,7 +15,7 @@
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"category": "web",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"depends": ["web"],
"installable": True,
@ -25,8 +25,6 @@
"/web_dialog_size/static/src/js/web_dialog_size.esm.js",
"/web_dialog_size/static/src/js/web_dialog_draggable.esm.js",
"/web_dialog_size/static/src/scss/web_dialog_size.scss",
],
"web.assets_qweb": [
"/web_dialog_size/static/src/xml/web_dialog_size.xml",
"/web_dialog_size/static/src/xml/ExpandButton.xml",
"/web_dialog_size/static/src/xml/DialogDraggable.xml",

View File

@ -16,22 +16,16 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__display_name
msgid "Display Name"
msgstr "Anzeigename"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__id
msgid "ID"
msgstr "ID"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter____last_update
msgid "Last Modified on"
msgstr "Zuletzt bearbeitet am"
#. module: web_dialog_size
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter
msgid "System Parameter"
msgstr "Systemparameter"
#~ msgid "Display Name"
#~ msgstr "Anzeigename"
#~ msgid "ID"
#~ msgstr "ID"
#~ msgid "Last Modified on"
#~ msgstr "Zuletzt bearbeitet am"

View File

@ -16,22 +16,10 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__display_name
msgid "Display Name"
msgstr ""
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__id
msgid "ID"
msgstr "ID"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter____last_update
msgid "Last Modified on"
msgstr ""
#. module: web_dialog_size
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter
msgid "System Parameter"
msgstr "Parámetro del sistema"
#~ msgid "ID"
#~ msgstr "ID"

View File

@ -16,22 +16,10 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__id
msgid "ID"
msgstr ""
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter____last_update
msgid "Last Modified on"
msgstr ""
#. module: web_dialog_size
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter
msgid "System Parameter"
msgstr "Paramètre système"
#~ msgid "Display Name"
#~ msgstr "Nom affiché"

View File

@ -16,22 +16,16 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__display_name
msgid "Display Name"
msgstr "Nome Visualizzato"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__id
msgid "ID"
msgstr "ID"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter____last_update
msgid "Last Modified on"
msgstr "Ultima Modifica il"
#. module: web_dialog_size
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter
msgid "System Parameter"
msgstr "Parametro di Sistema"
#~ msgid "Display Name"
#~ msgstr "Nome Visualizzato"
#~ msgid "ID"
#~ msgstr "ID"
#~ msgid "Last Modified on"
#~ msgstr "Ultima Modifica il"

View File

@ -16,22 +16,16 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__display_name
msgid "Display Name"
msgstr "Weergavenaam"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter__id
msgid "ID"
msgstr "ID"
#. module: web_dialog_size
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter____last_update
msgid "Last Modified on"
msgstr "Laatst Gewijzigd op"
#. module: web_dialog_size
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter
msgid "System Parameter"
msgstr "Systeem Parameter"
#~ msgid "Display Name"
#~ msgstr "Weergavenaam"
#~ msgid "ID"
#~ msgstr "ID"
#~ msgid "Last Modified on"
#~ msgstr "Laatst Gewijzigd op"

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"

View File

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_dialog_size
# * web_dialog_size
#
msgid ""
msgstr ""

View File

@ -1,3 +0,0 @@
By default, the module respects the caller's ``dialog_size`` option.
If you want to override this and have all dialogs maximized by default,
set the configuration parameter ``web_dialog_size.default_maximize`` to ``1``.

View File

@ -1,3 +1,4 @@
By default, the module respects the caller's ``dialog_size`` option.
If you want to set dialog boxes maximized by default, you need to:
#. Go to *Settings -> Technical -> Parameters -> System Parameters*

View File

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Web Dialog Size</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
@ -366,28 +366,31 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:12e664b8d9a56a20606514048d61cfecbade928aa7878d88fb6530eec6c732f1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_dialog_size"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_dialog_size"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_dialog_size"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_dialog_size"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>A module that lets the user expand/restore the dialog box size through a button
in the upper right corner (imitating most windows managers).
It also adds draggable support to the dialogs.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>If you want to set dialog boxes maximized by default, you need to:</p>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>By default, the module respects the callers <tt class="docutils literal">dialog_size</tt> option.
If you want to set dialog boxes maximized by default, you need to:</p>
<ol class="arabic simple">
<li>Go to <em>Settings -&gt; Technical -&gt; Parameters -&gt; System Parameters</em></li>
<li><dl class="first docutils">
@ -398,23 +401,23 @@ It also adds draggable support to the dialogs.</p>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Allow setting default dialog size per user.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_dialog_size%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_dialog_size%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>ACSONE SA/NV</li>
<li>Therp BV</li>
@ -424,7 +427,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Anthony Muschang &lt;<a class="reference external" href="mailto:anthony.muschang&#64;acsone.eu">anthony.muschang&#64;acsone.eu</a>&gt;</li>
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
@ -445,13 +448,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_dialog_size">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_dialog_size">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -1,19 +1,19 @@
/** @odoo-module **/
import {patch} from "@web/core/utils/patch";
import {ActionDialog} from "@web/webclient/actions/action_dialog";
import {onMounted, useExternalListener} from "@odoo/owl";
import {useListener} from "@web/core/utils/hooks";
import {LegacyComponent} from "@web/legacy/legacy_component";
import {Dialog} from "@web/core/dialog/dialog";
const {useExternalListener} = owl.hooks;
import {useListener} from "web.custom_hooks";
const {Component} = owl;
export class DialogDraggable extends Component {
export class DialogDraggable extends LegacyComponent {
setup() {
this.element_position = {x: 0, y: 0};
this.mouse_to_element_ratio = {x: 0, y: 0};
const bound_onDrag = this.onDrag.bind(this);
useListener("mousedown", "header.modal-header", (event) => {
const y = parseInt(this.el.offsetTop, 10);
const x = parseInt(this.el.offsetLeft, 10);
const y = parseInt(this.el.querySelector(".modal-content").offsetTop, 10);
const x = parseInt(this.el.querySelector(".modal-content").offsetLeft, 10);
this.mouse_to_element_ratio = {x: event.x - x, y: event.y - y};
this.element_position = {
x: event.x - this.mouse_to_element_ratio.x - x,
@ -24,11 +24,12 @@ export class DialogDraggable extends Component {
useExternalListener(document, "mouseup", () =>
document.removeEventListener("mousemove", bound_onDrag)
);
onMounted(() => {
this.el.querySelector(".modal-content").classList.add("position-absolute");
this.el.parentNode.classList.add("position-relative");
});
}
mounted() {
this.el.classList.add("position-absolute");
this.el.offsetParent.classList.add("position-relative");
}
getMovePosition({x, y}) {
return {
x: x - this.mouse_to_element_ratio.x - this.element_position.x,
@ -37,16 +38,13 @@ export class DialogDraggable extends Component {
}
onDrag(event) {
const {x, y} = this.getMovePosition(event);
this.el.style.left = `${x}px`;
this.el.style.top = `${y}px`;
const el = this.el.querySelector(".modal-content");
el.style.left = `${x}px`;
el.style.top = `${y}px`;
}
}
DialogDraggable.template = "DialogDraggable";
patch(Dialog, "web_dialog_size.DialogDraggable", {
components: {
...Dialog.components,
DialogDraggable,
},
});
Dialog.components = Object.assign(Dialog.components || {}, {DialogDraggable});
Object.assign(ActionDialog.components, {DialogDraggable});

View File

@ -3,8 +3,9 @@
import {ActionDialog} from "@web/webclient/actions/action_dialog";
import {patch} from "@web/core/utils/patch";
import rpc from "web.rpc";
const {Component} = owl;
const {onMounted} = owl.hooks;
import {Component, onMounted} from "@odoo/owl";
import {Dialog} from "@web/core/dialog/dialog";
import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog";
export class ExpandButton extends Component {
setup() {
@ -26,16 +27,18 @@ export class ExpandButton extends Component {
dialog_button_extend() {
this.props.setsize("dialog_full_screen");
this.render();
}
dialog_button_restore() {
this.props.setsize(this.last_size);
this.render();
}
}
ExpandButton.template = "web_dialog_size.ExpandButton";
patch(ActionDialog.prototype, "web_dialog_size.ActionDialog", {
patch(Dialog.prototype, "web_dialog_size.Dialog", {
setup() {
this._super(...arguments);
this.setSize = this.setSize.bind(this);
@ -43,18 +46,37 @@ patch(ActionDialog.prototype, "web_dialog_size.ActionDialog", {
},
setSize(size) {
this.size = size;
this.props.size = size;
this.render();
},
getSize() {
return this.size;
return this.props.size;
},
});
patch(ActionDialog, "web_dialog_size.ActionDialog", {
components: {
...ActionDialog.components,
ExpandButton,
patch(SelectCreateDialog.prototype, "web_dialog_size.SelectCreateDialog", {
setup() {
this._super(...arguments);
this.setSize = this.setSize.bind(this);
this.getSize = this.getSize.bind(this);
},
setSize(size) {
this.props.size = size;
this.render();
},
getSize() {
return this.props.size;
},
});
Object.assign(ActionDialog.components, {ExpandButton});
SelectCreateDialog.components = Object.assign(SelectCreateDialog.components || {}, {
ExpandButton,
});
Dialog.components = Object.assign(Dialog.components || {}, {ExpandButton});
// Patch annoying validation method
Dialog.props.size.validate = (s) =>
["sm", "md", "lg", "xl", "dialog_full_screen"].includes(s);

View File

@ -1,24 +1,16 @@
.modal {
.dialog_full_screen {
.modal-dialog_full_screen {
@include media-breakpoint-up(sm) {
max-width: 100%;
width: calc(100% - 50px);
}
}
.modal-header button.close {
font-size: 18px;
&:not(.dialog_button_extend):not(.dialog_button_restore) {
@include media-breakpoint-up(sm) {
margin-left: 15px;
}
}
&.dialog_button_extend,
.dialog_button_restore {
@include media-breakpoint-down(sm) {
display: none !important;
}
.dialog_button_restore,
.dialog_button_extend {
margin-left: auto;
+ .btn-close {
margin: -8px -8px -8px 0px;
}
}
}

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<t t-name="DialogDraggable" owl="1">
<t t-slot="default" />
<div>
<t t-slot="default" />
</div>
</t>
</templates>

View File

@ -4,7 +4,7 @@
<button
t-if="props.getsize() == 'dialog_full_screen'"
type="button"
class="close dialog_button_extend"
class="btn btn-secondary dialog_button_extend"
t-on-click="dialog_button_restore"
>
<i class="fa fa-compress" />
@ -12,7 +12,7 @@
<button
t-if="props.getsize() != 'dialog_full_screen'"
type="button"
class="close dialog_button_restore"
class="btn btn-secondary dialog_button_restore"
t-on-click="dialog_button_extend"
>
<i class="fa fa-expand" />

View File

@ -2,20 +2,38 @@
<templates xml:space="preserve">
<!-- This is for old Dialog template.
Because Odoo haven't done every template to OWL. -->
<t t-extend="Dialog">
<t t-jquery="button.close" t-operation="inner">
<t t-extend="web.DialogWidget">
<t t-jquery="button.btn-close" t-operation="inner">
<i class="fa fa-close" />
</t>
<t t-jquery="button.close" t-operation="before">
<button type="button" class="dialog_button_extend close">
<t t-jquery="button.btn-close" t-operation="before">
<button type="button" class="dialog_button_extend btn btn-secondary">
<i class="fa fa-expand" />
</button>
<button type="button" class="dialog_button_restore close">
<button type="button" class="dialog_button_restore btn btn-secondary">
<i class="fa fa-compress" />
</button>
</t>
</t>
<t t-inherit="web.LegacyAdaptedActionDialog" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('modal-content')]" position="before">
<DialogDraggable />
</xpath>
<DialogDraggable position="inside">
<xpath expr="//div[hasclass('modal-content')]" position="move" />
</DialogDraggable>
</t>
<t t-inherit="web.Dialog" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('modal-content')]" position="before">
<DialogDraggable />
</xpath>
<DialogDraggable position="inside">
<xpath expr="//div[hasclass('modal-content')]" position="move" />
</DialogDraggable>
</t>
<t t-inherit="web.ActionDialog" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('modal-content')]" position="before">
<DialogDraggable />
@ -23,8 +41,28 @@
<DialogDraggable position="inside">
<xpath expr="//div[hasclass('modal-content')]" position="move" />
</DialogDraggable>
<xpath expr="//button[hasclass('close')]" position="before">
<ExpandButton getsize="getSize" setsize="setSize" />
</t>
<t t-inherit="web.ActionDialog.header" t-inherit-mode="extension" owl="1">
<xpath expr="//button[hasclass('btn-close')]" position="before">
<ExpandButton getsize="getSize" setsize="setSize" t-if="!isFullscreen" />
</xpath>
</t>
<t t-inherit="web.Dialog.header" t-inherit-mode="extension" owl="1">
<xpath expr="//button[hasclass('btn-close')]" position="before">
<ExpandButton
getsize="getSize"
setsize="setSize"
t-if="!isFullscreen and getSize and setSize"
/>
</xpath>
</t>
<t t-inherit="web.SelectCreateDialog" t-inherit-mode="extension" owl="1">
<xpath expr="//Dialog" position="attributes">
<attribute name="size">props.size</attribute>
</xpath>
</t>
</templates>