diff --git a/app_odoo_customize/__manifest__.py b/app_odoo_customize/__manifest__.py index dac035b9..3aed7e79 100644 --- a/app_odoo_customize/__manifest__.py +++ b/app_odoo_customize/__manifest__.py @@ -78,7 +78,6 @@ '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', diff --git a/app_odoo_customize/static/src/js/dialog.js b/app_odoo_customize/static/src/js/dialog.js index 07236a8d..f38af2e4 100644 --- a/app_odoo_customize/static/src/js/dialog.js +++ b/app_odoo_customize/static/src/js/dialog.js @@ -1,92 +1,18 @@ /** @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 deleted file mode 100644 index 303e5b2b..00000000 --- a/app_odoo_customize/static/src/js/web_dialog_size.js +++ /dev/null @@ -1,56 +0,0 @@ -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/xml/web_dialog_size.xml b/app_odoo_customize/static/src/xml/web_dialog_size.xml index 7b0570a3..b42a44e7 100644 --- a/app_odoo_customize/static/src/xml/web_dialog_size.xml +++ b/app_odoo_customize/static/src/xml/web_dialog_size.xml @@ -1,16 +1,15 @@ - - - @@ -43,7 +42,7 @@