`
+ html += `
`;
html += makeIconButton('fa-edit icon-blue', `button-${name}-edit`, row.pk, `{% trans "Edit ${human_name}" %}`);
html += makeIconButton('fa-trash-alt icon-red', `button-${name}-delete`, row.pk, `{% trans "Delete ${human_name}" %}`);
@@ -1330,8 +1374,8 @@ function initPriceBreakSet(table, options) {
}
);
- function reloadPriceBreakTable(){
- table.bootstrapTable("refresh");
+ function reloadPriceBreakTable() {
+ table.bootstrapTable('refresh');
}
pb_new_btn.click(function() {
@@ -1419,12 +1463,26 @@ function loadBomChart(context, data) {
options: {
responsive: true,
maintainAspectRatio: false,
- plugins: {legend: {position: 'bottom'},
- scales: {xAxes: [{beginAtZero: true, ticks: {autoSkip: false}}]}}
+ plugins: {
+ legend: {
+ position: 'bottom',
+ },
+ scales: {
+ xAxes: [
+ {
+ beginAtZero: true,
+ ticks: {
+ autoSkip: false,
+ }
+ }
+ ]
+ }
+ }
}
});
}
+
function loadSellPricingChart(context, data) {
return new Chart(context, {
type: 'line',
@@ -1432,21 +1490,29 @@ function loadSellPricingChart(context, data) {
options: {
responsive: true,
maintainAspectRatio: false,
- plugins: {legend: {position: 'bottom'}},
+ plugins: {
+ legend: {
+ position: 'bottom'
+ }
+ },
scales: {
y: {
type: 'linear',
position: 'left',
- grid: {display: false},
+ grid: {
+ display: false
+ },
title: {
display: true,
- text: '{% trans "Unit Price" %}'
+ text: '{% trans "Unit Price" %}',
}
},
y1: {
type: 'linear',
position: 'right',
- grid: {display: false},
+ grid: {
+ display: false
+ },
titel: {
display: true,
text: '{% trans "Quantity" %}',
diff --git a/InvenTree/templates/js/translated/report.js b/InvenTree/templates/js/translated/report.js
index 370978be04..4f887f2275 100644
--- a/InvenTree/templates/js/translated/report.js
+++ b/InvenTree/templates/js/translated/report.js
@@ -1,5 +1,25 @@
{% load i18n %}
+/* globals
+ attachSelect,
+ closeModal,
+ inventreeGet,
+ openModal,
+ makeOptionsList,
+ modalEnable,
+ modalSetContent,
+ modalSetTitle,
+ modalSubmit,
+ showAlertDialog,
+*/
+
+/* exported
+ printBomReports,
+ printBuildReports,
+ printPurchaseOrderReports,
+ printSalesOrderReports,
+ printTestReports,
+*/
function selectReport(reports, items, options={}) {
/**
@@ -88,7 +108,7 @@ function selectReport(reports, items, options={}) {
}
-function printTestReports(items, options={}) {
+function printTestReports(items) {
/**
* Print test reports for the provided stock item(s)
*/
@@ -142,7 +162,7 @@ function printTestReports(items, options={}) {
}
-function printBuildReports(builds, options={}) {
+function printBuildReports(builds) {
/**
* Print Build report for the provided build(s)
*/
@@ -188,14 +208,14 @@ function printBuildReports(builds, options={}) {
window.location.href = href;
}
}
- )
+ );
}
}
- )
+ );
}
-function printBomReports(parts, options={}) {
+function printBomReports(parts) {
/**
* Print BOM reports for the provided part(s)
*/
@@ -245,11 +265,11 @@ function printBomReports(parts, options={}) {
);
}
}
- )
+ );
}
-function printPurchaseOrderReports(orders, options={}) {
+function printPurchaseOrderReports(orders) {
/**
* Print PO reports for the provided purchase order(s)
*/
@@ -296,14 +316,14 @@ function printPurchaseOrderReports(orders, options={}) {
window.location.href = href;
}
}
- )
+ );
}
}
- )
+ );
}
-function printSalesOrderReports(orders, options={}) {
+function printSalesOrderReports(orders) {
/**
* Print SO reports for the provided purchase order(s)
*/
@@ -350,8 +370,8 @@ function printSalesOrderReports(orders, options={}) {
window.location.href = href;
}
}
- )
+ );
}
}
- )
+ );
}
diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js
index 99c3824cac..e35831624e 100644
--- a/InvenTree/templates/js/translated/stock.js
+++ b/InvenTree/templates/js/translated/stock.js
@@ -2,6 +2,63 @@
{% load inventree_extras %}
{% load status_codes %}
+/* globals
+ attachSelect,
+ attachToggle,
+ blankImage,
+ enableField,
+ clearField,
+ clearFieldOptions,
+ closeModal,
+ constructFormBody,
+ constructNumberInput,
+ createNewModal,
+ getFormFieldValue,
+ global_settings,
+ handleFormErrors,
+ imageHoverIcon,
+ inventreeDelete,
+ inventreeGet,
+ inventreePut,
+ launchModalForm,
+ linkButtonsToSelection,
+ loadTableFilters,
+ makeIconBadge,
+ makeIconButton,
+ makeOptionsList,
+ makePartIcons,
+ modalEnable,
+ modalSetContent,
+ modalSetTitle,
+ modalSubmit,
+ moment,
+ openModal,
+ printStockItemLabels,
+ printTestReports,
+ renderLink,
+ reloadFieldOptions,
+ scanItemsIntoLocation,
+ showAlertDialog,
+ setFieldValue,
+ setupFilterList,
+ showApiError,
+ stockStatusDisplay,
+*/
+
+/* exported
+ createNewStockItem,
+ exportStock,
+ loadInstalledInTable,
+ loadStockLocationTable,
+ loadStockTable,
+ loadStockTestResultsTable,
+ loadStockTrackingTable,
+ loadTableFilters,
+ locationFields,
+ removeStockRow,
+ stockStatusCodes,
+*/
+
function locationFields() {
return {
@@ -23,7 +80,7 @@ function stockStatusCodes() {
{% for code in StockStatus.list %}
{
key: {{ code.key }},
- text: "{{ code.value }}",
+ text: '{{ code.value }}',
},
{% endfor %}
];
@@ -45,11 +102,23 @@ function exportStock(params={}) {
type: 'choice',
value: 'csv',
choices: [
- { value: 'csv', display_name: 'CSV' },
- { value: 'tsv', display_name: 'TSV' },
- { value: 'xls', display_name: 'XLS' },
- { value: 'xlsx', display_name: 'XLSX' },
- ]
+ {
+ value: 'csv',
+ display_name: 'CSV',
+ },
+ {
+ value: 'tsv',
+ display_name: 'TSV',
+ },
+ {
+ value: 'xls',
+ display_name: 'XLS',
+ },
+ {
+ value: 'xlsx',
+ display_name: 'XLSX',
+ },
+ ],
},
sublocations: {
label: '{% trans "Include Sublocations" %}',
@@ -94,34 +163,34 @@ function adjustStock(action, items, options={}) {
var allowSerializedStock = false;
switch (action) {
- case 'move':
- formTitle = '{% trans "Transfer Stock" %}';
- actionTitle = '{% trans "Move" %}';
- specifyLocation = true;
- allowSerializedStock = true;
- url = '{% url "api-stock-transfer" %}';
- break;
- case 'count':
- formTitle = '{% trans "Count Stock" %}';
- actionTitle = '{% trans "Count" %}';
- url = '{% url "api-stock-count" %}';
- break;
- case 'take':
- formTitle = '{% trans "Remove Stock" %}';
- actionTitle = '{% trans "Take" %}';
- url = '{% url "api-stock-remove" %}';
- break;
- case 'add':
- formTitle = '{% trans "Add Stock" %}';
- actionTitle = '{% trans "Add" %}';
- url = '{% url "api-stock-add" %}';
- break;
- case 'delete':
- formTitle = '{% trans "Delete Stock" %}';
- allowSerializedStock = true;
- break;
- default:
- break;
+ case 'move':
+ formTitle = '{% trans "Transfer Stock" %}';
+ actionTitle = '{% trans "Move" %}';
+ specifyLocation = true;
+ allowSerializedStock = true;
+ url = '{% url "api-stock-transfer" %}';
+ break;
+ case 'count':
+ formTitle = '{% trans "Count Stock" %}';
+ actionTitle = '{% trans "Count" %}';
+ url = '{% url "api-stock-count" %}';
+ break;
+ case 'take':
+ formTitle = '{% trans "Remove Stock" %}';
+ actionTitle = '{% trans "Take" %}';
+ url = '{% url "api-stock-remove" %}';
+ break;
+ case 'add':
+ formTitle = '{% trans "Add Stock" %}';
+ actionTitle = '{% trans "Add" %}';
+ url = '{% url "api-stock-add" %}';
+ break;
+ case 'delete':
+ formTitle = '{% trans "Delete Stock" %}';
+ allowSerializedStock = true;
+ break;
+ default:
+ break;
}
// Generate modal HTML content
@@ -157,25 +226,25 @@ function adjustStock(action, items, options={}) {
var value = null;
switch (action) {
- case 'move':
- minValue = 0;
- maxValue = item.quantity;
- value = item.quantity;
- break;
- case 'add':
- minValue = 0;
- value = 0;
- break;
- case 'take':
- minValue = 0;
- value = 0;
- break;
- case 'count':
- minValue = 0;
- value = item.quantity;
- break;
- default:
- break;
+ case 'move':
+ minValue = 0;
+ maxValue = item.quantity;
+ value = item.quantity;
+ break;
+ case 'add':
+ minValue = 0;
+ value = 0;
+ break;
+ case 'take':
+ minValue = 0;
+ value = 0;
+ break;
+ case 'count':
+ minValue = 0;
+ value = item.quantity;
+ break;
+ default:
+ break;
}
var image = item.part_detail.thumbnail || item.part_detail.image || blankImage();
@@ -208,8 +277,8 @@ function adjustStock(action, items, options={}) {
read_only: readonly,
title: readonly ? '{% trans "Quantity cannot be adjusted for serialized stock" %}' : '{% trans "Specify stock quantity" %}',
}
- )
- };
+ );
+ }
var buttons = `
`;
@@ -283,7 +352,7 @@ function adjustStock(action, items, options={}) {
confirm: true,
confirmMessage: '{% trans "Confirm stock adjustment" %}',
modal: modal,
- onSubmit: function(fields, opts) {
+ onSubmit: function(fields) {
// "Delete" action gets handled differently
if (action == 'delete') {
@@ -295,7 +364,7 @@ function adjustStock(action, items, options={}) {
inventreeDelete(
`/api/stock/${item.pk}/`,
)
- )
+ );
});
// Wait for *all* the requests to complete
@@ -327,7 +396,7 @@ function adjustStock(action, items, options={}) {
});
// Add in extra field data
- for (field_name in extraFields) {
+ for (var field_name in extraFields) {
data[field_name] = getFormFieldValue(
field_name,
fields[field_name],
@@ -342,7 +411,7 @@ function adjustStock(action, items, options={}) {
data,
{
method: 'POST',
- success: function(response, status) {
+ success: function() {
// Destroy the modal window
$(modal).modal('hide');
@@ -353,22 +422,22 @@ function adjustStock(action, items, options={}) {
},
error: function(xhr) {
switch (xhr.status) {
- case 400:
+ case 400:
- // Handle errors for standard fields
- handleFormErrors(
- xhr.responseJSON,
- extraFields,
- {
- modal: modal,
- }
- )
+ // Handle errors for standard fields
+ handleFormErrors(
+ xhr.responseJSON,
+ extraFields,
+ {
+ modal: modal,
+ }
+ );
- break;
- default:
- $(modal).modal('hide');
- showApiError(xhr);
- break;
+ break;
+ default:
+ $(modal).modal('hide');
+ showApiError(xhr);
+ break;
}
}
}
@@ -446,15 +515,15 @@ function loadStockTestResultsTable(table, options) {
html += makeIconButton('fa-trash-alt icon-red', 'button-test-delete', pk, '{% trans "Delete test result" %}');
}
- html += "
";
+ html += '
';
return html;
}
- var parent_node = "parent node";
+ var parent_node = 'parent node';
table.inventreeTable({
- url: "{% url 'api-part-test-template-list' %}",
+ url: '{% url "api-part-test-template-list" %}',
method: 'get',
name: 'testresult',
treeEnable: true,
@@ -473,7 +542,7 @@ function loadStockTestResultsTable(table, options) {
table.treegrid({
treeColumn: 0,
});
- table.treegrid("collapseAll");
+ table.treegrid('collapseAll');
},
columns: [
{
@@ -539,12 +608,12 @@ function loadStockTestResultsTable(table, options) {
stock_item: options.stock_item,
user_detail: true,
attachment_detail: true,
- ordering: "-date",
+ ordering: '-date',
},
{
success: function(data) {
// Iterate through the returned test data
- data.forEach(function(item, index) {
+ data.forEach(function(item) {
var match = false;
var override = false;
@@ -589,13 +658,12 @@ function loadStockTestResultsTable(table, options) {
});
// Push data back into the table
- table.bootstrapTable("load", tableData);
+ table.bootstrapTable('load', tableData);
}
}
- )
+ );
}
});
-
}
@@ -671,11 +739,11 @@ function loadStockTable(table, options) {
var params = options.params || {};
- var filterListElement = options.filterList || "#filter-list-stock";
+ var filterListElement = options.filterList || '#filter-list-stock';
var filters = {};
- var filterKey = options.filterKey || options.name || "stock";
+ var filterKey = options.filterKey || options.name || 'stock';
if (!options.disableFilters) {
filters = loadTableFilters(filterKey);
@@ -683,8 +751,8 @@ function loadStockTable(table, options) {
var original = {};
- for (var key in params) {
- original[key] = params[key];
+ for (var k in params) {
+ original[k] = params[k];
}
setupFilterList(filterKey, table, filterListElement);
@@ -700,10 +768,13 @@ function loadStockTable(table, options) {
grouping = options.grouping;
}
+ var col = null;
+
// Explicitly disable part grouping functionality
// Might be able to add this in later on,
// but there is a bug which makes this crash if paginating on the server side.
// Ref: https://github.com/wenzhixin/bootstrap-table/issues/3250
+ // eslint-disable-next-line no-unused-vars
grouping = false;
var columns = [
@@ -727,22 +798,24 @@ function loadStockTable(table, options) {
sortName: 'part__name',
visible: params['part_detail'],
switchable: params['part_detail'],
- formatter: function(value, row, index, field) {
+ formatter: function(value, row) {
var url = `/stock/item/${row.pk}/`;
var thumb = row.part_detail.thumbnail;
var name = row.part_detail.full_name;
- html = imageHoverIcon(thumb) + renderLink(name, url);
+ var html = imageHoverIcon(thumb) + renderLink(name, url);
html += makePartIcons(row.part_detail);
return html;
}
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
@@ -751,13 +824,15 @@ function loadStockTable(table, options) {
sortName: 'part__IPN',
visible: params['part_detail'],
switchable: params['part_detail'],
- formatter: function(value, row, index, field) {
+ formatter: function(value, row) {
return row.part_detail.IPN;
},
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
columns.push({
@@ -765,7 +840,7 @@ function loadStockTable(table, options) {
title: '{% trans "Description" %}',
visible: params['part_detail'],
switchable: params['part_detail'],
- formatter: function(value, row, index, field) {
+ formatter: function(value, row) {
return row.part_detail.description;
}
});
@@ -773,7 +848,7 @@ function loadStockTable(table, options) {
col = {
field: 'quantity',
title: '{% trans "Stock" %}',
- formatter: function(value, row, index, field) {
+ formatter: function(value, row) {
var val = parseFloat(value);
@@ -817,13 +892,9 @@ function loadStockTable(table, options) {
// REJECTED
if (row.status == {{ StockStatus.REJECTED }}) {
html += makeIconBadge('fa-times-circle icon-red', '{% trans "Stock item has been rejected" %}');
- }
-
- // LOST
- else if (row.status == {{ StockStatus.LOST }}) {
- html += makeIconBadge('fa-question-circle','{% trans "Stock item is lost" %}');
- }
- else if (row.status == {{ StockStatus.DESTROYED }}) {
+ } else if (row.status == {{ StockStatus.LOST }}) {
+ html += makeIconBadge('fa-question-circle', '{% trans "Stock item is lost" %}');
+ } else if (row.status == {{ StockStatus.DESTROYED }}) {
html += makeIconBadge('fa-skull-crossbones', '{% trans "Stock item is destroyed" %}');
}
@@ -834,51 +905,61 @@ function loadStockTable(table, options) {
return html;
}
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
field: 'status',
title: '{% trans "Status" %}',
- formatter: function(value, row, index, field) {
+ formatter: function(value) {
return stockStatusDisplay(value);
},
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
field: 'batch',
title: '{% trans "Batch" %}',
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
field: 'location_detail.pathstring',
title: '{% trans "Location" %}',
- formatter: function(value, row, index, field) {
+ formatter: function(value, row) {
return locationDetail(row);
}
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
field: 'stocktake_date',
title: '{% trans "Stocktake" %}',
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
@@ -887,18 +968,22 @@ function loadStockTable(table, options) {
visible: global_settings.STOCK_ENABLE_EXPIRY,
switchable: global_settings.STOCK_ENABLE_EXPIRY,
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
col = {
field: 'updated',
title: '{% trans "Last Updated" %}',
};
+
if (!options.params.ordering) {
col['sortable'] = true;
- };
+ }
+
columns.push(col);
columns.push({
@@ -963,7 +1048,7 @@ function loadStockTable(table, options) {
if (!options.params.ordering) {
col.sortable = true;
col.sortName = 'purchase_price';
- };
+ }
columns.push(col);
@@ -981,7 +1066,7 @@ function loadStockTable(table, options) {
formatNoMatches: function() {
return '{% trans "No stock items matching query" %}';
},
- url: options.url || "{% url 'api-stock-list' %}",
+ url: options.url || '{% url "api-stock-list" %}',
queryParams: filters,
sidePagination: 'server',
name: 'stock',
@@ -1048,7 +1133,7 @@ function loadStockTable(table, options) {
stock = +stock.toFixed(5);
- return stock + " (" + items + " items)";
+ return `${stock} (${items} {% trans "items" %})`;
} else if (field == 'status') {
var statii = [];
@@ -1170,7 +1255,7 @@ function loadStockTable(table, options) {
function stockAdjustment(action) {
- var items = $(table).bootstrapTable("getSelections");
+ var items = $(table).bootstrapTable('getSelections');
adjustStock(action, items, {
onSuccess: function() {
@@ -1203,7 +1288,7 @@ function loadStockTable(table, options) {
});
printTestReports(items);
- })
+ });
if (global_settings.BARCODE_ENABLE) {
$('#multi-item-barcode-scan-into-location').click(function() {
@@ -1213,7 +1298,7 @@ function loadStockTable(table, options) {
selections.forEach(function(item) {
items.push(item.pk);
- })
+ });
scanItemsIntoLocation(items);
});
@@ -1231,12 +1316,12 @@ function loadStockTable(table, options) {
stockAdjustment('add');
});
- $("#multi-item-move").click(function() {
+ $('#multi-item-move').click(function() {
stockAdjustment('move');
});
- $("#multi-item-order").click(function() {
- var selections = $(table).bootstrapTable("getSelections");
+ $('#multi-item-order').click(function() {
+ var selections = $(table).bootstrapTable('getSelections');
var stock = [];
@@ -1244,14 +1329,14 @@ function loadStockTable(table, options) {
stock.push(item.pk);
});
- launchModalForm("/order/purchase-order/order-parts/", {
+ launchModalForm('/order/purchase-order/order-parts/', {
data: {
stock: stock,
},
});
});
- $("#multi-item-set-status").click(function() {
+ $('#multi-item-set-status').click(function() {
// Select and set the STATUS field for selected stock items
var selections = $(table).bootstrapTable('getSelections');
@@ -1263,7 +1348,7 @@ function loadStockTable(table, options) {
function(item) {
return item.text;
},
- function (item) {
+ function(item) {
return item.key;
}
);
@@ -1335,11 +1420,11 @@ function loadStockTable(table, options) {
$.when.apply($, requests).done(function() {
$(table).bootstrapTable('refresh');
});
- })
+ });
});
- $("#multi-item-delete").click(function() {
- var selections = $(table).bootstrapTable("getSelections");
+ $('#multi-item-delete').click(function() {
+ var selections = $(table).bootstrapTable('getSelections');
var stock = [];
@@ -1368,8 +1453,8 @@ function loadStockLocationTable(table, options) {
var original = {};
- for (var key in params) {
- original[key] = params[key];
+ for (var k in params) {
+ original[k] = params[k];
}
setupFilterList(filterKey, table, filterListElement);
@@ -1437,7 +1522,7 @@ function loadStockTrackingTable(table, options) {
field: 'date',
title: '{% trans "Date" %}',
sortable: true,
- formatter: function(value, row, index, field) {
+ formatter: function(value) {
var m = moment(value);
if (m.isValid()) {
@@ -1453,11 +1538,11 @@ function loadStockTrackingTable(table, options) {
cols.push({
field: 'label',
title: '{% trans "Description" %}',
- formatter: function(value, row, index, field) {
- var html = "
" + value + "";
+ formatter: function(value, row) {
+ var html = '
' + value + '';
if (row.notes) {
- html += "
" + row.notes + "";
+ html += '
' + row.notes + '';
}
return html;
@@ -1468,7 +1553,7 @@ function loadStockTrackingTable(table, options) {
cols.push({
field: 'deltas',
title: '{% trans "Details" %}',
- formatter: function(details, row, index, field) {
+ formatter: function(details, row) {
var html = `
`;
if (!details) {
@@ -1603,14 +1688,11 @@ function loadStockTrackingTable(table, options) {
cols.push({
field: 'user',
title: '{% trans "User" %}',
- formatter: function(value, row, index, field) {
- if (value)
- {
+ formatter: function(value, row) {
+ if (value) {
// TODO - Format the user's first and last names
return row.user_detail.username;
- }
- else
- {
+ } else {
return `{% trans "No user information" %}`;
}
}
@@ -1692,7 +1774,7 @@ function createNewStockItem(options) {
reloadFieldOptions(
'supplier_part',
{
- url: "{% url 'api-supplier-part-list' %}",
+ url: '{% url "api-supplier-part-list" %}',
params: {
part: value,
pretty: true,
@@ -1723,7 +1805,7 @@ function createNewStockItem(options) {
} else {
var expiry = moment().add(response.default_expiry, 'days');
- setFieldValue('expiry_date', expiry.format("YYYY-MM-DD"));
+ setFieldValue('expiry_date', expiry.format('YYYY-MM-DD'));
}
}
}
@@ -1732,7 +1814,7 @@ function createNewStockItem(options) {
},
];
- launchModalForm("{% url 'stock-item-create' %}", options);
+ launchModalForm('{% url "stock-item-create" %}', options);
}
@@ -1741,28 +1823,8 @@ function loadInstalledInTable(table, options) {
* Display a table showing the stock items which are installed in this stock item.
*/
- function updateCallbacks() {
- // Setup callback functions when buttons are pressed
- table.find('.button-install').click(function() {
- var pk = $(this).attr('pk');
-
- launchModalForm(
- `/stock/item/${options.stock_item}/install/`,
- {
- data: {
- part: pk,
- },
- success: function() {
- // Refresh entire table!
- table.bootstrapTable('refresh');
- }
- }
- );
- });
- }
-
table.inventreeTable({
- url: "{% url 'api-stock-list' %}",
+ url: '{% url "api-stock-list" %}',
queryParams: {
installed_in: options.stock_item,
part_detail: true,
@@ -1802,7 +1864,7 @@ function loadInstalledInTable(table, options) {
{
field: 'status',
title: '{% trans "Status" %}',
- formatter: function(value, row) {
+ formatter: function(value) {
return stockStatusDisplay(value);
}
},
@@ -1841,8 +1903,8 @@ function loadInstalledInTable(table, options) {
table.bootstrapTable('refresh');
}
}
- )
+ );
});
}
});
-}
\ No newline at end of file
+}
diff --git a/InvenTree/templates/js/translated/table_filters.js b/InvenTree/templates/js/translated/table_filters.js
index 9e173a7b37..b94bc324c7 100644
--- a/InvenTree/templates/js/translated/table_filters.js
+++ b/InvenTree/templates/js/translated/table_filters.js
@@ -8,13 +8,26 @@
{% include "status_codes.html" with label='purchaseOrder' options=PurchaseOrderStatus.list %}
{% include "status_codes.html" with label='salesOrder' options=SalesOrderStatus.list %}
+/* globals
+ global_settings
+*/
+
+/* exported
+ buildStatusDisplay,
+ getAvailableTableFilters,
+ purchaseOrderStatusDisplay,
+ salesOrderStatusDisplay,
+ stockHistoryStatusDisplay,
+ stockStatusDisplay,
+*/
+
function getAvailableTableFilters(tableKey) {
tableKey = tableKey.toLowerCase();
// Filters for "variant" table
- if (tableKey == "variants") {
+ if (tableKey == 'variants') {
return {
active: {
type: 'bool',
@@ -36,11 +49,11 @@ function getAvailableTableFilters(tableKey) {
}
// Filters for Bill of Materials table
- if (tableKey == "bom") {
+ if (tableKey == 'bom') {
return {
sub_part_trackable: {
type: 'bool',
- title: '{% trans "Trackable Part" %}'
+ title: '{% trans "Trackable Part" %}',
},
sub_part_assembly: {
type: 'bool',
@@ -57,7 +70,7 @@ function getAvailableTableFilters(tableKey) {
allow_variants: {
type: 'bool',
title: '{% trans "Allow Variant Stock" %}',
- }
+ },
};
}
@@ -72,29 +85,29 @@ function getAvailableTableFilters(tableKey) {
}
// Filters for "stock location" table
- if (tableKey == "location") {
+ if (tableKey == 'location') {
return {
cascade: {
type: 'bool',
title: '{% trans "Include sublocations" %}',
description: '{% trans "Include locations" %}',
- }
+ },
};
}
// Filters for "part category" table
- if (tableKey == "category") {
+ if (tableKey == 'category') {
return {
cascade: {
type: 'bool',
title: '{% trans "Include subcategories" %}',
description: '{% trans "Include subcategories" %}',
- }
+ },
};
}
// Filters for the "customer stock" table (really a subset of "stock")
- if (tableKey == "customerstock") {
+ if (tableKey == 'customerstock') {
return {
serialized: {
type: 'bool',
@@ -102,7 +115,7 @@ function getAvailableTableFilters(tableKey) {
},
serial_gte: {
title: '{% trans "Serial number GTE" %}',
- description: '{% trans "Serial number greater than or equal to" %}'
+ description: '{% trans "Serial number greater than or equal to" %}',
},
serial_lte: {
title: '{% trans "Serial number LTE" %}',
@@ -110,7 +123,7 @@ function getAvailableTableFilters(tableKey) {
},
serial: {
title: '{% trans "Serial number" %}',
- description: '{% trans "Serial number" %}'
+ description: '{% trans "Serial number" %}',
},
batch: {
title: '{% trans "Batch" %}',
@@ -179,11 +192,11 @@ function getAvailableTableFilters(tableKey) {
},
serial: {
title: '{% trans "Serial number" %}',
- description: '{% trans "Serial number" %}'
+ description: '{% trans "Serial number" %}',
},
serial_gte: {
title: '{% trans "Serial number GTE" %}',
- description: '{% trans "Serial number greater than or equal to" %}'
+ description: '{% trans "Serial number greater than or equal to" %}',
},
serial_lte: {
title: '{% trans "Serial number LTE" %}',
@@ -239,7 +252,7 @@ function getAvailableTableFilters(tableKey) {
required: {
type: 'bool',
title: '{% trans "Required" %}',
- }
+ },
};
}
@@ -262,7 +275,7 @@ function getAvailableTableFilters(tableKey) {
}
// Filters for the "Order" table
- if (tableKey == "purchaseorder") {
+ if (tableKey == 'purchaseorder') {
return {
status: {
@@ -280,7 +293,7 @@ function getAvailableTableFilters(tableKey) {
};
}
- if (tableKey == "salesorder") {
+ if (tableKey == 'salesorder') {
return {
status: {
title: '{% trans "Order status" %}',
@@ -302,12 +315,12 @@ function getAvailableTableFilters(tableKey) {
active: {
type: 'bool',
title: '{% trans "Active parts" %}',
- }
+ },
};
}
// Filters for the "Parts" table
- if (tableKey == "parts") {
+ if (tableKey == 'parts') {
return {
cascade: {
type: 'bool',
@@ -330,7 +343,7 @@ function getAvailableTableFilters(tableKey) {
},
has_stock: {
type: 'bool',
- title: '{% trans "Stock available" %}'
+ title: '{% trans "Stock available" %}',
},
low_stock: {
type: 'bool',
diff --git a/InvenTree/templates/js/translated/tables.js b/InvenTree/templates/js/translated/tables.js
index 88d9a5f99a..6e719563ae 100644
--- a/InvenTree/templates/js/translated/tables.js
+++ b/InvenTree/templates/js/translated/tables.js
@@ -1,21 +1,33 @@
{% load i18n %}
+/* global
+ inventreeLoad,
+ inventreeSave,
+*/
+/* exported
+ customGroupSorter,
+ reloadtable,
+ renderLink,
+ reloadTableFilters,
+*/
+
+/**
+ * Reload a named table
+ * @param table
+ */
function reloadtable(table) {
$(table).bootstrapTable('refresh');
}
-function editButton(url, text='Edit') {
- return "";
-}
-
-
-function deleteButton(url, text='Delete') {
- return "";
-}
-
-
+/**
+ * Render a URL for display
+ * @param {String} text
+ * @param {String} url
+ * @param {object} options
+ * @returns link text
+ */
function renderLink(text, url, options={}) {
if (url === null || url === undefined || url === '') {
return text;
@@ -23,8 +35,6 @@ function renderLink(text, url, options={}) {
var max_length = options.max_length || -1;
- var remove_http = options.remove_http || false;
-
// Shorten the displayed length if required
if ((max_length > 0) && (text.length > max_length)) {
var slice_length = (max_length - 3) / 2;
@@ -59,12 +69,17 @@ function linkButtonsToSelection(table, buttons) {
enableButtons(buttons, table.bootstrapTable('getSelections').length > 0);
// Add a callback
- table.on('check.bs.table uncheck.bs.table check-some.bs.table uncheck-some.bs.table check-all.bs.table uncheck-all.bs.table', function(row) {
+ table.on('check.bs.table uncheck.bs.table check-some.bs.table uncheck-some.bs.table check-all.bs.table uncheck-all.bs.table', function() {
enableButtons(buttons, table.bootstrapTable('getSelections').length > 0);
});
}
+/**
+ * Returns true if the input looks like a valid number
+ * @param {String} n
+ * @returns
+ */
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
@@ -88,8 +103,8 @@ function reloadTableFilters(table, filters) {
// Construct a new list of filters to use for the query
var params = {};
- for (var key in filters) {
- params[key] = filters[key];
+ for (var k in filters) {
+ params[k] = filters[k];
}
// Original query params will override
@@ -136,7 +151,6 @@ function convertQueryParameters(params, filters) {
var ordering = params['sort'] || null;
if (ordering) {
-
if (order == 'desc') {
ordering = `-${ordering}`;
}
@@ -220,7 +234,7 @@ $.fn.inventreeTable = function(options) {
};
// Callback when a column is changed
- options.onColumnSwitch = function(field, checked) {
+ options.onColumnSwitch = function() {
var columns = table.bootstrapTable('getVisibleColumns');
@@ -239,7 +253,7 @@ $.fn.inventreeTable = function(options) {
// If a set of visible columns has been saved, load!
if (visibleColumns) {
- var columns = visibleColumns.split(",");
+ var columns = visibleColumns.split(',');
// Which columns are currently visible?
var visible = table.bootstrapTable('getVisibleColumns');
@@ -253,7 +267,7 @@ $.fn.inventreeTable = function(options) {
}
});
} else {
- console.log('Could not get list of visible columns!');
+ console.log(`Could not get list of visible columns for column '${tableName}'`);
}
}
@@ -261,7 +275,8 @@ $.fn.inventreeTable = function(options) {
if (options.buttons) {
linkButtonsToSelection(table, options.buttons);
}
-}
+};
+
function customGroupSorter(sortName, sortOrder, sortData) {
@@ -334,42 +349,42 @@ function customGroupSorter(sortName, sortOrder, sortData) {
}
// Expose default bootstrap table string literals to translation layer
-(function ($) {
+(function($) {
'use strict';
$.fn.bootstrapTable.locales['en-US-custom'] = {
- formatLoadingMessage: function () {
+ formatLoadingMessage: function() {
return '{% trans "Loading data" %}';
},
- formatRecordsPerPage: function (pageNumber) {
+ formatRecordsPerPage: function(pageNumber) {
return `${pageNumber} {% trans "rows per page" %}`;
},
- formatShowingRows: function (pageFrom, pageTo, totalRows) {
+ formatShowingRows: function(pageFrom, pageTo, totalRows) {
return `{% trans "Showing" %} ${pageFrom} {% trans "to" %} ${pageTo} {% trans "of" %} ${totalRows} {% trans "rows" %}`;
},
- formatSearch: function () {
+ formatSearch: function() {
return '{% trans "Search" %}';
},
- formatNoMatches: function () {
+ formatNoMatches: function() {
return '{% trans "No matching results" %}';
},
- formatPaginationSwitch: function () {
+ formatPaginationSwitch: function() {
return '{% trans "Hide/Show pagination" %}';
},
- formatRefresh: function () {
+ formatRefresh: function() {
return '{% trans "Refresh" %}';
},
- formatToggle: function () {
+ formatToggle: function() {
return '{% trans "Toggle" %}';
},
- formatColumns: function () {
+ formatColumns: function() {
return '{% trans "Columns" %}';
},
- formatAllRows: function () {
+ formatAllRows: function() {
return '{% trans "All" %}';
- }
+ },
};
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['en-US-custom']);
-})(jQuery);
\ No newline at end of file
+})(jQuery);
diff --git a/InvenTree/templates/status_codes.html b/InvenTree/templates/status_codes.html
index e7bc2e951c..453a7914e2 100644
--- a/InvenTree/templates/status_codes.html
+++ b/InvenTree/templates/status_codes.html
@@ -1,12 +1,13 @@
/*
* Status codes for the {{ label }} model.
*/
-var {{ label }}Codes = {
+const {{ label }}Codes = {
{% for opt in options %}'{{ opt.key }}': {
key: '{{ opt.key }}',
value: '{{ opt.value }}',{% if opt.color %}
label: 'label-{{ opt.color }}',{% endif %}
- },{% endfor %}
+ },
+ {% endfor %}
};
/*
diff --git a/tasks.py b/tasks.py
index 3de0241c07..1abbf23bc6 100644
--- a/tasks.py
+++ b/tasks.py
@@ -457,3 +457,12 @@ def server(c, address="127.0.0.1:8000"):
"""
manage(c, "runserver {address}".format(address=address), pty=True)
+
+
+@task
+def render_js_files(c):
+ """
+ Render templated javascript files (used for static testing).
+ """
+
+ manage(c, "test InvenTree.ci_render_js")