Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
|
||||
import { Chatter } from "@mail/chatter/web_portal/chatter";
|
||||
|
||||
patch(Chatter.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
const showNotificationMessages = browser.localStorage.getItem(
|
||||
'muk_web_chatter.notifications'
|
||||
);
|
||||
this.state.showNotificationMessages = (
|
||||
showNotificationMessages != null ?
|
||||
JSON.parse(showNotificationMessages) : true
|
||||
);
|
||||
},
|
||||
onClickNotificationsToggle() {
|
||||
const showNotificationMessages = !this.state.showNotificationMessages;
|
||||
browser.localStorage.setItem(
|
||||
'muk_web_chatter.notifications', showNotificationMessages
|
||||
);
|
||||
this.state.showNotificationMessages = showNotificationMessages;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
.o-mail-Chatter-top:has(.o-mail-Chatter-sendMessage.active) .o-mail-Composer-send {
|
||||
@extend .btn-danger
|
||||
}
|
||||
|
||||
.o-mail-Form-chatter.o-aside {
|
||||
.mk_chatter_resize {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 5px;
|
||||
height: 100%;
|
||||
cursor: col-resize;
|
||||
position: absolute;
|
||||
z-index: $o-mail-NavigableList-zIndex + 1;
|
||||
border-left: var(--ControlPanel-border-bottom, 1px solid $o-gray-300);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<templates xml:space="preserve">
|
||||
<t
|
||||
t-name="muk_web_theme.Chatter"
|
||||
t-inherit="mail.Chatter"
|
||||
t-inherit-mode="extension"
|
||||
>
|
||||
<xpath expr="//button[hasclass('o-mail-Chatter-sendMessage')]" position="replace">
|
||||
<button
|
||||
class="o-mail-Chatter-sendMessage btn text-nowrap me-1"
|
||||
t-att-class="{
|
||||
'btn-danger': !state.composerType,
|
||||
'btn-primary': state.composerType === 'message',
|
||||
'btn-secondary': state.composerType !== 'message',
|
||||
'active': state.composerType === 'message',
|
||||
'my-2': !props.compactHeight
|
||||
}"
|
||||
t-att-disabled="!state.thread.hasWriteAccess and !(state.thread.hasReadAccess and state.thread.canPostOnReadonly) and props.threadId"
|
||||
data-hotkey="m"
|
||||
t-on-click="() => this.toggleComposer('message')"
|
||||
>
|
||||
<i t-if="env.isSmall" class="fa fa-envelope me-sm-1" />
|
||||
<span class="d-none d-sm-inline">Message</span>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//button[hasclass('o-mail-Chatter-logNote')]" position="replace">
|
||||
<button
|
||||
class="o-mail-Chatter-logNote btn text-nowrap me-1"
|
||||
t-att-class="{
|
||||
'btn-primary': state.composerType === 'note',
|
||||
'btn-secondary': state.composerType !== 'note',
|
||||
'active': state.composerType === 'note',
|
||||
'my-2': !props.compactHeight
|
||||
}"
|
||||
t-att-disabled="!state.thread.hasWriteAccess and !(state.thread.hasReadAccess and state.thread.canPostOnReadonly) and props.threadId"
|
||||
data-hotkey="shift+m"
|
||||
t-on-click="() => this.toggleComposer('note')"
|
||||
>
|
||||
<i t-if="env.isSmall" class="fa fa-sticky-note me-sm-1" />
|
||||
<span class="d-none d-sm-inline">Note</span>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//button[hasclass('o-mail-Chatter-activity')]/span" position="before">
|
||||
<i t-if="env.isSmall" class="fa fa-clock-o me-sm-1"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[hasclass('o-mail-Chatter-activity')]/span" position="attributes">
|
||||
<attribute name="class" add="d-none d-sm-inline" separator=" " />
|
||||
</xpath>
|
||||
<xpath expr="//button[@t-if='props.hasAttachmentPreview and state.thread.attachmentsInWebClientView.length']" position="attributes">
|
||||
<attribute name="t-if">props.isChatterAside and props.hasAttachmentPreview and state.thread.attachmentsInWebClientView.length</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//button[@t-on-click='onClickSearch']" position="after">
|
||||
<button
|
||||
class="btn btn-link text-action px-1"
|
||||
aria-label="Show/Hide Notifications"
|
||||
title="Show/Hide Notifications"
|
||||
t-on-click="onClickNotificationsToggle"
|
||||
t-att-disabled="state.isSearchOpen"
|
||||
>
|
||||
<i
|
||||
class="fa fa-lg"
|
||||
t-att-class="{
|
||||
'fa-eye': state.showNotificationMessages,
|
||||
'fa-eye-slash': !state.showNotificationMessages,
|
||||
}"
|
||||
/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//Thread" position="attributes">
|
||||
<attribute name="showNotificationMessages">state.showNotificationMessages</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
import { Thread } from '@mail/core/common/thread';
|
||||
|
||||
patch(Thread.prototype, {
|
||||
get displayMessages() {
|
||||
let messages = (
|
||||
this.props.order === 'asc' ?
|
||||
this.props.thread.nonEmptyMessages :
|
||||
[...this.props.thread.nonEmptyMessages].reverse()
|
||||
);
|
||||
if (!this.props.showNotificationMessages) {
|
||||
messages = messages.filter(
|
||||
(msg) => !['user_notification', 'notification'].includes(
|
||||
msg.message_type
|
||||
)
|
||||
);
|
||||
}
|
||||
return messages;
|
||||
},
|
||||
});
|
||||
|
||||
Thread.props = [
|
||||
...Thread.props,
|
||||
'showNotificationMessages?',
|
||||
];
|
||||
Thread.defaultProps = {
|
||||
...Thread.defaultProps,
|
||||
showNotificationMessages: true,
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<templates xml:space="preserve">
|
||||
<t
|
||||
t-name="muk_web_theme.Thread"
|
||||
t-inherit="mail.Thread"
|
||||
t-inherit-mode="extension"
|
||||
>
|
||||
<xpath expr="//t[@t-key='msg.id']" position="attributes">
|
||||
<attribute name="t-foreach">displayMessages</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -0,0 +1,2 @@
|
||||
$o-form-renderer-max-width: 3840px;
|
||||
$o-form-view-sheet-max-width: 2560px;
|
||||
@@ -0,0 +1,66 @@
|
||||
import { session } from '@web/session';
|
||||
import { patch } from '@web/core/utils/patch';
|
||||
import { append, createElement, setAttributes } from '@web/core/utils/xml';
|
||||
|
||||
import {FormCompiler} from '@web/views/form/form_compiler';
|
||||
|
||||
patch(FormCompiler.prototype, {
|
||||
compile(node, params) {
|
||||
const res = super.compile(node, params);
|
||||
const chatterContainerHookXml = res.querySelector(
|
||||
'.o_form_renderer > .o-mail-Form-chatter'
|
||||
);
|
||||
if (!chatterContainerHookXml) {
|
||||
return res;
|
||||
}
|
||||
setAttributes(chatterContainerHookXml, {
|
||||
't-ref': 'chatterContainer',
|
||||
});
|
||||
if (session.chatter_position === 'bottom') {
|
||||
const formSheetBgXml = res.querySelector('.o_form_sheet_bg');
|
||||
if (!chatterContainerHookXml || !formSheetBgXml?.parentNode) {
|
||||
return res;
|
||||
}
|
||||
const webClientViewAttachmentViewHookXml = res.querySelector(
|
||||
'.o_attachment_preview'
|
||||
);
|
||||
const chatterContainerXml = chatterContainerHookXml.querySelector(
|
||||
"t[t-component='__comp__.mailComponents.Chatter']"
|
||||
);
|
||||
const sheetBgChatterContainerHookXml = chatterContainerHookXml.cloneNode(true);
|
||||
const sheetBgChatterContainerXml = sheetBgChatterContainerHookXml.querySelector(
|
||||
"t[t-component='__comp__.mailComponents.Chatter']"
|
||||
);
|
||||
sheetBgChatterContainerHookXml.classList.add('o-isInFormSheetBg', 'w-auto');
|
||||
append(formSheetBgXml, sheetBgChatterContainerHookXml);
|
||||
setAttributes(sheetBgChatterContainerXml, {
|
||||
isInFormSheetBg: 'true',
|
||||
isChatterAside: 'false',
|
||||
});
|
||||
setAttributes(chatterContainerXml, {
|
||||
isInFormSheetBg: 'true',
|
||||
isChatterAside: 'false',
|
||||
});
|
||||
setAttributes(chatterContainerHookXml, {
|
||||
't-if': 'false',
|
||||
});
|
||||
if (webClientViewAttachmentViewHookXml) {
|
||||
setAttributes(webClientViewAttachmentViewHookXml, {
|
||||
't-if': 'false',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setAttributes(chatterContainerHookXml, {
|
||||
't-att-style': '__comp__.chatterState.width ? `width: ${__comp__.chatterState.width}px; max-width: ${__comp__.chatterState.width}px;` : ""',
|
||||
});
|
||||
const chatterContainerResizeHookXml = createElement('span');
|
||||
chatterContainerResizeHookXml.classList.add('mk_chatter_resize');
|
||||
setAttributes(chatterContainerResizeHookXml, {
|
||||
't-on-mousedown.stop.prevent': '__comp__.onStartChatterResize.bind(__comp__)',
|
||||
't-on-dblclick.stop.prevent': '__comp__.onDoubleClickChatterResize.bind(__comp__)',
|
||||
});
|
||||
append(chatterContainerHookXml, chatterContainerResizeHookXml);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
import { useState, useRef } from '@odoo/owl';
|
||||
import { patch } from '@web/core/utils/patch';
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
|
||||
import { FormRenderer } from '@web/views/form/form_renderer';
|
||||
|
||||
patch(FormRenderer.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.chatterState = useState({
|
||||
width: browser.localStorage.getItem('muk_web_chatter.width'),
|
||||
});
|
||||
this.chatterContainer = useRef('chatterContainer');
|
||||
},
|
||||
onStartChatterResize(ev) {
|
||||
if (ev.button !== 0) {
|
||||
return;
|
||||
}
|
||||
const initialX = ev.pageX;
|
||||
const chatterElement = this.chatterContainer.el;
|
||||
const initialWidth = chatterElement.offsetWidth;
|
||||
console.log("hi", ev, initialX, initialWidth)
|
||||
const resizeStoppingEvents = [
|
||||
'keydown', 'mousedown', 'mouseup'
|
||||
];
|
||||
const resizePanel = (ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
const newWidth = Math.min(
|
||||
Math.max(50, initialWidth - (ev.pageX - initialX)),
|
||||
Math.max(chatterElement.parentElement.offsetWidth - 250, 250)
|
||||
);
|
||||
browser.localStorage.setItem('muk_web_chatter.width', newWidth);
|
||||
this.chatterState.width = newWidth;
|
||||
};
|
||||
const stopResize = (ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
if (ev.type === 'mousedown' && ev.button === 0) {
|
||||
return;
|
||||
}
|
||||
document.removeEventListener('mousemove', resizePanel, true);
|
||||
resizeStoppingEvents.forEach((stoppingEvent) => {
|
||||
document.removeEventListener(stoppingEvent, stopResize, true);
|
||||
});
|
||||
document.activeElement.blur();
|
||||
};
|
||||
document.addEventListener('mousemove', resizePanel, true);
|
||||
resizeStoppingEvents.forEach((stoppingEvent) => {
|
||||
document.addEventListener(stoppingEvent, stopResize, true);
|
||||
});
|
||||
},
|
||||
onDoubleClickChatterResize(ev) {
|
||||
browser.localStorage.removeItem('muk_web_chatter.width');
|
||||
this.chatterState.width = false;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user