[REF] iap: convert iap buy credit buttons

closes odoo/odoo#97213

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Simon Genin (ges)
2022-08-22 16:48:15 +02:00
parent 6cdb99f887
commit e698f4286b
3 changed files with 53 additions and 2 deletions
+2 -2
View File
@@ -22,13 +22,13 @@ to support In-App purchases inside Odoo. """,
'auto_install': True,
'assets': {
'web.assets_backend': [
'iap/static/src/js/**/*',
'iap/static/src/**/*.js',
],
'web.tests_assets': [
'iap/static/tests/**/*',
],
'web.assets_qweb': [
'iap/static/src/xml/**/*',
'iap/static/src/**/*.xml',
],
},
'license': 'LGPL-3',
@@ -0,0 +1,38 @@
/** @odoo-modules */
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
const { Component } = owl;
class IAPActionButtonsWidget extends Component {
setup() {
this.orm = useService("orm");
this.action = useService("action");
}
async onViewServicesClicked() {
const url = await this.orm.silent.call("iap.account", "get_account_url");
this.action.doAction({
type: "ir.actions.act_url",
url: url,
});
}
async onBuyLinkClicked() {
const url = await this.orm.silent.call("iap.account", "get_credits_url", [this.props.serviceName]);
this.action.doAction({
type: "ir.actions.act_url",
url: url,
});
}
}
IAPActionButtonsWidget.template = "iap.ActionButtonsWidget";
IAPActionButtonsWidget.extractProps = ({ attrs }) => {
return {
serviceName: attrs.service_name,
showServiceButtons: !Boolean(attrs.hide_service),
};
};
registry.category("view_widgets").add("iap_buy_more_credits", IAPActionButtonsWidget);
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<template id="template" xml:space="preserve">
<t t-name="iap.ActionButtonsWidget" owl="1">
<div class="mt-2 row">
<div class="col-sm">
<button t-on-click="onBuyLinkClicked" class="btn btn-link buy_credits px-0 o-hidden-ios"><i class="fa fa-arrow-right"/> Buy credits</button><br/>
<button t-if="props.showServiceButtons" t-on-click="onViewServicesClicked" class="btn btn-link px-0 o-hidden-ios"><i class="fa fa-arrow-right me-1"/> View My Services</button>
</div>
</div>
</t>
</template>