91 lines
1.7 KiB
JavaScript
Executable File
91 lines
1.7 KiB
JavaScript
Executable File
|
|
Vn.Basket = new Class
|
|
({
|
|
Extends: Vn.Module
|
|
|
|
,open: function ()
|
|
{
|
|
if (this.basketChecked)
|
|
this.parent ();
|
|
}
|
|
|
|
,activate: function ()
|
|
{
|
|
Vn.BasketChecker.check (this.conn,
|
|
this.onBasketCheck.bind (this));
|
|
}
|
|
|
|
,onBasketCheck: function (isOk)
|
|
{
|
|
if (!isOk)
|
|
return;
|
|
|
|
this.basketChecked = true;
|
|
this.open ();
|
|
}
|
|
|
|
,onConfigureClick: function ()
|
|
{
|
|
Htk.Toast.showWarning (_('RememberReconfiguringImpact'));
|
|
this.hash.set ({'form': 'ecomerce/checkout'});
|
|
}
|
|
|
|
,onCheckoutClick: function ()
|
|
{
|
|
this.hash.set ({'form': 'ecomerce/confirm'});
|
|
}
|
|
|
|
,amountRender: function (renderer, form)
|
|
{
|
|
var amount = form.get ('amount');
|
|
var grouping = form.get ('grouping');
|
|
|
|
if (amount && grouping)
|
|
renderer.value = amount / grouping;
|
|
else
|
|
renderer.value = null;
|
|
}
|
|
|
|
,onAmountChange: function (renderer, row, newValue)
|
|
{
|
|
var model = this.$('items');
|
|
model.set (row, 'amount', newValue * model.get (row, 'grouping'));
|
|
}
|
|
|
|
,featuresRender: function (renderer, form)
|
|
{
|
|
renderer.value = form.get ('Medida') +' '+ form.get ('Categoria') +' '+ form.get ('Color');
|
|
}
|
|
|
|
,stemsRender: function (renderer, form)
|
|
{
|
|
renderer.value = Vn.Value.format (form.get ('price'), '%.2d€') +' x '+ form.get ('amount');
|
|
|
|
if (form.get ('amount') > form.get ('available'))
|
|
renderer.td.className = 'available-exceeded';
|
|
else
|
|
renderer.td.className = '';
|
|
}
|
|
|
|
,subtotalRender: function (renderer, form)
|
|
{
|
|
renderer.value = this.subtotal (form);
|
|
}
|
|
|
|
,subtotal: function (form)
|
|
{
|
|
return form.get ('amount') * form.get ('price');
|
|
}
|
|
|
|
,availableRender: function (renderer, form)
|
|
{
|
|
if (form.get ('amount') > form.get ('avail'))
|
|
renderer.value = 'unavailable';
|
|
else
|
|
renderer.value = 'invisible';
|
|
}
|
|
});
|
|
|
|
|
|
|