Skip to content
Snippets Groups Projects
Commit e698f428 authored by Simon Genin (ges)'s avatar Simon Genin (ges)
Browse files

[REF] iap: convert iap buy credit buttons


closes odoo/odoo#97213

Signed-off-by: default avatarAaron Bohy (aab) <aab@odoo.com>
parent 6cdb99f8
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
/** @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);
<?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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment