forked from Techsystech/web
[MIG] web_send_message_popup: Migration to 15.0
parent
ecb8d57ff1
commit
0ce97b7ad4
|
@ -2,12 +2,14 @@
|
|||
# License AGPL-3.0 or later (http://gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Web Send Message as Popup",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "15.0.1.0.0",
|
||||
"author": "Camptocamp, Odoo Community Association (OCA)",
|
||||
"maintainer": "Camptocamp",
|
||||
"license": "AGPL-3",
|
||||
"category": "Hidden",
|
||||
"depends": ["web", "mail"],
|
||||
"website": "https://github.com/OCA/web",
|
||||
"data": ["templates/assets.xml"],
|
||||
"assets": {
|
||||
"web.assets_backend": ["web_send_message_popup/static/src/models/**/*.js"]
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/* Copyright 2019-2021 Camptocamp SA
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
odoo.define("web_send_message_popup/static/src/js/chatter.js", function (require) {
|
||||
"use strict";
|
||||
|
||||
const components = {
|
||||
Composer: require("mail/static/src/components/chatter_topbar/chatter_topbar.js"),
|
||||
};
|
||||
const {patch} = require("web.utils");
|
||||
|
||||
patch(components.Composer, "web_send_message_popup/static/src/js/chatter.js", {
|
||||
/**
|
||||
* Overwrite to always launch full composer instead of quick messages
|
||||
*/
|
||||
_onClickSendMessage() {
|
||||
this._super.apply(this, arguments);
|
||||
if (
|
||||
this.chatter.composer &&
|
||||
this.chatter.isComposerVisible &&
|
||||
!this.chatter.composer.isLog
|
||||
) {
|
||||
this.chatter.update({isComposerVisible: false});
|
||||
this.chatter.composer.openFullComposer();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
|
@ -0,0 +1,57 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {clear} from "@mail/model/model_field_command";
|
||||
import {escapeAndCompactTextContent} from "@mail/js/utils";
|
||||
import {registerInstancePatchModel} from "@mail/model/model_core";
|
||||
|
||||
registerInstancePatchModel("mail.chatter", "web_send_message_popup.ChatterPatch", {
|
||||
onClickSendMessage() {
|
||||
if (this.composerView) {
|
||||
// Change `isLog` to false since this should only be possible when you press
|
||||
// "Log Note" first, otherwise this won't hurt.
|
||||
this.composerView.composer.update({isLog: false});
|
||||
// Open the full composer with `composerView` because it carries through the
|
||||
// composer options.
|
||||
this.composerView.openFullComposer();
|
||||
// Clear the `composerView` since we don't need it no more.
|
||||
this.update({composerView: clear()});
|
||||
return;
|
||||
}
|
||||
this.openFullComposer();
|
||||
},
|
||||
openFullComposer() {
|
||||
// Rough copy of composer view function `openFullComposer`.
|
||||
// Get composer from thread.
|
||||
// We access data from the composer since history still is saved there.
|
||||
// e.g. open and close "Log note".
|
||||
const composer = this.thread.composer;
|
||||
const context = {
|
||||
default_attachment_ids: composer.attachments.map((att) => att.id),
|
||||
default_body: escapeAndCompactTextContent(composer.textInputContent),
|
||||
default_is_log: false,
|
||||
default_model: this.threadModel,
|
||||
default_partner_ids: composer.recipients.map((partner) => partner.id),
|
||||
default_res_id: this.threadId,
|
||||
mail_post_autofollow: true,
|
||||
};
|
||||
const action = {
|
||||
type: "ir.actions.act_window",
|
||||
res_model: "mail.compose.message",
|
||||
view_mode: "form",
|
||||
views: [[false, "form"]],
|
||||
target: "new",
|
||||
context,
|
||||
};
|
||||
const options = {
|
||||
on_close: () => {
|
||||
if (composer.exists()) {
|
||||
composer._reset();
|
||||
if (composer.activeThread) {
|
||||
composer.activeThread.loadNewMessages();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
this.env.bus.trigger("do-action", {action, options});
|
||||
},
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="web_send_message_popup assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_send_message_popup/static/src/js/chatter.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
Reference in New Issue