[REF] sms: patch new owl PhoneField

This commit patches the new implementation of the PhoneField to
add the sms button.

Part-of: odoo/odoo#92475
This commit is contained in:
luvi
2022-06-30 09:29:44 +02:00
committed by Aaron Bohy
parent b0f20bcd09
commit 968148f59e
5 changed files with 62 additions and 0 deletions
+2
View File
@@ -44,10 +44,12 @@ The service is provided by the In App Purchase Odoo platform.
],
'mail.assets_discuss_public': [
'sms/static/src/components/*/*',
('remove', 'sms/static/src/components/phone_field/*'),
],
'web.assets_backend': [
'sms/static/src/js/fields_phone_widget.js',
'sms/static/src/js/fields_sms_widget.js',
'sms/static/src/components/*/*',
],
'web.qunit_suite_tests': [
'sms/static/tests/sms_widget_test.js',
@@ -0,0 +1,12 @@
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { PhoneField } from "@web/views/fields/phone/phone_field";
import { SendSMSButton } from '@sms/components/sms_button/sms_button';
patch(PhoneField, "sms.PhoneField", {
components: {
...PhoneField.components,
SendSMSButton
},
});
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-inherit="web.PhoneField" t-inherit-mode="extension">
<xpath expr="//*[hasclass('o_phone_link')]" position="after">
<t t-if="props.value.length > 0">
<SendSMSButton record="props.record" value="props.value"/>
</t>
</xpath>
</t>
</templates>
@@ -0,0 +1,23 @@
/** @odoo-module **/
import { useService } from "@web/core/utils/hooks";
const { Component } = owl;
export class SendSMSButton extends Component {
setup() {
this.action = useService("action");
this.title = this.env._t("Send SMS Text Message");
}
onClick() {
this.action.doAction({
type: "ir.actions.act_window",
name: this.title,
res_id: this.props.record.resId,
res_model: "sms.composer",
target: "new",
views: [[false, "form"]],
});
}
};
SendSMSButton.template = "sms.SendSMSButton";
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="sms.SendSMSButton" owl="1">
<a
t-att-title="title"
t-att-href="'sms:'+props.value"
t-on-click.prevent="onClick"
class="ml-3 d-inline-flex align-items-center o_field_phone_sms"
><i class="fa fa-mobile"></i><small class="font-weight-bold ml-1">SMS</small></a>
</t>
</templates>