[15.0][MIG] web_dialog_size: migration to 15.0

pull/2919/head
Mantux11 2022-03-18 15:04:16 +00:00 committed by Carlos Roca
parent 22892259d0
commit de7f74d8d8
11 changed files with 180 additions and 47 deletions

View File

@ -14,13 +14,13 @@ Web Dialog Size
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |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 :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -54,7 +54,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. 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. 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 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:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `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**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -88,6 +88,7 @@ Contributors
* Sudhir Arya <sudhir@erpharbor.com> * Sudhir Arya <sudhir@erpharbor.com>
* Pierre Pizzetta <pierre@devreaction.com> * Pierre Pizzetta <pierre@devreaction.com>
* Mantas Šniukas <mantas@vialaurea.lt>
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/14.0/web_dialog_size>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_dialog_size>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -15,10 +15,21 @@
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
"category": "web", "category": "web",
"version": "14.0.1.0.0", "version": "15.0.1.0.1",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["web"], "depends": ["web"],
"qweb": ["static/src/xml/web_dialog_size.xml"],
"data": ["templates/assets.xml"],
"installable": True, "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",
],
},
} }

View File

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 14.0\n" "Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -13,21 +13,6 @@ msgstr ""
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: \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 #. module: web_dialog_size
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter #: model:ir.model,name:web_dialog_size.model_ir_config_parameter
msgid "System Parameter" msgid "System Parameter"

View File

@ -13,3 +13,4 @@
* Sudhir Arya <sudhir@erpharbor.com> * Sudhir Arya <sudhir@erpharbor.com>
* Pierre Pizzetta <pierre@devreaction.com> * Pierre Pizzetta <pierre@devreaction.com>
* Mantas Šniukas <mantas@vialaurea.lt>

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/14.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-14-0/web-14-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/14.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" 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 module that lets the user expand/restore the dialog box size through a button <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). in the upper right corner (imitating most windows managers).
It also adds draggable support to the dialogs.</p> It also adds draggable support to the dialogs.</p>
@ -408,7 +408,7 @@ It also adds draggable support to the dialogs.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <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. 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 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:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <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>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -441,6 +441,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</li> </li>
<li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li> <li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li>
<li>Pierre Pizzetta &lt;<a class="reference external" href="mailto:pierre&#64;devreaction.com">pierre&#64;devreaction.com</a>&gt;</li> <li>Pierre Pizzetta &lt;<a class="reference external" href="mailto:pierre&#64;devreaction.com">pierre&#64;devreaction.com</a>&gt;</li>
<li>Mantas Šniukas &lt;<a class="reference external" href="mailto:mantas&#64;vialaurea.lt">mantas&#64;vialaurea.lt</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -450,7 +451,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/14.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/15.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> <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>
</div> </div>

View File

@ -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,
},
});

View File

@ -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,
},
});

View File

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

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<t t-name="web_dialog_size.ExpandButton" owl="1">
<button
t-if="props.getsize() == 'dialog_full_screen'"
type="button"
class="close dialog_button_extend"
t-on-click="dialog_button_restore"
>
<i class="fa fa-compress" />
</button>
<button
t-if="props.getsize() != 'dialog_full_screen'"
type="button"
class="close dialog_button_restore"
t-on-click="dialog_button_extend"
>
<i class="fa fa-expand" />
</button>
</t>
</templates>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve"> <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-extend="Dialog">
<t t-jquery="button.close" t-operation="inner"> <t t-jquery="button.close" t-operation="inner">
<i class="fa fa-close" /> <i class="fa fa-close" />
@ -13,4 +15,16 @@
</button> </button>
</t> </t>
</t> </t>
<t t-inherit="web.ActionDialog" 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>
<xpath expr="//button[hasclass('close')]" position="before">
<ExpandButton getsize="getSize" setsize="setSize" />
</xpath>
</t>
</templates> </templates>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template
id="assets_backend"
name="web_dialog_size assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<link
rel="stylesheet"
href="/web_dialog_size/static/src/scss/web_dialog_size.scss"
/>
<script
type="text/javascript"
src="/web_dialog_size/static/src/js/web_dialog_size.js"
/>
</xpath>
</template>
</odoo>