0
1
Fork 0
hedera-web-mindshore/forms/ecomerce/orders/index.js

63 lines
1.2 KiB
JavaScript

import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml'),
activate() {
this.tpv = new Hedera.Tpv({
conn: this.conn,
hash: this.hash
});
this.tpv.check(this._onTpvCheck.bind(this));
},
_onTpvCheck(tpv, tpvOrder, tpvStatus) {
if (tpvStatus === 'ko')
this.$.errorDialog.show();
},
onBasketClick() {
this.hash.setAll({form: 'ecomerce/basket'});
},
repeaterFunc(res, form) {
res.$.link.href = this.hash.make({
form: 'ecomerce/ticket',
ticket: form.$.id
});
},
// TPV
balanceConditionalFunc(field, value) {
if (value >= 0)
Vn.Node.removeClass(this.$.balance, 'negative');
else
Vn.Node.addClass(this.$.balance, 'negative');
},
onPayButtonClick() {
var amount = -this.$.debt.value;
amount = amount <= 0 ? null : amount;
var defaultAmountStr = '';
if (amount !== null)
defaultAmountStr = Vn.Value.format(amount, '%.2d');
amount = prompt(_('AmountToPay:'), defaultAmountStr);
if (amount != null) {
amount = parseFloat(amount.replace(',', '.'));
this.tpv.pay(amount, null);
}
},
onDialogResponse(dialog, response) {
if (response == Htk.Dialog.Button.RETRY)
this.tpv.retryPay();
}
});