Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
81
web_dialog_size/static/src/js/web_dialog_size.esm.js
Executable file
81
web_dialog_size/static/src/js/web_dialog_size.esm.js
Executable file
@@ -0,0 +1,81 @@
|
||||
import {Component, onMounted} from "@odoo/owl";
|
||||
import {ActionDialog} from "@web/webclient/actions/action_dialog";
|
||||
import {Dialog} from "@web/core/dialog/dialog";
|
||||
import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {useService} from "@web/core/utils/hooks";
|
||||
|
||||
export class ExpandButton extends Component {
|
||||
setup() {
|
||||
this.orm = useService("orm");
|
||||
this.last_size = this.props.getsize();
|
||||
this.config = this.orm.call(
|
||||
"ir.config_parameter",
|
||||
"get_web_dialog_size_config"
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
var self = this;
|
||||
this.config.then(function (r) {
|
||||
if (r.default_maximize) {
|
||||
self.dialog_button_extend();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
dialog_button_extend() {
|
||||
this.props.setsize("dialog_full_screen");
|
||||
this.render();
|
||||
}
|
||||
|
||||
dialog_button_restore() {
|
||||
this.props.setsize(this.last_size);
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
ExpandButton.template = "web_dialog_size.ExpandButton";
|
||||
|
||||
patch(Dialog.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.setSize = this.setSize.bind(this);
|
||||
this.getSize = this.getSize.bind(this);
|
||||
},
|
||||
|
||||
setSize(size) {
|
||||
this.props.size = size;
|
||||
this.render();
|
||||
},
|
||||
|
||||
getSize() {
|
||||
return this.props.size;
|
||||
},
|
||||
});
|
||||
|
||||
patch(SelectCreateDialog.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.setSize = this.setSize.bind(this);
|
||||
this.getSize = this.getSize.bind(this);
|
||||
},
|
||||
|
||||
setSize(size) {
|
||||
this.props.size = size;
|
||||
this.render();
|
||||
},
|
||||
|
||||
getSize() {
|
||||
return this.props.size;
|
||||
},
|
||||
});
|
||||
|
||||
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);
|
||||
16
web_dialog_size/static/src/scss/web_dialog_size.scss
Executable file
16
web_dialog_size/static/src/scss/web_dialog_size.scss
Executable file
@@ -0,0 +1,16 @@
|
||||
.modal {
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
web_dialog_size/static/src/xml/ExpandButton.xml
Executable file
21
web_dialog_size/static/src/xml/ExpandButton.xml
Executable file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<templates>
|
||||
<t t-name="web_dialog_size.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-window-restore" />
|
||||
</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-window-maximize" />
|
||||
</button>
|
||||
</t>
|
||||
</templates>
|
||||
8
web_dialog_size/static/src/xml/select_create_dialog.xml
Executable file
8
web_dialog_size/static/src/xml/select_create_dialog.xml
Executable file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-inherit="web.SelectCreateDialog" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//Dialog" position="attributes">
|
||||
<attribute name="size">props.size</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
13
web_dialog_size/static/src/xml/web_dialog_header.xml
Executable file
13
web_dialog_size/static/src/xml/web_dialog_header.xml
Executable file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<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>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user