update odoo customize, misc

This commit is contained in:
Ivan Office
2023-08-24 18:13:08 +08:00
parent 2b78fe0f4b
commit 989979469e
11 changed files with 241 additions and 40 deletions

View File

@@ -293,6 +293,18 @@
<div class="oe_demo oe_screenshot img img-fluid">
<img src="setmodule2.png"/>
</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>
</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 **/
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)

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-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;
}
}
}

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">
<t t-extend="res_config_edition">
<t t-jquery=".user-heading h3" t-operation="replace">
<h3>
odooAi <t t-esc="widget.server_version"/> (odooai.cn Edition)
<t t-inherit="web.res_config_edition" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('user-heading')]//h3" position="replace">
<h3 class="px-0">
Odoo <t t-esc="serverVersion"/> (<a target="_blank" href="https://www.odooai.cn" style="text-decoration: underline;">odooai.cn</a> Edition)
</h3>
</t>
</xpath>
</t>
</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>