diff --git a/setup/web_dialog_size/odoo/addons/web_dialog_size b/setup/web_dialog_size/odoo/addons/web_dialog_size new file mode 120000 index 000000000..8dcc87d96 --- /dev/null +++ b/setup/web_dialog_size/odoo/addons/web_dialog_size @@ -0,0 +1 @@ +../../../../web_dialog_size \ No newline at end of file diff --git a/setup/web_dialog_size/setup.py b/setup/web_dialog_size/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_dialog_size/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst new file mode 100644 index 000000000..63fdada2b --- /dev/null +++ b/web_dialog_size/README.rst @@ -0,0 +1,107 @@ +=============== +Web Dialog Size +=============== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/14.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-14-0/web-14-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/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +If you want to set dialog boxes maximized by default, you need to: + +#. Go to *Settings -> Technical -> Parameters -> System Parameters* +#. Add a new record with the text *web_dialog_size.default_maximize* in + the *Key* field and the text *True* in the *Value* field + +Known issues / Roadmap +====================== + +* Allow setting default dialog size per user. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV +* Therp BV +* Siddharth Bhalgami +* Tecnativa +* Amaris + +Contributors +~~~~~~~~~~~~ + +* Anthony Muschang +* Stéphane Bidoul +* Holger Brunn +* Siddharth Bhalgami +* Wolfgang Pichler +* David Vidal +* Quentin Theuret +* `Tecnativa `_: + + * Pedro M. Baeza + * Jairo Llopis + * Ernesto Tejeda + +* Sudhir Arya +* Pierre Pizzetta + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_dialog_size/__init__.py b/web_dialog_size/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/web_dialog_size/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_dialog_size/__manifest__.py b/web_dialog_size/__manifest__.py new file mode 100644 index 000000000..9e6bb8360 --- /dev/null +++ b/web_dialog_size/__manifest__.py @@ -0,0 +1,35 @@ +# Copyright 2015 ACSONE SA/NV +# Copyright 2018 Amaris +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Web Dialog Size", + "summary": """ + A module that lets the user expand a + dialog box to the full screen width.""", + "author": "ACSONE SA/NV, " + "Therp BV, " + "Siddharth Bhalgami," + "Tecnativa, " + "Amaris, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "category": "web", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "depends": ["web"], + "installable": True, + "assets": { + "web.assets_backend": [ + "/web_dialog_size/static/src/js/web_dialog_size.js", + "/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", + ], + }, +} diff --git a/web_dialog_size/i18n/de.po b/web_dialog_size/i18n/de.po new file mode 100644 index 000000000..ac839333d --- /dev/null +++ b/web_dialog_size/i18n/de.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-10-13 20:46+0000\n" +"Last-Translator: Corneliuus \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"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" diff --git a/web_dialog_size/i18n/es.po b/web_dialog_size/i18n/es.po new file mode 100644 index 000000000..ea98745b5 --- /dev/null +++ b/web_dialog_size/i18n/es.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-05-25 11:47+0000\n" +"Last-Translator: Valentin Vinagre \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"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" diff --git a/web_dialog_size/i18n/fr.po b/web_dialog_size/i18n/fr.po new file mode 100644 index 000000000..5fc83293a --- /dev/null +++ b/web_dialog_size/i18n/fr.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-05-14 20:47+0000\n" +"Last-Translator: Yves Le Doeuff \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"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" diff --git a/web_dialog_size/i18n/it.po b/web_dialog_size/i18n/it.po new file mode 100644 index 000000000..8588aa3ee --- /dev/null +++ b/web_dialog_size/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-08-13 12:49+0000\n" +"Last-Translator: Alessandro Fiorino \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"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" diff --git a/web_dialog_size/i18n/nl.po b/web_dialog_size/i18n/nl.po new file mode 100644 index 000000000..0babcff0e --- /dev/null +++ b/web_dialog_size/i18n/nl.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-05-17 20:47+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"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" diff --git a/web_dialog_size/i18n/web_dialog_size.pot b/web_dialog_size/i18n/web_dialog_size.pot new file mode 100644 index 000000000..7eac5a644 --- /dev/null +++ b/web_dialog_size/i18n/web_dialog_size.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \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 "" + +#. 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 "" diff --git a/web_dialog_size/i18n/zh_CN.po b/web_dialog_size/i18n/zh_CN.po new file mode 100644 index 000000000..a46f346ce --- /dev/null +++ b/web_dialog_size/i18n/zh_CN.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-09-01 12:52+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: web_dialog_size +#: model:ir.model,name:web_dialog_size.model_ir_config_parameter +msgid "System Parameter" +msgstr "系统参数" diff --git a/web_dialog_size/models/__init__.py b/web_dialog_size/models/__init__.py new file mode 100644 index 000000000..bd3aa9f10 --- /dev/null +++ b/web_dialog_size/models/__init__.py @@ -0,0 +1 @@ +from . import ir_config_parameter diff --git a/web_dialog_size/models/ir_config_parameter.py b/web_dialog_size/models/ir_config_parameter.py new file mode 100644 index 000000000..493a4f6fb --- /dev/null +++ b/web_dialog_size/models/ir_config_parameter.py @@ -0,0 +1,18 @@ +# Copyright 2018 Tecnativa - Jairo Llopis +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.models import Model, api +from odoo.tools.safe_eval import const_eval + + +class IrConfigParameter(Model): + _inherit = "ir.config_parameter" + + @api.model + def get_web_dialog_size_config(self): + get_param = self.sudo().get_param + return { + "default_maximize": const_eval( + get_param("web_dialog_size.default_maximize", "False") + ) + } diff --git a/web_dialog_size/readme/CONFIGURATION.rst b/web_dialog_size/readme/CONFIGURATION.rst new file mode 100644 index 000000000..18b1ad078 --- /dev/null +++ b/web_dialog_size/readme/CONFIGURATION.rst @@ -0,0 +1,3 @@ +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``. diff --git a/web_dialog_size/readme/CONFIGURE.rst b/web_dialog_size/readme/CONFIGURE.rst new file mode 100644 index 000000000..902f3316e --- /dev/null +++ b/web_dialog_size/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +If you want to set dialog boxes maximized by default, you need to: + +#. Go to *Settings -> Technical -> Parameters -> System Parameters* +#. Add a new record with the text *web_dialog_size.default_maximize* in + the *Key* field and the text *True* in the *Value* field diff --git a/web_dialog_size/readme/CONTRIBUTORS.rst b/web_dialog_size/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..5f67550d1 --- /dev/null +++ b/web_dialog_size/readme/CONTRIBUTORS.rst @@ -0,0 +1,16 @@ +* Anthony Muschang +* Stéphane Bidoul +* Holger Brunn +* Siddharth Bhalgami +* Wolfgang Pichler +* David Vidal +* Quentin Theuret +* `Tecnativa `_: + + * Pedro M. Baeza + * Jairo Llopis + * Ernesto Tejeda + +* Sudhir Arya +* Pierre Pizzetta +* Mantas Šniukas diff --git a/web_dialog_size/readme/DESCRIPTION.rst b/web_dialog_size/readme/DESCRIPTION.rst new file mode 100644 index 000000000..398e72f50 --- /dev/null +++ b/web_dialog_size/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +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. diff --git a/web_dialog_size/readme/ROADMAP.rst b/web_dialog_size/readme/ROADMAP.rst new file mode 100644 index 000000000..8667f3e52 --- /dev/null +++ b/web_dialog_size/readme/ROADMAP.rst @@ -0,0 +1 @@ +* Allow setting default dialog size per user. diff --git a/web_dialog_size/static/description/icon.png b/web_dialog_size/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_dialog_size/static/description/icon.png differ diff --git a/web_dialog_size/static/description/index.html b/web_dialog_size/static/description/index.html new file mode 100644 index 000000000..a6dc37eae --- /dev/null +++ b/web_dialog_size/static/description/index.html @@ -0,0 +1,459 @@ + + + + + + +Web Dialog Size + + + +
+

Web Dialog Size

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

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.

+

Table of contents

+ +
+

Configuration

+

If you want to set dialog boxes maximized by default, you need to:

+
    +
  1. Go to Settings -> Technical -> Parameters -> System Parameters
  2. +
  3. +
    Add a new record with the text web_dialog_size.default_maximize in
    +
    the Key field and the text True in the Value field
    +
    +
  4. +
+
+
+

Known issues / Roadmap

+
    +
  • Allow setting default dialog size per user.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
  • Therp BV
  • +
  • Siddharth Bhalgami
  • +
  • Tecnativa
  • +
  • Amaris
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_dialog_size/static/src/js/web_dialog_draggable.esm.js b/web_dialog_size/static/src/js/web_dialog_draggable.esm.js new file mode 100644 index 000000000..f47eae5fc --- /dev/null +++ b/web_dialog_size/static/src/js/web_dialog_draggable.esm.js @@ -0,0 +1,52 @@ +/** @odoo-module **/ + +import {patch} from "@web/core/utils/patch"; +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 { + 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); + 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, + y: event.y - this.mouse_to_element_ratio.y - y, + }; + document.addEventListener("mousemove", bound_onDrag); + }); + useExternalListener(document, "mouseup", () => + document.removeEventListener("mousemove", bound_onDrag) + ); + } + 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, + y: y - this.mouse_to_element_ratio.y - this.element_position.y, + }; + } + onDrag(event) { + const {x, y} = this.getMovePosition(event); + this.el.style.left = `${x}px`; + this.el.style.top = `${y}px`; + } +} + +DialogDraggable.template = "DialogDraggable"; + +patch(Dialog, "web_dialog_size.DialogDraggable", { + components: { + ...Dialog.components, + DialogDraggable, + }, +}); diff --git a/web_dialog_size/static/src/js/web_dialog_size.esm.js b/web_dialog_size/static/src/js/web_dialog_size.esm.js new file mode 100644 index 000000000..c3f5a083e --- /dev/null +++ b/web_dialog_size/static/src/js/web_dialog_size.esm.js @@ -0,0 +1,60 @@ +/** @odoo-module **/ + +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; + +export class ExpandButton extends Component { + setup() { + this.last_size = this.props.getsize(); + this.config = rpc.query({ + model: "ir.config_parameter", + method: "get_web_dialog_size_config", + }); + + onMounted(() => { + var self = this; + this.config.then(function (r) { + if (r.default_maximize && stop) { + self.dialog_button_extend(); + } + }); + }); + } + + dialog_button_extend() { + this.props.setsize("dialog_full_screen"); + } + + dialog_button_restore() { + this.props.setsize(this.last_size); + } +} + +ExpandButton.template = "web_dialog_size.ExpandButton"; + +patch(ActionDialog.prototype, "web_dialog_size.ActionDialog", { + setup() { + this._super(...arguments); + this.setSize = this.setSize.bind(this); + this.getSize = this.getSize.bind(this); + }, + + setSize(size) { + this.size = size; + this.render(); + }, + + getSize() { + return this.size; + }, +}); + +patch(ActionDialog, "web_dialog_size.ActionDialog", { + components: { + ...ActionDialog.components, + ExpandButton, + }, +}); diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js new file mode 100644 index 000000000..02f1a6f17 --- /dev/null +++ b/web_dialog_size/static/src/js/web_dialog_size.js @@ -0,0 +1,69 @@ +odoo.define("web_dialog_size.web_dialog_size", function (require) { + "use strict"; + + var rpc = require("web.rpc"); + var Dialog = require("web.Dialog"); + + var config = rpc.query({ + model: "ir.config_parameter", + method: "get_web_dialog_size_config", + }); + + Dialog.include({ + willStart: function () { + var self = this; + return this._super.apply(this, arguments).then(function () { + self.$modal + .find(".dialog_button_extend") + .on("click", self.proxy("_extending")); + self.$modal + .find(".dialog_button_restore") + .on("click", self.proxy("_restore")); + return config.then(function (r) { + if (r.default_maximize) { + self._extending(); + } else { + self._restore(); + } + }); + }); + }, + + opened: function () { + return this._super.apply(this, arguments).then( + function () { + if (this.$modal) { + this.$modal.find(">:first-child").draggable({ + handle: ".modal-header", + helper: false, + }); + } + }.bind(this) + ); + }, + + close: function () { + if (this.$modal) { + var draggable = this.$modal.find(">:first-child").draggable("instance"); + if (draggable) { + this.$modal.find(">:first-child").draggable("destroy"); + } + } + return this._super.apply(this, arguments); + }, + + _extending: function () { + var dialog = this.$modal.find(".modal-dialog"); + dialog.addClass("dialog_full_screen"); + dialog.find(".dialog_button_extend").hide(); + dialog.find(".dialog_button_restore").show(); + }, + + _restore: function () { + var dialog = this.$modal.find(".modal-dialog"); + dialog.removeClass("dialog_full_screen"); + dialog.find(".dialog_button_restore").hide(); + dialog.find(".dialog_button_extend").show(); + }, + }); +}); diff --git a/web_dialog_size/static/src/scss/web_dialog_size.scss b/web_dialog_size/static/src/scss/web_dialog_size.scss new file mode 100644 index 000000000..abf3aba73 --- /dev/null +++ b/web_dialog_size/static/src/scss/web_dialog_size.scss @@ -0,0 +1,24 @@ +.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; + } + } + } +} diff --git a/web_dialog_size/static/src/xml/DialogDraggable.xml b/web_dialog_size/static/src/xml/DialogDraggable.xml new file mode 100644 index 000000000..6cafd8641 --- /dev/null +++ b/web_dialog_size/static/src/xml/DialogDraggable.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/web_dialog_size/static/src/xml/ExpandButton.xml b/web_dialog_size/static/src/xml/ExpandButton.xml new file mode 100644 index 000000000..22318ef73 --- /dev/null +++ b/web_dialog_size/static/src/xml/ExpandButton.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/web_dialog_size/static/src/xml/web_dialog_size.xml b/web_dialog_size/static/src/xml/web_dialog_size.xml new file mode 100644 index 000000000..e7cc3a7b6 --- /dev/null +++ b/web_dialog_size/static/src/xml/web_dialog_size.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web_dialog_size/tests/__init__.py b/web_dialog_size/tests/__init__.py new file mode 100644 index 000000000..79d02635e --- /dev/null +++ b/web_dialog_size/tests/__init__.py @@ -0,0 +1 @@ +from . import test_web_dialog_size diff --git a/web_dialog_size/tests/test_web_dialog_size.py b/web_dialog_size/tests/test_web_dialog_size.py new file mode 100644 index 000000000..53e916dd8 --- /dev/null +++ b/web_dialog_size/tests/test_web_dialog_size.py @@ -0,0 +1,20 @@ +# Copyright 2018 Tecnativa - Ernesto Tejeda +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from odoo.tests.common import TransactionCase + + +class TestWebDialogSize(TransactionCase): + def setUp(self): + super(TestWebDialogSize, self).setUp() + + def test_get_web_dialog_size_config(self): + obj = self.env["ir.config_parameter"] + + self.assertFalse(obj.get_web_dialog_size_config()["default_maximize"]) + + obj.set_param("web_dialog_size.default_maximize", "True") + self.assertTrue(obj.get_web_dialog_size_config()["default_maximize"]) + + obj.set_param("web_dialog_size.default_maximize", "False") + self.assertFalse(obj.get_web_dialog_size_config()["default_maximize"])