diff --git a/setup/web_chatt_filtering/odoo/addons/web_chatt_filtering b/setup/web_chatt_filtering/odoo/addons/web_chatt_filtering new file mode 120000 index 000000000000..d782e51d145d --- /dev/null +++ b/setup/web_chatt_filtering/odoo/addons/web_chatt_filtering @@ -0,0 +1 @@ +../../../../web_chatt_filtering \ No newline at end of file diff --git a/setup/web_chatt_filtering/setup.py b/setup/web_chatt_filtering/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_chatt_filtering/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_chatt_filtering/README.rst b/web_chatt_filtering/README.rst new file mode 100644 index 000000000000..876af1b30fe4 --- /dev/null +++ b/web_chatt_filtering/README.rst @@ -0,0 +1,100 @@ +==================== +mail_chatt_filtering +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/15.0/web_chatt_filtering + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_chatt_filtering + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +After working with Odoo a long time and load lot of loaded data, the amount of messages displayed inside the chatter of a record start to be significantly big + +This module introduces a filter in the Chatter +.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/initial_chatter_state.png + +Next functionalities are provided: +* Filter messages by content + +.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/filter_content.png + +* Filter messages by author + +.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/filter_author.png + +* Reverse filtering on author + +F.ex. <-admin> will show all the messages in the chatt excluding the ones of the Administrator + +.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/filter_excluding_author.png + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Just installing the module is enough to have this functionality working. No configuration needed + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Pedro Gonzalez + +Contributors +~~~~~~~~~~~~ + +* `Pesol `__: + + * Pedro Evaristo Gonzalez Sanchez + +* Saulius Zylys + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_chatt_filtering/__init__.py b/web_chatt_filtering/__init__.py new file mode 100644 index 000000000000..5311633e4734 --- /dev/null +++ b/web_chatt_filtering/__init__.py @@ -0,0 +1,2 @@ +# Copyright <2019> Pesol +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). diff --git a/web_chatt_filtering/__manifest__.py b/web_chatt_filtering/__manifest__.py new file mode 100644 index 000000000000..2bfb23effd42 --- /dev/null +++ b/web_chatt_filtering/__manifest__.py @@ -0,0 +1,28 @@ +# Copyright <2019> Pesol +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "mail_chatt_filtering", + "summary": """ + Extend the mail_chatt functionality to have filtering by author or by + message content + """, + "category": "web", + "author": "Pedro Gonzalez ," + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/web", + "version": "15.0.1.0.0", + "depends": ["mail"], + "data": [], + "assets": { + "mail.assets_discuss_public": [ + "web_chatt_filtering/static/src/models/chatter/chatter.esm.js" + ], + "web.assets_backend": [ + "web_chatt_filtering/static/src/models/chatter/chatter.esm.js" + ], + "web.assets_qweb": [ + "web_chatt_filtering/static/src/components/chatter/chatter.xml" + ], + }, +} diff --git a/web_chatt_filtering/readme/CONTRIBUTORS.rst b/web_chatt_filtering/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..3f3e4f571612 --- /dev/null +++ b/web_chatt_filtering/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Pesol `__: + + * Pedro Evaristo Gonzalez Sanchez + +* Saulius Zylys diff --git a/web_chatt_filtering/readme/DESCRIPTION.rst b/web_chatt_filtering/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..3bbefd064c02 --- /dev/null +++ b/web_chatt_filtering/readme/DESCRIPTION.rst @@ -0,0 +1,19 @@ +After working with Odoo a long time and load lot of loaded data, the amount of messages displayed inside the chatter of a record start to be significantly big + +This module introduces a filter in the Chatter +.. image:: ../static/img/initial_chatter_state.png + +Next functionalities are provided: +* Filter messages by content + +.. image:: ../static/img/filter_content.png + +* Filter messages by author + +.. image:: ../static/img/filter_author.png + +* Reverse filtering on author + +F.ex. <-admin> will show all the messages in the chatt excluding the ones of the Administrator + +.. image:: ../static/img/filter_excluding_author.png diff --git a/web_chatt_filtering/readme/USAGE.rst b/web_chatt_filtering/readme/USAGE.rst new file mode 100644 index 000000000000..b49aa41de0ee --- /dev/null +++ b/web_chatt_filtering/readme/USAGE.rst @@ -0,0 +1 @@ +Just installing the module is enough to have this functionality working. No configuration needed diff --git a/web_chatt_filtering/static/description/index.html b/web_chatt_filtering/static/description/index.html new file mode 100644 index 000000000000..f764aee73220 --- /dev/null +++ b/web_chatt_filtering/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +mail_chatt_filtering + + + +
+

mail_chatt_filtering

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

After working with Odoo a long time and load lot of loaded data, the amount of messages displayed inside the chatter of a record start to be significantly big

+

This module introduces a filter in the Chatter +.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/initial_chatter_state.png

+

Next functionalities are provided: +* Filter messages by content

+https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/filter_content.png +
    +
  • Filter messages by author
  • +
+https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/filter_author.png +
    +
  • Reverse filtering on author
  • +
+

F.ex. <-admin> will show all the messages in the chatt excluding the ones of the Administrator

+https://raw.githubusercontent.com/OCA/web/15.0/web_chatt_filtering/static/img/filter_excluding_author.png +

Table of contents

+ +
+

Usage

+

Just installing the module is enough to have this functionality working. No configuration needed

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+ +
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_chatt_filtering/static/img/filter_author.png b/web_chatt_filtering/static/img/filter_author.png new file mode 100644 index 000000000000..544cf5a75406 Binary files /dev/null and b/web_chatt_filtering/static/img/filter_author.png differ diff --git a/web_chatt_filtering/static/img/filter_content.png b/web_chatt_filtering/static/img/filter_content.png new file mode 100644 index 000000000000..04066edda9f3 Binary files /dev/null and b/web_chatt_filtering/static/img/filter_content.png differ diff --git a/web_chatt_filtering/static/img/filter_excluding_author.png b/web_chatt_filtering/static/img/filter_excluding_author.png new file mode 100644 index 000000000000..9791c8227dbd Binary files /dev/null and b/web_chatt_filtering/static/img/filter_excluding_author.png differ diff --git a/web_chatt_filtering/static/img/initial_chatter_state.png b/web_chatt_filtering/static/img/initial_chatter_state.png new file mode 100644 index 000000000000..e01461b205c8 Binary files /dev/null and b/web_chatt_filtering/static/img/initial_chatter_state.png differ diff --git a/web_chatt_filtering/static/src/components/chatter/chatter.xml b/web_chatt_filtering/static/src/components/chatter/chatter.xml new file mode 100644 index 000000000000..71a908189a4d --- /dev/null +++ b/web_chatt_filtering/static/src/components/chatter/chatter.xml @@ -0,0 +1,19 @@ + + + + +
+ + + +
+
+
+
diff --git a/web_chatt_filtering/static/src/models/chatter/chatter.esm.js b/web_chatt_filtering/static/src/models/chatter/chatter.esm.js new file mode 100644 index 000000000000..4eda66cdf4ea --- /dev/null +++ b/web_chatt_filtering/static/src/models/chatter/chatter.esm.js @@ -0,0 +1,69 @@ +/** @odoo-module **/ + +import {link, unlinkAll} from "@mail/model/model_field_command"; +import {registerInstancePatchModel} from "@mail/model/model_core"; + +registerInstancePatchModel( + "mail.chatter", + "web_chatt_filtering/static/src/models/chatter/chatter.esm.js", + { + /** + * @override + */ + _created() { + const _super = this._super(); + this.onKeydownSearchPartner = this.onKeydownSearchPartner.bind(this); + return _super; + }, + + // ---------------------------------------------------------------------- + // Public + // ---------------------------------------------------------------------- + + /** + * Handles keydown on 'Enter'. + * + * @param {KeyboardEvent} ev + */ + onKeydownSearchPartner(ev) { + if (ev.key === "Enter") { + var $partner_search = $("#search_partner").val().trim(); + this.thread.cache.update({ + messages: this.thread.cache._computeMessages(), + }); + if ($partner_search) { + this._setFIlteredMessages($partner_search); + } + } + }, + + // ---------------------------------------------------------------------- + // Private + // ---------------------------------------------------------------------- + + /** + * Loads this thread cache, by fetching the most recent messages in this + * conversation. + * + * @private + * @param {String} partner_search + */ + _setFIlteredMessages(partner_search) { + const messages = this.thread.cache.messages; + this.thread.cache.update({messages: unlinkAll()}); + let busqueda = partner_search; + var messages_filter = []; + if (busqueda.charAt(0) === "-") { + busqueda = busqueda.substring(1); + const expresion = new RegExp(`${busqueda}.*`, "i"); + messages_filter = messages.filter((m) => !expresion.test(m.authorName)); + } else { + const expresion = new RegExp(`${busqueda}.*`, "i"); + messages_filter = messages.filter( + (m) => expresion.test(m.authorName) || expresion.test(m.body) + ); + } + this.thread.cache.update({messages: link(messages_filter)}); + }, + } +);