You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
4.1 KiB
118 lines
4.1 KiB
odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) {
|
|
'use strict';
|
|
|
|
require('web.dom_ready');
|
|
var ajax = require('web.ajax');
|
|
var core = require('web.core');
|
|
var _t = core._t;
|
|
var concurrency = require('web.concurrency');
|
|
var dp = new concurrency.DropPrevious();
|
|
|
|
$('#carousel_1').on('slide.bs.carousel', function (e) {
|
|
var $e = $(e.relatedTarget);
|
|
var idx = $e.index();
|
|
var itemsPerSlide = 5;
|
|
var totalItems = $('.carousel-item').length;
|
|
|
|
if (idx >= totalItems-(itemsPerSlide-1)) {
|
|
var it = itemsPerSlide - (totalItems - idx);
|
|
for (var i=0; i<it; i++) {
|
|
// append slides to end
|
|
if (e.direction=="left") {
|
|
$('.carousel-item').eq(i).appendTo('.carousel-inner');
|
|
}
|
|
else {
|
|
$('.carousel-item').eq(0).appendTo('.carousel-inner');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
var $pay_button = $('#o_payment_form_pay');
|
|
|
|
var _onRetraitUpdateAnswer = function(result) {
|
|
var $retrait_badge = $('#point_retrait input[name="point_retrait_type"][value=' + result.vracoop_point_retrait_id + ']');
|
|
|
|
if (result.status === true) {
|
|
$pay_button.data('disabled_reasons').carrier_selection = false;
|
|
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
|
|
}
|
|
else {
|
|
console.error(result.error_message);
|
|
}
|
|
};
|
|
|
|
var _onRetraitClick = function(ev) {
|
|
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
|
|
$pay_button.prop('disabled', true);
|
|
var vracoop_point_retrait_id = $(ev.currentTarget).val();
|
|
console.log(vracoop_point_retrait_id);
|
|
var values = {'vracoop_point_retrait_id': vracoop_point_retrait_id};
|
|
dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values))
|
|
.then(_onRetraitUpdateAnswer);
|
|
};
|
|
|
|
var $retraits = $("#point_retrait input[name='point_retrait_type']");
|
|
$retraits.click(_onRetraitClick);
|
|
console.log($retraits);
|
|
|
|
if ($retraits.length > 0) {
|
|
$retraits.filter(':checked').click();
|
|
}
|
|
|
|
var _onDayUpdateAnswer = function(result) {
|
|
|
|
if (result.status === true) {
|
|
$pay_button.data('disabled_reasons').carrier_selection = false;
|
|
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
|
|
}
|
|
else {
|
|
console.error(result.error_message);
|
|
}
|
|
};
|
|
|
|
var _onDayClick = function(ev) {
|
|
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
|
|
$pay_button.prop('disabled', true);
|
|
var day_retrait = $(ev.currentTarget).val();
|
|
console.log(day_retrait);
|
|
var values = {'day_retrait': day_retrait};
|
|
dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values))
|
|
.then(_onDayUpdateAnswer);
|
|
};
|
|
|
|
var $days = $("#point_retrait input[name='day_select']");
|
|
$days.click(_onDayClick);
|
|
|
|
if ($days.length > 0) {
|
|
$days.filter(':checked').click();
|
|
}
|
|
|
|
var _onHourUpdateAnswer = function(result) {
|
|
|
|
if (result.status === true) {
|
|
$pay_button.data('disabled_reasons').carrier_selection = false;
|
|
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
|
|
}
|
|
else {
|
|
console.error(result.error_message);
|
|
}
|
|
};
|
|
|
|
var _onHourClick = function(ev) {
|
|
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
|
|
$pay_button.prop('disabled', true);
|
|
var hour_retrait = $(ev.currentTarget).val();
|
|
var values = {'hour_retrait': hour_retrait};
|
|
dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values))
|
|
.then(_onHourUpdateAnswer);
|
|
};
|
|
|
|
var $hours = $("#point_retrait input[name='hour_select']");
|
|
$hours.click(_onHourClick);
|
|
|
|
if ($hours.length > 0) {
|
|
$hours.filter(':checked').click();
|
|
}
|
|
|
|
});
|