update misc

This commit is contained in:
Ivan Office
2023-09-09 03:18:43 +08:00
parent bc0fbb5d75
commit d5b111179c
8 changed files with 44 additions and 148 deletions

View File

@@ -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',

View File

@@ -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)

View File

@@ -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();
},
});
});

View File

@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<!--begin 旧widget模式-->
<!-- remove d-none if want to show, 当前没必要-->
<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 d-none">
<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 d-none">
<button type="button" class="dialog_button_restore btn btn-secondary">
<i class="fa fa-compress" />
</button>
</t>
@@ -43,7 +42,7 @@
<button
t-if="props.getsize() == 'dialog_full_screen'"
type="button"
class="btn btn-secondary dialog_button_extend d-none"
class="btn btn-secondary dialog_button_extend"
t-on-click="dialog_button_restore"
>
<i class="fa fa-compress" />
@@ -51,7 +50,7 @@
<button
t-if="props.getsize() != 'dialog_full_screen'"
type="button"
class="btn btn-secondary dialog_button_restore d-none"
class="btn btn-secondary dialog_button_restore"
t-on-click="dialog_button_extend"
>
<i class="fa fa-expand" />

View File

@@ -11,7 +11,7 @@
<field name="inherit_id" ref="base.edit_menu"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<multi_edit eval="True"/>
<attribute name="multi_edit">1</attribute>
</xpath>
<field name="complete_name" position="after">
<field name="name"/>