diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst index 147457915..efd76c091 100644 --- a/web_dialog_size/README.rst +++ b/web_dialog_size/README.rst @@ -91,6 +91,7 @@ Contributors - Pedro M. Baeza - Jairo Llopis - Ernesto Tejeda + - Carlos Roca - Sudhir Arya - Pierre Pizzetta diff --git a/web_dialog_size/__manifest__.py b/web_dialog_size/__manifest__.py index e45b9918b..c3db7866d 100644 --- a/web_dialog_size/__manifest__.py +++ b/web_dialog_size/__manifest__.py @@ -15,19 +15,25 @@ "Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", "category": "web", - "version": "16.0.1.0.1", + "version": "17.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_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", + ( + "after", + "/web/static/src/core/dialog/dialog.xml", + "/web_dialog_size/static/src/xml/web_dialog_header.xml", + ), + ( + "after", + "/web/static/src/views/view_dialogs/select_create_dialog.xml", + "/web_dialog_size/static/src/xml/select_create_dialog.xml", + ), ], }, } diff --git a/web_dialog_size/readme/CONTRIBUTORS.md b/web_dialog_size/readme/CONTRIBUTORS.md index ace311bb8..8b9a9b08c 100644 --- a/web_dialog_size/readme/CONTRIBUTORS.md +++ b/web_dialog_size/readme/CONTRIBUTORS.md @@ -9,6 +9,7 @@ - Pedro M. Baeza - Jairo Llopis - Ernesto Tejeda + - Carlos Roca - 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 aa30b0d04..eac58c273 100644 --- a/web_dialog_size/static/description/index.html +++ b/web_dialog_size/static/description/index.html @@ -442,6 +442,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Pedro M. Baeza
  • Jairo Llopis
  • Ernesto Tejeda
  • +
  • Carlos Roca
  • Sudhir Arya <sudhir@erpharbor.com>
  • 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 deleted file mode 100644 index 92ea85a35..000000000 --- a/web_dialog_size/static/src/js/web_dialog_draggable.esm.js +++ /dev/null @@ -1,50 +0,0 @@ -/** @odoo-module **/ - -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"; - -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.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, - y: event.y - this.mouse_to_element_ratio.y - y, - }; - document.addEventListener("mousemove", bound_onDrag); - }); - 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"); - }); - } - - 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); - const el = this.el.querySelector(".modal-content"); - el.style.left = `${x}px`; - el.style.top = `${y}px`; - } -} - -DialogDraggable.template = "DialogDraggable"; - -Dialog.components = Object.assign(Dialog.components || {}, {DialogDraggable}); -Object.assign(ActionDialog.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 index ae2a8c771..76379af98 100644 --- a/web_dialog_size/static/src/js/web_dialog_size.esm.js +++ b/web_dialog_size/static/src/js/web_dialog_size.esm.js @@ -1,19 +1,20 @@ /** @odoo-module **/ import {ActionDialog} from "@web/webclient/actions/action_dialog"; -import {patch} from "@web/core/utils/patch"; -import rpc from "web.rpc"; import {Component, onMounted} from "@odoo/owl"; import {Dialog} from "@web/core/dialog/dialog"; import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog"; +import {patch} from "@web/core/utils/patch"; +import {useService} from "@web/core/utils/hooks"; export class ExpandButton extends Component { setup() { + this.orm = useService("orm"); this.last_size = this.props.getsize(); - this.config = rpc.query({ - model: "ir.config_parameter", - method: "get_web_dialog_size_config", - }); + this.config = this.orm.call( + "ir.config_parameter", + "get_web_dialog_size_config" + ); onMounted(() => { var self = this; @@ -38,9 +39,9 @@ export class ExpandButton extends Component { ExpandButton.template = "web_dialog_size.ExpandButton"; -patch(Dialog.prototype, "web_dialog_size.Dialog", { +patch(Dialog.prototype, { setup() { - this._super(...arguments); + super.setup(); this.setSize = this.setSize.bind(this); this.getSize = this.getSize.bind(this); }, @@ -55,9 +56,9 @@ patch(Dialog.prototype, "web_dialog_size.Dialog", { }, }); -patch(SelectCreateDialog.prototype, "web_dialog_size.SelectCreateDialog", { +patch(SelectCreateDialog.prototype, { setup() { - this._super(...arguments); + super.setup(); this.setSize = this.setSize.bind(this); this.getSize = this.getSize.bind(this); }, diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js deleted file mode 100644 index 0afabcc2e..000000000 --- a/web_dialog_size/static/src/js/web_dialog_size.js +++ /dev/null @@ -1,50 +0,0 @@ -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")); - self.$modal.find(">:first-child").draggable({ - handle: ".modal-header", - helper: false, - }); - return config.then(function (r) { - if (r.default_maximize) { - self._extending(); - } else { - self._restore(); - } - }); - }); - }, - - _extending: function () { - var dialog = this.$modal.find(".modal-dialog"); - dialog.addClass("modal-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("modal-dialog_full_screen"); - dialog.find(".dialog_button_restore").hide(); - dialog.find(".dialog_button_extend").show(); - }, - }); -}); diff --git a/web_dialog_size/static/src/xml/DialogDraggable.xml b/web_dialog_size/static/src/xml/DialogDraggable.xml deleted file mode 100644 index bc30ace1c..000000000 --- a/web_dialog_size/static/src/xml/DialogDraggable.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - -
    - -
    -
    -
    diff --git a/web_dialog_size/static/src/xml/select_create_dialog.xml b/web_dialog_size/static/src/xml/select_create_dialog.xml new file mode 100644 index 000000000..1ba58a6bf --- /dev/null +++ b/web_dialog_size/static/src/xml/select_create_dialog.xml @@ -0,0 +1,8 @@ + + + + + props.size + + + diff --git a/web_dialog_size/static/src/xml/web_dialog_header.xml b/web_dialog_size/static/src/xml/web_dialog_header.xml new file mode 100644 index 000000000..2cdfecd9f --- /dev/null +++ b/web_dialog_size/static/src/xml/web_dialog_header.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/web_dialog_size/static/src/xml/web_dialog_size.xml b/web_dialog_size/static/src/xml/web_dialog_size.xml deleted file mode 100644 index e160bedb1..000000000 --- a/web_dialog_size/static/src/xml/web_dialog_size.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - props.size - - - - diff --git a/web_dialog_size/tests/test_web_dialog_size.py b/web_dialog_size/tests/test_web_dialog_size.py index 53e916dd8..0eefbd984 100644 --- a/web_dialog_size/tests/test_web_dialog_size.py +++ b/web_dialog_size/tests/test_web_dialog_size.py @@ -6,7 +6,7 @@ from odoo.tests.common import TransactionCase class TestWebDialogSize(TransactionCase): def setUp(self): - super(TestWebDialogSize, self).setUp() + super().setUp() def test_get_web_dialog_size_config(self): obj = self.env["ir.config_parameter"]