JS linting

This commit is contained in:
Oliver 2021-10-06 16:52:56 +11:00
parent ac3a97d4d6
commit 21be5b4a26

View File

@ -1146,8 +1146,6 @@ function showAllocationSubTable(index, row, element, options) {
element.html(html); element.html(html);
var lineItem = row;
var table = $(`#allocation-table-${row.pk}`); var table = $(`#allocation-table-${row.pk}`);
// Is the parent SalesOrder pending? // Is the parent SalesOrder pending?
@ -1171,7 +1169,7 @@ function showAllocationSubTable(index, row, element, options) {
}); });
// Add callbacks for 'delete' buttons // Add callbacks for 'delete' buttons
table.find(".button-allocation-delete").click(function() { table.find('.button-allocation-delete').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
// TODO: Migrate to API forms // TODO: Migrate to API forms
@ -1265,10 +1263,8 @@ function showFulfilledSubTable(index, row, element, options) {
element.html(html); element.html(html);
var lineItem = row;
$(`#${id}`).bootstrapTable({ $(`#${id}`).bootstrapTable({
url: "{% url 'api-stock-list' %}", url: '{% url "api-stock-list" %}',
queryParams: { queryParams: {
part: row.part, part: row.part,
sales_order: options.order, sales_order: options.order,
@ -1292,9 +1288,11 @@ function showFulfilledSubTable(index, row, element, options) {
return renderLink(text, `/stock/item/${row.pk}/`); return renderLink(text, `/stock/item/${row.pk}/`);
}, },
}, },
/*
{ {
field: 'po' field: 'po'
}, },
*/
], ],
}); });
} }
@ -1313,12 +1311,12 @@ function loadSalesOrderLineItemTable(table, options={}) {
options.params = options.params || {}; options.params = options.params || {};
if (!options.order) { if (!options.order) {
console.log("ERROR: function called without order ID"); console.log('ERROR: function called without order ID');
return; return;
} }
if (!options.status) { if (!options.status) {
console.log("ERROR: function called without order status"); console.log('ERROR: function called without order status');
return; return;
} }
@ -1405,18 +1403,33 @@ function loadSalesOrderLineItemTable(table, options={}) {
title: '{% trans "Total price" %}', title: '{% trans "Total price" %}',
formatter: function(value, row) { formatter: function(value, row) {
var total = row.sale_price * row.quantity; var total = row.sale_price * row.quantity;
var formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: row.sale_price_currency}); var formatter = new Intl.NumberFormat(
return formatter.format(total) 'en-US',
{
style: 'currency',
currency: row.sale_price_currency
}
);
return formatter.format(total);
}, },
footerFormatter: function(data) { footerFormatter: function(data) {
var total = data.map(function (row) { var total = data.map(function (row) {
return +row['sale_price']*row['quantity'] return +row['sale_price'] * row['quantity'];
}).reduce(function (sum, i) { }).reduce(function (sum, i) {
return sum + i return sum + i;
}, 0) }, 0);
var currency = (data.slice(-1)[0] && data.slice(-1)[0].sale_price_currency) || 'USD'; var currency = (data.slice(-1)[0] && data.slice(-1)[0].sale_price_currency) || 'USD';
var formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: currency});
return formatter.format(total) var formatter = new Intl.NumberFormat(
'en-US',
{
style: 'currency',
currency: currency
}
);
return formatter.format(total);
} }
}, },
{ {
@ -1618,9 +1631,11 @@ function loadSalesOrderLineItemTable(table, options={}) {
$(table).find('.button-buy').click(function() { $(table).find('.button-buy').click(function() {
var pk = $(this).attr('pk'); var pk = $(this).attr('pk');
launchModalForm("{% url 'order-parts' %}", { launchModalForm('{% url "order-parts" %}', {
data: { data: {
parts: [pk], parts: [
pk
],
}, },
}); });
}); });
@ -1632,15 +1647,19 @@ function loadSalesOrderLineItemTable(table, options={}) {
var row = $(table).bootstrapTable('getData')[idx]; var row = $(table).bootstrapTable('getData')[idx];
launchModalForm( launchModalForm(
"{% url 'line-pricing' %}", '{% url "line-pricing" %}',
{ {
submit_text: '{% trans "Calculate price" %}', submit_text: '{% trans "Calculate price" %}',
data: { data: {
line_item: pk, line_item: pk,
quantity: row.quantity, quantity: row.quantity,
}, },
buttons: [{name: 'update_price', buttons: [
title: '{% trans "Update Unit Price" %}'},], {
name: 'update_price',
title: '{% trans "Update Unit Price" %}'
},
],
success: reloadTable, success: reloadTable,
} }
); );