diff --git a/app_odoo_customize/__manifest__.py b/app_odoo_customize/__manifest__.py index eb3a9b08..b9b82107 100644 --- a/app_odoo_customize/__manifest__.py +++ b/app_odoo_customize/__manifest__.py @@ -77,8 +77,11 @@ 'app_odoo_customize/static/src/js/user_menu.js', 'app_odoo_customize/static/src/js/ribbon.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/*.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', @@ -130,7 +133,7 @@ 35. Fixed for odoo 14. 36. Add refresh translate for multi module. 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.. 40. Fix support for enterprise version. 41. Fix odoo bug, when click Preferences menu not hide in mobile. @@ -183,7 +186,7 @@ 35. 优化至odoo14适用 36. 可为多个模块强制更新翻译 37. noupdate字段的快速管理,主要针对 xml_id - 38. 对话框可拖拽 + 38. 对话框可拖拽,可缩放,自动大屏优化 39. 只有系统管理员可以操作快速debug 40. 增强对企业版的支持 41. 修正odoo原生移动端菜单bug,点击个人设置时,原菜单不隐藏等 diff --git a/app_odoo_customize/static/description/index.html b/app_odoo_customize/static/description/index.html index d791b665..5b534422 100644 --- a/app_odoo_customize/static/description/index.html +++ b/app_odoo_customize/static/description/index.html @@ -293,6 +293,18 @@
+

Easy Export translate follow your language

+
+ +
+ + +
+
+

Add Draggable and sizeable Dialog enable.

+
+ +
diff --git a/app_odoo_customize/static/description/setdialog.gif b/app_odoo_customize/static/description/setdialog.gif new file mode 100644 index 00000000..5295a046 Binary files /dev/null and b/app_odoo_customize/static/description/setdialog.gif differ diff --git a/app_odoo_customize/static/description/setmodule3.png b/app_odoo_customize/static/description/setmodule3.png new file mode 100644 index 00000000..cbd2ce22 Binary files /dev/null and b/app_odoo_customize/static/description/setmodule3.png differ diff --git a/app_odoo_customize/static/src/js/dialog.js b/app_odoo_customize/static/src/js/dialog.js index f38af2e4..07236a8d 100644 --- a/app_odoo_customize/static/src/js/dialog.js +++ b/app_odoo_customize/static/src/js/dialog.js @@ -1,18 +1,92 @@ /** @odoo-module **/ 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 { 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", { 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() { + 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() { var $dl = $('#' + this.id + ' .modal-dialog .modal-content'); if ($dl) diff --git a/app_odoo_customize/static/src/js/web_dialog_size.js b/app_odoo_customize/static/src/js/web_dialog_size.js new file mode 100644 index 00000000..303e5b2b --- /dev/null +++ b/app_odoo_customize/static/src/js/web_dialog_size.js @@ -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(); + }, + }); +}); diff --git a/app_odoo_customize/static/src/scss/dialog.scss b/app_odoo_customize/static/src/scss/dialog.scss index ad828ffc..c740a405 100644 --- a/app_odoo_customize/static/src/scss/dialog.scss +++ b/app_odoo_customize/static/src/scss/dialog.scss @@ -1,7 +1,23 @@ -.modal { - .modal-content { - .modal-header.ui-draggable-handle { - cursor: move; - } +.modal { + .modal-content { + .modal-header.ui-draggable-handle { + 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; + } + } } \ No newline at end of file diff --git a/app_odoo_customize/static/src/xml/customize_user_menu.xml b/app_odoo_customize/static/src/xml/customize_user_menu.xml deleted file mode 100644 index 65ed3b4c..00000000 --- a/app_odoo_customize/static/src/xml/customize_user_menu.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - Activate the developer mode - Activate the developer mode (with assets) - Deactivate the developer mode -