This commit is contained in:
Chill
2023-08-24 18:16:24 +08:00
11 changed files with 241 additions and 40 deletions

View File

@@ -77,8 +77,11 @@
'app_odoo_customize/static/src/js/user_menu.js', 'app_odoo_customize/static/src/js/user_menu.js',
'app_odoo_customize/static/src/js/ribbon.js', 'app_odoo_customize/static/src/js/ribbon.js',
'app_odoo_customize/static/src/js/dialog.js', 'app_odoo_customize/static/src/js/dialog.js',
'app_odoo_customize/static/src/js/web_dialog_size.js',
'app_odoo_customize/static/src/webclient/*.js', 'app_odoo_customize/static/src/webclient/*.js',
'app_odoo_customize/static/src/webclient/*.xml', 'app_odoo_customize/static/src/webclient/*.xml',
'app_odoo_customize/static/src/xml/res_config_edition.xml',
'app_odoo_customize/static/src/xml/web_dialog_size.xml',
], ],
}, },
'pre_init_hook': 'pre_init_hook', 'pre_init_hook': 'pre_init_hook',
@@ -130,7 +133,7 @@
35. Fixed for odoo 14. 35. Fixed for odoo 14.
36. Add refresh translate for multi module. 36. Add refresh translate for multi module.
37. Easy noupdate manage for External Identifiers(xml_id) 37. Easy noupdate manage for External Identifiers(xml_id)
38. Add Draggable Dialog enable. 38. Add Draggable and sizeable Dialog enable.
39. Only erp manager can see debug menu.. 39. Only erp manager can see debug menu..
40. Fix support for enterprise version. 40. Fix support for enterprise version.
41. Fix odoo bug, when click Preferences menu not hide in mobile. 41. Fix odoo bug, when click Preferences menu not hide in mobile.
@@ -183,7 +186,7 @@
35. 优化至odoo14适用 35. 优化至odoo14适用
36. 可为多个模块强制更新翻译 36. 可为多个模块强制更新翻译
37. noupdate字段的快速管理主要针对 xml_id 37. noupdate字段的快速管理主要针对 xml_id
38. 对话框可拖拽 38. 对话框可拖拽,可缩放,自动大屏优化
39. 只有系统管理员可以操作快速debug 39. 只有系统管理员可以操作快速debug
40. 增强对企业版的支持 40. 增强对企业版的支持
41. 修正odoo原生移动端菜单bug点击个人设置时原菜单不隐藏等 41. 修正odoo原生移动端菜单bug点击个人设置时原菜单不隐藏等

View File

@@ -293,6 +293,18 @@
<div class="oe_demo oe_screenshot img img-fluid"> <div class="oe_demo oe_screenshot img img-fluid">
<img src="setmodule2.png"/> <img src="setmodule2.png"/>
</div> </div>
<h4 class="oe_slogan">Easy Export translate follow your language</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="setmodule3.png"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h1 class="text-danger text-center"> Add Draggable and sizeable Dialog enable.</h1>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="setdialog.gif"/>
</div>
</div> </div>
</section> </section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -1,18 +1,92 @@
/** @odoo-module **/ /** @odoo-module **/
import { Dialog } from "@web/core/dialog/dialog"; import { Dialog } from "@web/core/dialog/dialog";
import {ActionDialog} from "@web/webclient/actions/action_dialog";
import {Component, onMounted} from "@odoo/owl";
import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog";
import { patch } from "@web/core/utils/patch"; import { patch } from "@web/core/utils/patch";
import { session } from "@web/session"; import { session } from "@web/session";
export class ExpandButton extends Component {
setup() {
this.last_size = this.props.getsize();
}
dialog_button_extend() {
this.props.setsize("dialog_full_screen");
this.render();
}
dialog_button_restore() {
this.props.setsize(this.last_size);
this.render();
}
}
ExpandButton.template = "app_odoo_customize.ExpandButton";
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);
//处理 owl patch
patch(Dialog.prototype, "app_odoo_customize.Dialog", { patch(Dialog.prototype, "app_odoo_customize.Dialog", {
setup() { setup() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
const app_system_name = session.app_system_name || "odooApp"; const app_system_name = session.app_system_name || "odooApp";
this.title = app_system_name; this.title = app_system_name;
this.setSize = this.setSize.bind(this);
this.getSize = this.getSize.bind(this);
owl.onMounted(() => { owl.onMounted(() => {
this.setDrag(); this.setDrag();
}); });
}, },
setSize(size) {
this.props.size = size;
this.render();
},
getSize() {
return this.props.size;
},
setDrag() {
var $dl = $('#' + this.id + ' .modal-dialog .modal-content');
if ($dl)
$dl.draggable({
handle: ".modal-header"
});
},
});
patch(SelectCreateDialog.prototype, "app_odoo_customize.SelectCreateDialog", {
setup() {
this._super.apply(this, arguments);
const app_system_name = session.app_system_name || "odooApp";
this.title = app_system_name;
this.setSize = this.setSize.bind(this);
this.getSize = this.getSize.bind(this);
owl.onMounted(() => {
this.setDrag();
});
},
setSize(size) {
this.props.size = size;
this.render();
},
getSize() {
return this.props.size;
},
setDrag() { setDrag() {
var $dl = $('#' + this.id + ' .modal-dialog .modal-content'); var $dl = $('#' + this.id + ' .modal-dialog .modal-content');
if ($dl) if ($dl)

View File

@@ -0,0 +1,56 @@
odoo.define("app_odoo_customize.web_dialog_size", function (require) {
"use strict";
var Dialog = require("web.Dialog");
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"));
});
},
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();
},
});
});

View File

@@ -1,7 +1,23 @@
.modal { .modal {
.modal-content { .modal-content {
.modal-header.ui-draggable-handle { .modal-header.ui-draggable-handle {
cursor: move; cursor: move;
}
} }
}
.modal-dialog_full_screen {
@include media-breakpoint-up(sm) {
max-width: 100%;
width: calc(100% - 50px);
}
}
.dialog_button_restore,
.dialog_button_extend {
margin-left: auto;
+ .btn-close {
margin: -8px -8px -8px 0px;
}
}
} }

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<!--owl 处理继承继承-->
<t t-inherit="web.UserMenu" t-inherit-mode="extension" owl="1">
<xpath expr="//td[hasclass('client-line-email')]" position="after">
<t t-jquery="a[data-menu='documentation']" t-operation="before">
<switch-lang/>
<a role="menuitem" href="#" data-menu="debug" class="dropdown-item">Activate the developer mode</a>
<a role="menuitem" href="#" data-menu="debugassets" class="dropdown-item">Activate the developer mode (with assets)</a>
<a role="menuitem" href="#" data-menu="quitdebug" class="dropdown-item">Deactivate the developer mode</a>
<div role="separator" class="dropdown-divider"/>
<a role="menuitem" href="#" data-menu="documentation_dev" class="dropdown-item">Developer Manual</a>
</t>
</xpath>
</t>
</templates>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve"> <templates xml:space="preserve">
<t t-extend="res_config_edition"> <t t-inherit="web.res_config_edition" t-inherit-mode="extension" owl="1">
<t t-jquery=".user-heading h3" t-operation="replace"> <xpath expr="//div[hasclass('user-heading')]//h3" position="replace">
<h3> <h3 class="px-0">
odooAi <t t-esc="widget.server_version"/> (odooai.cn Edition) Odoo <t t-esc="serverVersion"/> (<a target="_blank" href="https://www.odooai.cn" style="text-decoration: underline;">odooai.cn</a> Edition)
</h3> </h3>
</t> </xpath>
</t> </t>
</templates> </templates>

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<!--begin 旧widget模式-->
<t t-extend="web.DialogWidget">
<t t-jquery="button.btn-close" t-operation="inner">
<i class="fa fa-close" />
</t>
<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 btn btn-secondary">
<i class="fa fa-compress" />
</button>
</t>
</t>
<!--end 旧widget模式-->
<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>
<!--扩展按键-->
<t t-name="app_odoo_customize.ExpandButton" owl="1">
<button
t-if="props.getsize() == 'dialog_full_screen'"
type="button"
class="btn btn-secondary 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="btn btn-secondary dialog_button_restore"
t-on-click="dialog_button_extend"
>
<i class="fa fa-expand" />
</button>
</t>
</templates>

View File

@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve"> <templates xml:space="preserve">
<!-- <t t-extend="res_config_edition">--> <t t-inherit="web.res_config_edition" t-inherit-mode="extension" owl="1">
<!-- <t t-jquery=".user-heading h3" t-operation="replace">--> <xpath expr="//div[hasclass('user-heading')]//h3" position="replace">
<!-- <h3>--> <h3 class="px-0">
<!-- odooApp <t t-esc="widget.server_version"/> (odooai.cn Edition)--> Odoo <t t-esc="serverVersion"/> (<a target="_blank" href="https://www.odooai.cn" style="text-decoration: underline;">odooai.cn</a> Edition)
<!-- </h3>--> </h3>
<!-- </t>--> </xpath>
<!-- <t t-jquery=".user-o_web_settings_compact_subtitle small" t-operation="replace">--> </t>
<!-- <small><a target="_blank" href="http://www.gnu.org/licenses/lgpl.html" style="text-decoration: underline;">GNU LGPL Licensed</a></small>-->
<!-- </t>-->
<!-- </t>-->
</templates> </templates>