Browse Source

[REF] pretty js

pull/84/head
robin.keunen 5 years ago
parent
commit
cead37f6fd
  1. 58
      easy_my_coop/static/src/js/easy_my_coop.js
  2. 1521
      easy_my_coop/static/src/js/jquery.inputmask.bundle.js
  3. 26
      easy_my_coop_loan_website/static/src/js/loan_issue.js

58
easy_my_coop/static/src/js/easy_my_coop.js

@ -4,14 +4,14 @@ odoo.define('easy_my_coop.oe_easymy_coop', function (require) {
var ajax = require('web.ajax'); var ajax = require('web.ajax');
$('.oe_easymy_coop').each(function () { $('.oe_easymy_coop').each(function () {
var oe_easymy_coop = this;
var oe_easymy_coop = this;
$('#share_product_id').change(function () {
var share_product_id = $("#share_product_id").val();
ajax.jsonRpc("/subscription/get_share_product", 'call', {
$('#share_product_id').change(function () {
var share_product_id = $("#share_product_id").val();
ajax.jsonRpc("/subscription/get_share_product", 'call', {
'share_product_id': share_product_id, 'share_product_id': share_product_id,
})
.then(function (data) {
})
.then(function (data) {
$('#share_price').text(data[share_product_id].list_price); $('#share_price').text(data[share_product_id].list_price);
$('input.js_quantity').val(data[share_product_id].min_qty); $('input.js_quantity').val(data[share_product_id].min_qty);
if (data[share_product_id].force_min_qty == true) { if (data[share_product_id].force_min_qty == true) {
@ -19,34 +19,34 @@ odoo.define('easy_my_coop.oe_easymy_coop', function (require) {
} }
$('input.js_quantity').change(); $('input.js_quantity').change();
var $share_price = $('#share_price').text(); var $share_price = $('#share_price').text();
$('input[name="total_parts"]').val($('input.js_quantity').val()*$share_price);
$('input[name="total_parts"]').val($('input.js_quantity').val() * $share_price);
$('input[name="total_parts"]').change(); $('input[name="total_parts"]').change();
});
});
});
});
$(oe_easymy_coop).on('click', 'a.js_add_cart_json', function (ev) {
var $share_price = $('#share_price').text();
var $link = $(ev.currentTarget);
var $input = $link.parent().parent().find("input");
var $input_total = $("div").find(".total");
var min = parseFloat($input.data("min") || 1);
var amount_max = parseFloat($('input[name="total_parts"]').data("max"));
var quantity = ($link.has(".fa-minus").length ? -1 : 1) + parseFloat($input.val(), 10);
var total_part = quantity * $share_price;
var quantity_max = amount_max / $share_price;
$input.val(quantity > min ? total_part <= amount_max ? quantity : quantity_max : min);
$input.change();
$('input[name="total_parts"]').val($input.val()*$share_price);
return false;
});
$(oe_easymy_coop).on('click', 'a.js_add_cart_json', function (ev) {
var $share_price = $('#share_price').text();
var $link = $(ev.currentTarget);
var $input = $link.parent().parent().find("input");
var $input_total = $("div").find(".total");
var min = parseFloat($input.data("min") || 1);
var amount_max = parseFloat($('input[name="total_parts"]').data("max"));
var quantity = ($link.has(".fa-minus").length ? -1 : 1) + parseFloat($input.val(), 10);
var total_part = quantity * $share_price;
var quantity_max = amount_max / $share_price;
$input.val(quantity > min ? total_part <= amount_max ? quantity : quantity_max : min);
$input.change();
$('input[name="total_parts"]').val($input.val() * $share_price);
return false;
});
$(oe_easymy_coop).on('focusout', 'input.js_quantity', function (ev) {
$('a.js_add_cart_json').trigger('click');
});
$(oe_easymy_coop).on('focusout', 'input.js_quantity', function (ev) {
$('a.js_add_cart_json').trigger('click');
});
$('#share_product_id').trigger('change');
$('#share_product_id').trigger('change');
$("[name='birthdate']").inputmask();
$("[name='birthdate']").inputmask();
}); });
}); });
}); });

1521
easy_my_coop/static/src/js/jquery.inputmask.bundle.js
File diff suppressed because it is too large
View File

26
easy_my_coop_loan_website/static/src/js/loan_issue.js

@ -4,20 +4,20 @@ odoo.define('easy_my_coop_loan_website.oe_easymy_coop_loan', function (require)
var ajax = require('web.ajax'); var ajax = require('web.ajax');
$('.oe_easymy_coop_loan').each(function () { $('.oe_easymy_coop_loan').each(function () {
var oe_easymy_coop_loan = this;
$('#loan_issue').change(function () {
var loan_issue_id = $("#loan_issue").val();
ajax.jsonRpc("/subscription/get_loan_issue", 'call', {
var oe_easymy_coop_loan = this;
$('#loan_issue').change(function () {
var loan_issue_id = $("#loan_issue").val();
ajax.jsonRpc("/subscription/get_loan_issue", 'call', {
'loan_issue_id': loan_issue_id, 'loan_issue_id': loan_issue_id,
})
.then(function (data) {
if (data !== false) {
$("#subscription_amount").prop('max', data[loan_issue_id].maximum_amount_per_sub);
$("#subscription_amount").prop('step', data[loan_issue_id].face_value);
}
});
});
$('#loan_issue').trigger('change');
})
.then(function (data) {
if (data !== false) {
$("#subscription_amount").prop('max', data[loan_issue_id].maximum_amount_per_sub);
$("#subscription_amount").prop('step', data[loan_issue_id].face_value);
}
});
});
$('#loan_issue').trigger('change');
}); });
}); });
}); });
Loading…
Cancel
Save