mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix #I8H48V app_web_fullwidth将web_chatter_position的功能加入
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
{
|
||||
'name': 'Web Form Fullwidth, Full screen full width. Chatter Position ',
|
||||
'version': '16.23.02.19',
|
||||
'version': '16.23.12.08',
|
||||
'category': 'web',
|
||||
'author': 'odooai.cn',
|
||||
'website': 'https://www.odooai.cn',
|
||||
@@ -44,10 +44,14 @@
|
||||
'depends': [
|
||||
'web'
|
||||
],
|
||||
'data': [],
|
||||
'data': [
|
||||
'views/res_users_views.xml',
|
||||
'views/webclient_templates.xml',
|
||||
],
|
||||
'assets': {
|
||||
'web.assets_backend': [
|
||||
('after', 'web/static/src/views/**/*', 'app_web_fullwidth/static/src/scss/app_style_after.scss'),
|
||||
'/app_web_fullwidth/static/src/js/*.js'
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import res_users
|
||||
|
||||
21
app_web_fullwidth/models/res_users.py
Normal file
21
app_web_fullwidth/models/res_users.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
chatter_position = fields.Selection([
|
||||
("auto", "Responsive"),
|
||||
("bottom", "Bottom"),
|
||||
("sided", "Sided"),
|
||||
], default="auto",)
|
||||
|
||||
@property
|
||||
def SELF_READABLE_FIELDS(self):
|
||||
return super().SELF_READABLE_FIELDS + ["chatter_position"]
|
||||
|
||||
@property
|
||||
def SELF_WRITEABLE_FIELDS(self):
|
||||
return super().SELF_WRITEABLE_FIELDS + ["chatter_position"]
|
||||
123
app_web_fullwidth/static/src/js/form_compiler.js
Normal file
123
app_web_fullwidth/static/src/js/form_compiler.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {append} from "@web/core/utils/xml";
|
||||
import {MailFormCompiler} from "@mail/views/form/form_compiler";
|
||||
import {FormCompiler} from "@web/views/form/form_compiler";
|
||||
import {FormController} from "@web/views/form/form_controller";
|
||||
|
||||
patch(MailFormCompiler.prototype, "web_chatter_position", {
|
||||
/**
|
||||
* Patch the visibility of the Sided chatter (`C` above).
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
compile() {
|
||||
const res = this._super.apply(this, arguments);
|
||||
const chatterContainerHookXml = res.querySelector(
|
||||
".o_FormRenderer_chatterContainer"
|
||||
);
|
||||
if (!chatterContainerHookXml) {
|
||||
return res;
|
||||
}
|
||||
// Don't patch anything if the setting is "auto": this is the core behaviour
|
||||
if (odoo.web_chatter_position === "auto") {
|
||||
return res;
|
||||
} else if (odoo.web_chatter_position === "sided") {
|
||||
chatterContainerHookXml.setAttribute("t-if", "!hasAttachmentViewer()");
|
||||
} else if (odoo.web_chatter_position === "bottom") {
|
||||
chatterContainerHookXml.setAttribute("t-if", false);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
});
|
||||
|
||||
patch(FormCompiler.prototype, "web_chatter_position", {
|
||||
/**
|
||||
* Patch the css classes of the `Form`, to include an extra `h-100` class.
|
||||
* Without it, the form sheet will not be full height in some situations,
|
||||
* looking a bit weird.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
compileForm() {
|
||||
const res = this._super.apply(this, arguments);
|
||||
if (odoo.web_chatter_position === "sided") {
|
||||
const classes = res.getAttribute("t-attf-class");
|
||||
res.setAttribute("t-attf-class", `${classes} h-100`);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
/**
|
||||
* Patch the visibility of bottom chatters (`A` and `B` above).
|
||||
* `B` may not exist in some situations, so we ensure it does by creating it.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
compile(node, params) {
|
||||
const res = this._super.apply(this, arguments);
|
||||
const chatterContainerHookXml = res.querySelector(
|
||||
".o_FormRenderer_chatterContainer:not(.o-isInFormSheetBg)"
|
||||
);
|
||||
if (!chatterContainerHookXml) {
|
||||
return res;
|
||||
}
|
||||
if (chatterContainerHookXml.parentNode.classList.contains("o_form_sheet")) {
|
||||
return res;
|
||||
}
|
||||
// Don't patch anything if the setting is "auto": this is the core behaviour
|
||||
if (odoo.web_chatter_position === "auto") {
|
||||
return res;
|
||||
// For "sided", we have to remote the bottom chatter
|
||||
// (except if there is an attachment viewer, as we have to force bottom)
|
||||
} else if (odoo.web_chatter_position === "sided") {
|
||||
const formSheetBgXml = res.querySelector(".o_form_sheet_bg");
|
||||
if (!formSheetBgXml) {
|
||||
return res;
|
||||
}
|
||||
chatterContainerHookXml.setAttribute("t-if", false);
|
||||
// For "bottom", we keep the chatter in the form sheet
|
||||
// (the one used for the attachment viewer case)
|
||||
// If it's not there, we create it.
|
||||
} else if (odoo.web_chatter_position === "bottom") {
|
||||
if (params.hasAttachmentViewerInArch) {
|
||||
const sheetBgChatterContainerHookXml = res.querySelector(
|
||||
".o_FormRenderer_chatterContainer.o-isInFormSheetBg"
|
||||
);
|
||||
sheetBgChatterContainerHookXml.setAttribute("t-if", true);
|
||||
chatterContainerHookXml.setAttribute("t-if", false);
|
||||
} else {
|
||||
const formSheetBgXml = res.querySelector(".o_form_sheet_bg");
|
||||
if (!formSheetBgXml) {
|
||||
return res;
|
||||
}
|
||||
const sheetBgChatterContainerHookXml =
|
||||
chatterContainerHookXml.cloneNode(true);
|
||||
sheetBgChatterContainerHookXml.classList.add("o-isInFormSheetBg");
|
||||
sheetBgChatterContainerHookXml.setAttribute("t-if", true);
|
||||
append(formSheetBgXml, sheetBgChatterContainerHookXml);
|
||||
const sheetBgChatterContainerXml =
|
||||
sheetBgChatterContainerHookXml.querySelector("ChatterContainer");
|
||||
sheetBgChatterContainerXml.setAttribute("isInFormSheetBg", "true");
|
||||
chatterContainerHookXml.setAttribute("t-if", false);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
});
|
||||
|
||||
patch(FormController.prototype, "web_chatter_position", {
|
||||
/**
|
||||
* Patch the css classes of the form container, to include an extra `flex-row` class.
|
||||
* Without it, it'd go for flex columns direction and it won't look good.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
get className() {
|
||||
const result = this._super();
|
||||
if (odoo.web_chatter_position === "sided") {
|
||||
result["flex-row"] = true;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
});
|
||||
13
app_web_fullwidth/views/res_users_views.xml
Normal file
13
app_web_fullwidth/views/res_users_views.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="app_res_users_form" model="ir.ui.view">
|
||||
<field name="name">app.res.users.form</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='email']" position="after">
|
||||
<field name="chatter_position" widget="radio"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
12
app_web_fullwidth/views/webclient_templates.xml
Normal file
12
app_web_fullwidth/views/webclient_templates.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<template id="webclient_bootstrap" inherit_id="web.webclient_bootstrap">
|
||||
<t t-set="head_web" position="inside">
|
||||
<script type="text/javascript">
|
||||
odoo.web_chatter_position = "<t
|
||||
t-out="request.env.user.chatter_position"
|
||||
/>";
|
||||
</script>
|
||||
</t>
|
||||
</template>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user