diff --git a/addons/hr/static/src/components/employee_chat/employee_chat.js b/addons/hr/static/src/components/employee_chat/employee_chat.js new file mode 100644 index 0000000000000000000000000000000000000000..11dd02da89c995bb11593cda34cce1d19b37fd09 --- /dev/null +++ b/addons/hr/static/src/components/employee_chat/employee_chat.js @@ -0,0 +1,21 @@ +/** @odoo-module */ + +import { registry } from '@web/core/registry'; +import { standardWidgetProps } from "@web/views/widgets/standard_widget_props"; + +import { useOpenChat } from "@mail/views/open_chat_hook"; + +const { Component } = owl; + +export class HrEmployeeChat extends Component { + setup() { + super.setup(); + this.openChat = useOpenChat(this.props.record.resModel); + } +} +HrEmployeeChat.props = { + ...standardWidgetProps, +}; +HrEmployeeChat.template = 'hr.OpenChat'; + +registry.category("view_widgets").add("hr_employee_chat", HrEmployeeChat); diff --git a/addons/hr/static/src/components/employee_chat/employee_chat.xml b/addons/hr/static/src/components/employee_chat/employee_chat.xml new file mode 100644 index 0000000000000000000000000000000000000000..08de9af504e9cdebc0746236cd6cd48345d7b810 --- /dev/null +++ b/addons/hr/static/src/components/employee_chat/employee_chat.xml @@ -0,0 +1,27 @@ + +<?xml version="1.0" encoding="UTF-8"?> +<templates id="template" xml:space="preserve"> + <t t-name="hr.OpenChat" owl="1"> + <a t-if="props.record.data.user_id" + title="Chat" + icon="fa-comments" + t-on-click.prevent="() => openChat(props.record.resId)" + href="#" + class="ml8 o_employee_chat_btn" + role="button"> + <i class="fa fa-comments align-middle fs-6"/> + </a> + </t> + + <!-- TODO KBA: remove when Studio converted to owl --> + <t t-name="hr.OpenChatLegacy"> + <a + title="Chat" + icon="fa-comments" + href="#" + class="ml8 o_employee_chat_btn" + role="button"> + <i class="fa fa-comments align-middle fs-6"/> + </a> + </t> +</templates> diff --git a/addons/hr/static/src/components/employee_chat/employee_chat_legacy.js b/addons/hr/static/src/components/employee_chat/employee_chat_legacy.js new file mode 100644 index 0000000000000000000000000000000000000000..563143fffe59ce833ece8a145aadde6b20fad361 --- /dev/null +++ b/addons/hr/static/src/components/employee_chat/employee_chat_legacy.js @@ -0,0 +1,13 @@ +odoo.define('hr.OpenChatLegacy', function (require) { +"use strict"; + +const widgetRegistry = require('web.widget_registry'); +const Widget = require('web.Widget'); + +const HrEmployeeChatLegacy = Widget.extend({ + template: 'hr.OpenChatLegacy', +}); + +// TODO KBA remove when Studio converted to Owl +widgetRegistry.add('hr_employee_chat', HrEmployeeChatLegacy); +}); diff --git a/addons/hr/static/src/views/form_view.js b/addons/hr/static/src/views/form_view.js index aeecabcf94637a00a97c22ed9175440bcd19e52a..b9aa209af4b5cf3ccc2afd82b17614e1dd83124b 100644 --- a/addons/hr/static/src/views/form_view.js +++ b/addons/hr/static/src/views/form_view.js @@ -29,6 +29,7 @@ export class EmployeeFormController extends FormController { } } +// TODO KBA: to remove in master export class EmployeeFormRenderer extends FormRenderer { setup() { super.setup(); diff --git a/addons/hr/static/src/views/kanban_view.js b/addons/hr/static/src/views/kanban_view.js index 78ca6f3ef4c2e28dff536c4aed33e9e2704909f5..d2bab112de3a076a4f70fabefe7d793f3f385116 100644 --- a/addons/hr/static/src/views/kanban_view.js +++ b/addons/hr/static/src/views/kanban_view.js @@ -5,6 +5,7 @@ import { registry } from '@web/core/registry'; import { kanbanView } from '@web/views/kanban/kanban_view'; import { KanbanModel } from '@web/views/kanban/kanban_model'; +// TODO KBA: to remove in master export class EmployeeKanbanRecord extends KanbanModel.Record { async openChat(employeeId) { const messaging = await this.model.env.services.messaging.get(); diff --git a/addons/hr/views/hr_employee_public_views.xml b/addons/hr/views/hr_employee_public_views.xml index d735e552d9166e0ba822cbd0059d33eecea46e5d..4b4ef1885248d668ebc341e56e7de66988b389ed 100644 --- a/addons/hr/views/hr_employee_public_views.xml +++ b/addons/hr/views/hr_employee_public_views.xml @@ -50,7 +50,7 @@ <label for="name" string="Employee Name"/> <h1> <field name="name" placeholder="e.g. John Doe" required="True"/> - <a title="Chat" icon="fa-comments" t-on-click.prevent="() => openChat(props.record.resId)" href="#" class="ml8" invisible="not context.get('chat_icon')" attrs="{'invisible': [('user_id','=', False)]}" role="button"><i class="fa fa-comments"/></a> + <widget name="hr_employee_chat" invisible="not context.get('chat_icon')"/> </h1> <h2> <field name="job_title" placeholder="Job Title" /> @@ -182,7 +182,7 @@ <div class="o_kanban_record_bottom"> <div class="oe_kanban_bottom_left"/> <div class="oe_kanban_bottom_right"> - <a title="Chat" icon="fa-comments" href="#" t-on-click.prevent="() => props.record.openChat(props.record.resId)" class="ml8" attrs="{'invisible': [('user_id','=', False)]}" role="button"><i class="fa fa-comments"/></a> + <widget name="hr_employee_chat"/> </div> </div> </div> diff --git a/addons/hr/views/hr_employee_views.xml b/addons/hr/views/hr_employee_views.xml index d57178ea1810c4037500509e508af5959f368e9e..02632a5966293b8151b681bc3cf833ab9685c2e9 100644 --- a/addons/hr/views/hr_employee_views.xml +++ b/addons/hr/views/hr_employee_views.xml @@ -76,7 +76,7 @@ <!-- Employee is not here but according to his work schedule, he should be connected --> <small role="img" class="fa fa-fw fa-circle text-warning o_button_icon hr_presence align-middle" attrs="{'invisible': [('hr_icon_display', '!=', 'presence_to_define')]}" aria-label="To define" title="To define" name="presence_to_define"/> </div> - <a title="Chat" icon="fa-comments" t-on-click.prevent="() => openChat(props.record.resId)" href="#" class="ml8 o_employee_chat_btn" invisible="not context.get('chat_icon')" attrs="{'invisible': [('user_id','=', False)]}" role="button"><i class="fa fa-comments align-middle fs-6"/></a> + <widget name="hr_employee_chat" invisible="not context.get('chat_icon')"/> </div> </h1> <h2> @@ -365,7 +365,7 @@ <div class="o_kanban_record_bottom"> <div class="oe_kanban_bottom_left"/> <div class="oe_kanban_bottom_right float-end pe-auto"> - <a title="Chat" icon="fa-comments" href="#" t-on-click.prevent="() => props.record.openChat(props.record.resId)" class="ml8" attrs="{'invisible': [('user_id','=', False)]}" role="button"><i class="fa fa-comments"/></a> + <widget name="hr_employee_chat"/> <div class="hr_activity_container mb-1 me-n1"> <field name="activity_ids" widget="kanban_activity"/> </div>