mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[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
This commit is contained in:
@@ -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&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 caller’s <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 -> Technical -> Parameters -> 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 <<a class="reference external" href="mailto:anthony.muschang@acsone.eu">anthony.muschang@acsone.eu</a>></li>
|
||||
<li>Stéphane Bidoul <<a class="reference external" href="mailto:stephane.bidoul@acsone.eu">stephane.bidoul@acsone.eu</a>></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>
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user