From de7f74d8d8ef389b628973f7e8971fd85607caf7 Mon Sep 17 00:00:00 2001 From: Mantux11 Date: Fri, 18 Mar 2022 15:04:16 +0000 Subject: [PATCH] [15.0][MIG] web_dialog_size: migration to 15.0 --- web_dialog_size/README.rst | 11 ++-- web_dialog_size/__manifest__.py | 17 +++++- web_dialog_size/i18n/web_dialog_size.pot | 17 +----- web_dialog_size/readme/CONTRIBUTORS.rst | 1 + web_dialog_size/static/description/index.html | 7 ++- .../static/src/js/web_dialog_draggable.esm.js | 52 ++++++++++++++++ .../static/src/js/web_dialog_size.esm.js | 60 +++++++++++++++++++ .../static/src/xml/DialogDraggable.xml | 6 ++ .../static/src/xml/ExpandButton.xml | 21 +++++++ .../static/src/xml/web_dialog_size.xml | 16 ++++- web_dialog_size/templates/assets.xml | 19 ------ 11 files changed, 180 insertions(+), 47 deletions(-) create mode 100644 web_dialog_size/static/src/js/web_dialog_draggable.esm.js create mode 100644 web_dialog_size/static/src/js/web_dialog_size.esm.js create mode 100644 web_dialog_size/static/src/xml/DialogDraggable.xml create mode 100644 web_dialog_size/static/src/xml/ExpandButton.xml delete mode 100644 web_dialog_size/templates/assets.xml diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst index 63fdada2b..0109ec843 100644 --- a/web_dialog_size/README.rst +++ b/web_dialog_size/README.rst @@ -14,13 +14,13 @@ 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/14.0/web_dialog_size + :target: https://github.com/OCA/web/tree/15.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 + :target: https://translation.odoo-community.org/projects/web-15-0/web-15-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 + :target: https://runbot.odoo-community.org/runbot/162/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -54,7 +54,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -88,6 +88,7 @@ Contributors * Sudhir Arya * Pierre Pizzetta +* Mantas Šniukas Maintainers ~~~~~~~~~~~ @@ -102,6 +103,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 `_ project on GitHub. +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/__manifest__.py b/web_dialog_size/__manifest__.py index a5be6d098..b074138b2 100644 --- a/web_dialog_size/__manifest__.py +++ b/web_dialog_size/__manifest__.py @@ -15,10 +15,21 @@ "Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", "category": "web", - "version": "14.0.1.0.0", + "version": "15.0.1.0.1", "license": "AGPL-3", "depends": ["web"], - "qweb": ["static/src/xml/web_dialog_size.xml"], - "data": ["templates/assets.xml"], "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/web_dialog_size.pot b/web_dialog_size/i18n/web_dialog_size.pot index 7eac5a644..8d58b1537 100644 --- a/web_dialog_size/i18n/web_dialog_size.pot +++ b/web_dialog_size/i18n/web_dialog_size.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -13,21 +13,6 @@ msgstr "" "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" diff --git a/web_dialog_size/readme/CONTRIBUTORS.rst b/web_dialog_size/readme/CONTRIBUTORS.rst index 9da11ab82..5f67550d1 100644 --- a/web_dialog_size/readme/CONTRIBUTORS.rst +++ b/web_dialog_size/readme/CONTRIBUTORS.rst @@ -13,3 +13,4 @@ * Sudhir Arya * Pierre Pizzetta +* Mantas Šniukas diff --git a/web_dialog_size/static/description/index.html b/web_dialog_size/static/description/index.html index a6dc37eae..94f2deadb 100644 --- a/web_dialog_size/static/description/index.html +++ b/web_dialog_size/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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.

@@ -408,7 +408,7 @@ It also adds draggable support to the dialogs.

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.

+feedback.

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

@@ -441,6 +441,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Sudhir Arya <sudhir@erpharbor.com>
  • Pierre Pizzetta <pierre@devreaction.com>
  • +
  • Mantas Šniukas <mantas@vialaurea.lt>
  • @@ -450,7 +451,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    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.

    +

    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/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 index d43a79b73..e7cc3a7b6 100644 --- a/web_dialog_size/static/src/xml/web_dialog_size.xml +++ b/web_dialog_size/static/src/xml/web_dialog_size.xml @@ -1,5 +1,7 @@ - + + @@ -13,4 +15,16 @@ + + + + + + + + + + + + diff --git a/web_dialog_size/templates/assets.xml b/web_dialog_size/templates/assets.xml deleted file mode 100644 index cb68c4697..000000000 --- a/web_dialog_size/templates/assets.xml +++ /dev/null @@ -1,19 +0,0 @@ - - -