[fix] pre-commit warnings
This commit is contained in:
parent
1e21f38099
commit
44f7380e22
1 changed files with 28 additions and 33 deletions
|
|
@ -1,40 +1,34 @@
|
||||||
odoo.define('nfu_sale_product_min_max_qty.website_min_max_qty', function (require) {
|
odoo.define("nfu_sale_product_min_max_qty.website_min_max_qty", function (require) {
|
||||||
'use strict';
|
"use strict";
|
||||||
var core = require('web.core');
|
var core = require("web.core");
|
||||||
var _t = core._t;
|
var _t = core._t;
|
||||||
var core = require('web.core');
|
var wSaleUtils = require("website_sale.utils");
|
||||||
var ajax = require('web.ajax');
|
var publicWidget = require("web.public.widget");
|
||||||
var wSaleUtils = require('website_sale.utils');
|
require("website_sale.website_sale");
|
||||||
var publicWidget = require('web.public.widget');
|
|
||||||
require('website_sale.website_sale');
|
|
||||||
console.log('here1');
|
|
||||||
publicWidget.registry.WebsiteSale.include({
|
publicWidget.registry.WebsiteSale.include({
|
||||||
|
|
||||||
onClickAddCartJSON: function (ev) {
|
onClickAddCartJSON: function (ev) {
|
||||||
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
$('.css_quantity').popover('dispose');
|
$(".css_quantity").popover("dispose");
|
||||||
var $link = $(ev.currentTarget);
|
var $link = $(ev.currentTarget);
|
||||||
var $input = $link.closest('.input-group').find("input");
|
var $input = $link.closest(".input-group").find("input");
|
||||||
var min = parseFloat($input.data("min") || 0);
|
var min = parseFloat($input.data("min") || 0);
|
||||||
var previousQty = parseFloat($input.val() || 0, 10);
|
var previousQty = parseFloat($input.val() || 0, 10);
|
||||||
var quantity = ($link.has(".fa-minus").length ? -1 : 1) + previousQty;
|
var quantity = ($link.has(".fa-minus").length ? -1 : 1) + previousQty;
|
||||||
if (quantity < min) {
|
if (quantity < min) {
|
||||||
$input.closest('.css_quantity').popover({
|
$input.closest(".css_quantity").popover({
|
||||||
content: _t(`Minimum Quantity is ${min}.`),
|
content: _t(`Minimum Quantity is ${min}.`),
|
||||||
title: _t("Warning"),
|
title: _t("Warning"),
|
||||||
placement: "left",
|
placement: "left",
|
||||||
trigger: 'focus',
|
trigger: "focus",
|
||||||
html: true,
|
html: true,
|
||||||
});
|
});
|
||||||
$input.closest('.css_quantity').popover('show');
|
$input.closest(".css_quantity").popover("show");
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('.css_quantity').popover('dispose')
|
$(".css_quantity").popover("dispose");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
this._super(ev);
|
this._super(ev);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,43 +37,44 @@ odoo.define('nfu_sale_product_min_max_qty.website_min_max_qty', function (requir
|
||||||
*/
|
*/
|
||||||
_changeCartQuantity: function ($input, value, $dom_optional, line_id, productIDs) {
|
_changeCartQuantity: function ($input, value, $dom_optional, line_id, productIDs) {
|
||||||
_.each($dom_optional, function (elem) {
|
_.each($dom_optional, function (elem) {
|
||||||
$(elem).find('.js_quantity').text(value);
|
$(elem).find(".js_quantity").text(value);
|
||||||
productIDs.push($(elem).find('span[data-product-id]').data('product-id'));
|
productIDs.push($(elem).find("span[data-product-id]").data("product-id"));
|
||||||
});
|
});
|
||||||
$input.data('update_change', true);
|
$input.data("update_change", true);
|
||||||
var max_qty = parseInt($input.closest('tr').find('input[name="max-qty"]').val(), 0);
|
var max_qty = parseInt($input.closest("tr").find('input[name="max-qty"]').val(), 10);
|
||||||
var set_qty = parseInt($input.closest('tr').find('input[name!="max-qty"]').val(), 0);
|
var set_qty = parseInt($input.closest("tr").find('input[name!="max-qty"]').val(), 10);
|
||||||
this._rpc({
|
this._rpc({
|
||||||
route: "/shop/cart/update_json",
|
route: "/shop/cart/update_json",
|
||||||
params: {
|
params: {
|
||||||
line_id: line_id,
|
line_id: line_id,
|
||||||
product_id: parseInt($input.data('product-id'), 10),
|
product_id: parseInt($input.data("product-id"), 10),
|
||||||
set_qty: set_qty,
|
set_qty: set_qty,
|
||||||
max_qty: max_qty,
|
max_qty: max_qty,
|
||||||
},
|
},
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
$input.data('update_change', false);
|
$input.data("update_change", false);
|
||||||
var check_value = parseInt($input.val() || 0, 10);
|
var check_value = parseInt($input.val() || 0, 10);
|
||||||
if (isNaN(check_value)) {
|
if (isNaN(check_value)) {
|
||||||
check_value = 1;
|
check_value = 1;
|
||||||
}
|
}
|
||||||
if (value !== check_value) {
|
if (value !== check_value) {
|
||||||
$input.trigger('change');
|
$input.trigger("change");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sessionStorage.setItem('website_sale_cart_quantity', data.cart_quantity);
|
sessionStorage.setItem("website_sale_cart_quantity", data.cart_quantity);
|
||||||
if (!data.cart_quantity) {
|
if (!data.cart_quantity) {
|
||||||
return window.location = '/shop/cart';
|
return (window.location = "/shop/cart");
|
||||||
}
|
}
|
||||||
$input.val(data.quantity);
|
$input.val(data.quantity);
|
||||||
$('.js_quantity[data-line-id='+line_id+']').val(data.quantity).text(data.quantity);
|
$(".js_quantity[data-line-id=" + line_id + "]")
|
||||||
|
.val(data.quantity)
|
||||||
|
.text(data.quantity);
|
||||||
|
|
||||||
wSaleUtils.updateCartNavBar(data);
|
wSaleUtils.updateCartNavBar(data);
|
||||||
wSaleUtils.showWarning(data.warning);
|
wSaleUtils.showWarning(data.warning);
|
||||||
// Propagating the change to the express checkout forms
|
// Propagating the change to the express checkout forms
|
||||||
core.bus.trigger('cart_amount_changed', data.amount, data.minor_amount);
|
core.bus.trigger("cart_amount_changed", data.amount, data.minor_amount);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue