mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 12:35:46 +00:00
Fix JS linting workflow (#4915)
* Add bad .js code - Call function which has not been defined - Should throw JS lint error * update eslint - Move to newer version of eslint - Change default rules * Fixes for tables.js * Fixes for table_filters.js * Fixes for stock.js * Fix for sales_order.js and search.js * Fix return_order.js * Fixes for purchase_order.js * More updates - part.js - plugin.js - pricing.js * Updates - order.js * Even morerer updates - label.js - modals.js - model_renderers.js - news.js - notification.js * More, MORE! - build.js - company.js - charts.js - filters.js - forms.js - helpers.js * Final? - api.js - attachment.js - barcode.js - bom.js * Fix 'useless-escape' * Disable no-useless-escape rule
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
showMessage,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
|
@ -1,7 +1,17 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
constructForm,
|
||||
getTableData,
|
||||
enableDragAndDrop,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIcon,
|
||||
reloadBootstrapTable,
|
||||
renderDate,
|
||||
renderLink,
|
||||
setupFilterList,
|
||||
showApiError,
|
||||
wrapButtons,
|
||||
*/
|
||||
|
||||
|
@ -1,15 +1,26 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
createNewModal,
|
||||
global_settings,
|
||||
handleFormError,
|
||||
handleFormSuccess,
|
||||
Html5Qrcode,
|
||||
Html5QrcodeScannerState,
|
||||
imageHoverIcon,
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
makeIcon,
|
||||
makeRemoveButton,
|
||||
modalEnable,
|
||||
modalSetContent,
|
||||
modalSetTitle,
|
||||
modalSetSubmitText,
|
||||
modalShowSubmitButton,
|
||||
modalSubmit,
|
||||
showApiError,
|
||||
showQuestionDialog,
|
||||
user_settings,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -57,8 +68,10 @@ function makeBarcodeInput(placeholderText='', hintText='') {
|
||||
return html;
|
||||
}
|
||||
|
||||
qrScanner = null;
|
||||
qrScannerCallback = null;
|
||||
// Global variables for qrScanner
|
||||
var qrScanner = null;
|
||||
var qrScannerCallback = null;
|
||||
|
||||
|
||||
function startQrScanner() {
|
||||
$('#barcode_scan_video_container').show();
|
||||
|
@ -1,16 +1,46 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
addFieldErrorMessage,
|
||||
constructField,
|
||||
constructForm,
|
||||
constructFormBody,
|
||||
createNewModal,
|
||||
enableSubmitButton,
|
||||
exportFormatOptions,
|
||||
formatDecimal,
|
||||
formatPriceRange,
|
||||
getApiEndpointOptions,
|
||||
getFormFieldValue,
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
initializeRelatedField,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
inventreeSave,
|
||||
launchModalForm,
|
||||
loadTableFilters,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIcon,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makeInfoButton,
|
||||
makePartIcons,
|
||||
makeRemoveButton,
|
||||
modalSetContent,
|
||||
partFields,
|
||||
partGroups,
|
||||
renderLink,
|
||||
setupFilterList,
|
||||
shortenString,
|
||||
showApiError,
|
||||
thumbnailImage,
|
||||
updateFieldValue,
|
||||
withTitle,
|
||||
wrapButtons,
|
||||
yesNoLabel,
|
||||
*/
|
||||
|
||||
@ -226,7 +256,7 @@ function submitBomTable(part_id, options={}) {
|
||||
items: rows,
|
||||
};
|
||||
|
||||
var options = {
|
||||
var opts = {
|
||||
nested: {
|
||||
items: idx_values,
|
||||
}
|
||||
@ -247,7 +277,7 @@ function submitBomTable(part_id, options={}) {
|
||||
error: function(xhr) {
|
||||
switch (xhr.status) {
|
||||
case 400:
|
||||
handleFormErrors(xhr.responseJSON, fields, options);
|
||||
handleFormErrors(xhr.responseJSON, fields, opts);
|
||||
break;
|
||||
default:
|
||||
showApiError(xhr, url);
|
||||
@ -1092,7 +1122,7 @@ function loadBomTable(table, options={}) {
|
||||
|
||||
if (any_pricing) {
|
||||
|
||||
var html = formatPriceRange(min_price, max_price);
|
||||
let html = formatPriceRange(min_price, max_price);
|
||||
|
||||
if (complete_pricing) {
|
||||
html += makeIconBadge(
|
||||
@ -1109,7 +1139,7 @@ function loadBomTable(table, options={}) {
|
||||
return html;
|
||||
|
||||
} else {
|
||||
var html = '<em>{% trans "No pricing available" %}</em>';
|
||||
let html = '<em>{% trans "No pricing available" %}</em>';
|
||||
html += makeIconBadge('fa-times-circle icon-red');
|
||||
|
||||
return html;
|
||||
|
@ -2,19 +2,49 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
addClearCallback,
|
||||
buildStatusDisplay,
|
||||
clearEvents,
|
||||
constructExpandCollapseButtons,
|
||||
constructField,
|
||||
constructForm,
|
||||
constructOrderTableButtons,
|
||||
endDate,
|
||||
formatDecimal,
|
||||
FullCalendar,
|
||||
getFormFieldValue,
|
||||
getTableData,0
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
initializeRelatedField,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
launchModalForm,
|
||||
linkButtonsToSelection,
|
||||
loadTableFilters,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeRemoveButton,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makePartIcons,
|
||||
makeProgressBar,
|
||||
orderParts,
|
||||
renderDate,
|
||||
renderLink,
|
||||
setupFilterList,
|
||||
shortenString,
|
||||
showAlertDialog,
|
||||
showApiError,
|
||||
startDate,
|
||||
stockStatusDisplay,
|
||||
showApiErrors,
|
||||
thumbnailImage,
|
||||
updateFieldValue,
|
||||
wrapButtons,
|
||||
yesNoLabel,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -675,9 +705,9 @@ function scrapBuildOutputs(build_id, outputs, options={}) {
|
||||
<div class='alert alert-block alert-danger'>
|
||||
{% trans "Selected build outputs will be marked as scrapped" %}
|
||||
<ul>
|
||||
<li>{% trans "Scrapped output are given the 'rejected' status" %}</li>
|
||||
<li>{% trans "Allocated stock items will no longer be available" %}</li>
|
||||
<li>{% trans "The completion status of the build order will not be adjusted" %}</li>
|
||||
<li>{% trans "Scrapped output are marked as rejected" %}</li>
|
||||
<li>{% trans "Allocated stock items will no longer be available" %}</li>
|
||||
<li>{% trans "The completion status of the build order will not be adjusted" %}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<table class='table table-striped table-condensed' id='build-scrap-table'>
|
||||
@ -2687,6 +2717,8 @@ function loadBuildTable(table, options) {
|
||||
|
||||
var filters = loadTableFilters('build', params);
|
||||
|
||||
var calendar = null;
|
||||
|
||||
var filterTarget = options.filterTarget || null;
|
||||
|
||||
setupFilterList('build', table, filterTarget, {
|
||||
@ -2944,7 +2976,7 @@ function loadBuildTable(table, options) {
|
||||
if (!loaded_calendar) {
|
||||
loaded_calendar = true;
|
||||
|
||||
var el = document.getElementById('build-order-calendar');
|
||||
let el = document.getElementById('build-order-calendar');
|
||||
|
||||
calendar = new FullCalendar.Calendar(el, {
|
||||
initialView: 'dayGridMonth',
|
||||
|
@ -2,6 +2,7 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
Chart,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
|
@ -1,11 +1,26 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
constructLabel,
|
||||
constructForm,
|
||||
formatCurrency,
|
||||
formatDecimal,
|
||||
formatDate,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
loadTableFilters,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIconBadge,
|
||||
renderClipboard,
|
||||
renderDate,
|
||||
renderLink,
|
||||
renderPart,
|
||||
setupFilterList,
|
||||
thumbnailImage,
|
||||
wrapButtons,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -369,7 +384,6 @@ function createSupplierPartPriceBreak(part_id, options={}) {
|
||||
constructForm('{% url "api-part-supplier-price-list" %}', {
|
||||
fields: fields,
|
||||
method: 'POST',
|
||||
fields: fields,
|
||||
title: '{% trans "Add Price Break" %}',
|
||||
onSuccess: function(response) {
|
||||
handleFormSuccess(response, options);
|
||||
@ -634,6 +648,7 @@ function deleteContacts(contacts, options={}) {
|
||||
ids.push(contact.pk);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
let html = `
|
||||
<div class='alert alert-block alert-danger'>
|
||||
{% trans "All selected contacts will be deleted" %}
|
||||
|
@ -1,9 +1,14 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
downloadTableData,
|
||||
getAvailableTableFilters,
|
||||
getTableData,
|
||||
global_settings,
|
||||
inventreeLoad,
|
||||
inventreeSave,
|
||||
printLabels,
|
||||
printReports,
|
||||
reloadTableFilters,
|
||||
*/
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
/* globals
|
||||
createNewModal,
|
||||
enableSubmitButton,
|
||||
formatDecimal,
|
||||
inventreeFormDataUpload,
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
@ -10,8 +12,12 @@
|
||||
modalEnable,
|
||||
modalShowSubmitButton,
|
||||
getModelRenderer,
|
||||
reloadBootstrapTable,
|
||||
sanitizeInputString,
|
||||
showAlertOrCache,
|
||||
showApiError,
|
||||
showMessage,
|
||||
showModalSpinner,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -617,10 +623,12 @@ function constructFormBody(fields, options) {
|
||||
|
||||
if (options.preFormContent) {
|
||||
|
||||
let content = '';
|
||||
|
||||
if (typeof(options.preFormContent) === 'function') {
|
||||
var content = options.preFormContent(options);
|
||||
content = options.preFormContent(options);
|
||||
} else {
|
||||
var content = options.preFormContent;
|
||||
content = options.preFormContent;
|
||||
}
|
||||
|
||||
$(modal).find('#pre-form-content').html(content);
|
||||
@ -1270,7 +1278,7 @@ function handleNestedArrayErrors(errors, field_name, options={}) {
|
||||
|
||||
// Nest list must be provided!
|
||||
if (!nest_list) {
|
||||
console.warn(`handleNestedArrayErrors missing nesting options for field '${fieldName}'`);
|
||||
console.warn(`handleNestedArrayErrors missing nesting options for field '${field_name}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1287,9 +1295,9 @@ function handleNestedArrayErrors(errors, field_name, options={}) {
|
||||
var nest_id = nest_list[idx];
|
||||
|
||||
// Here, error_item is a map of field names to error messages
|
||||
for (sub_field_name in error_item) {
|
||||
for (var sub_field_name in error_item) {
|
||||
|
||||
var errors = error_item[sub_field_name];
|
||||
var sub_errors = error_item[sub_field_name];
|
||||
|
||||
if (sub_field_name == 'non_field_errors') {
|
||||
|
||||
@ -1301,11 +1309,11 @@ function handleNestedArrayErrors(errors, field_name, options={}) {
|
||||
row = $(`#items_${nest_id}`);
|
||||
}
|
||||
|
||||
for (var ii = errors.length - 1; ii >= 0; ii--) {
|
||||
for (var ii = sub_errors.length - 1; ii >= 0; ii--) {
|
||||
|
||||
var html = `
|
||||
<div id='error_${ii}_non_field_error' class='help-block form-field-error form-error-message'>
|
||||
<strong>${errors[ii]}</strong>
|
||||
<strong>${sub_errors[ii]}</strong>
|
||||
</div>`;
|
||||
|
||||
row.after(html);
|
||||
@ -1443,7 +1451,7 @@ function addFieldErrorMessage(name, error_text, error_idx=0, options={}) {
|
||||
return;
|
||||
}
|
||||
|
||||
field_name = getFieldName(name, options);
|
||||
let field_name = getFieldName(name, options);
|
||||
|
||||
var field_dom = null;
|
||||
|
||||
@ -2336,6 +2344,7 @@ function constructInput(name, parameters, options={}) {
|
||||
break;
|
||||
case 'raw':
|
||||
func = constructRawInput;
|
||||
break;
|
||||
default:
|
||||
// Unsupported field type!
|
||||
break;
|
||||
|
@ -1,5 +1,14 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
EasyMDE,
|
||||
inventreeFormDataUpload,
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
showApiError,
|
||||
user_settings,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
blankImage,
|
||||
deleteButton,
|
||||
@ -336,8 +345,6 @@ function makeProgressBar(value, maximum, opts={}) {
|
||||
|
||||
var id = options.id || 'progress-bar';
|
||||
|
||||
var style = '';
|
||||
|
||||
if (opts.max_width) {
|
||||
style += `max-width: ${options.max_width}; `;
|
||||
}
|
||||
@ -514,6 +521,7 @@ function sanitizeInputString(s, options={}) {
|
||||
}
|
||||
|
||||
// Remove ASCII control characters
|
||||
// eslint-disable-next-line no-control-regex
|
||||
s = s.replace(/[\x00-\x1F\x7F]+/g, '');
|
||||
|
||||
// Remove Unicode control characters
|
||||
|
@ -8,10 +8,13 @@
|
||||
modalEnable,
|
||||
modalSetContent,
|
||||
modalSetTitle,
|
||||
modalShowSubmitButton,
|
||||
modalSubmit,
|
||||
openModal,
|
||||
plugins_enabled,
|
||||
showAlertDialog,
|
||||
showMessage,
|
||||
user_settings,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -96,10 +99,10 @@ function selectLabel(labels, items, options={}) {
|
||||
var html = '';
|
||||
|
||||
if (items.length > 0) {
|
||||
name = items.length == 1 ? options.singular_name : options.plural_name;
|
||||
let item_name = items.length == 1 ? options.singular_name : options.plural_name;
|
||||
html += `
|
||||
<div class='alert alert-block alert-info'>
|
||||
${items.length} ${name} {% trans "selected" %}
|
||||
${items.length} ${item_name} {% trans "selected" %}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
/* globals
|
||||
inventreeGet,
|
||||
QRCode,
|
||||
showAlertOrCache,
|
||||
user_settings,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -856,7 +858,7 @@ function insertActionButton(modal, options) {
|
||||
// check if button already present
|
||||
var already_present = false;
|
||||
for (var child=element[0].firstElementChild; child; child=child.nextElementSibling) {
|
||||
if (item.firstElementChild.name == options.name) {
|
||||
if (child.firstElementChild.name == options.name) {
|
||||
already_present = true;
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
/* globals
|
||||
blankImage,
|
||||
partStockLabel,
|
||||
renderLink,
|
||||
select2Thumbnail
|
||||
shortenString
|
||||
shortenString,
|
||||
user_settings
|
||||
*/
|
||||
|
||||
/* exported
|
||||
|
@ -1,6 +1,15 @@
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
|
||||
/* globals
|
||||
getReadEditButton,
|
||||
inventreePut,
|
||||
renderDate,
|
||||
setupFilterList,
|
||||
*/
|
||||
|
||||
|
||||
/* exported
|
||||
loadNewsFeedTable,
|
||||
*/
|
||||
|
@ -1,5 +1,14 @@
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
/* globals
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
renderLink,
|
||||
setupFilterList,
|
||||
*/
|
||||
|
||||
|
||||
/* exported
|
||||
loadNotificationTable,
|
||||
startNotificationWatcher,
|
||||
@ -69,10 +78,10 @@ function loadNotificationTable(table, options={}, enableDelete=false) {
|
||||
formatter: function(value, row, index, field) {
|
||||
var bRead = getReadEditButton(row.pk, row.read);
|
||||
|
||||
let bDel = '';
|
||||
|
||||
if (enableDelete) {
|
||||
var bDel = `<button title='{% trans "Delete Notification" %}' class='notification-delete btn btn-outline-secondary' type='button' pk='${row.pk}'><span class='fas fa-trash-alt icon-red'></span></button>`;
|
||||
} else {
|
||||
var bDel = '';
|
||||
bDel = `<button title='{% trans "Delete Notification" %}' class='notification-delete btn btn-outline-secondary' type='button' pk='${row.pk}'><span class='fas fa-trash-alt icon-red'></span></button>`;
|
||||
}
|
||||
|
||||
var html = `<div class='btn-group float-right' role='group'>${bRead}${bDel}</div>`;
|
||||
@ -90,12 +99,13 @@ function loadNotificationTable(table, options={}, enableDelete=false) {
|
||||
|
||||
|
||||
var notificationWatcher = null; // reference for the notificationWatcher
|
||||
|
||||
/**
|
||||
* start the regular notification checks
|
||||
**/
|
||||
function startNotificationWatcher() {
|
||||
notificationCheck(force=true);
|
||||
notificationWatcher = setInterval(notificationCheck, 1000);
|
||||
notificationCheck(true);
|
||||
notificationWatcher = setInterval(notificationCheck, 5000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +202,8 @@ function updateNotificationReadState(btn, panel_caller=false) {
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the html for a read / unread button
|
||||
@ -203,17 +214,23 @@ function updateNotificationReadState(btn, panel_caller=false) {
|
||||
* - small: should the button be small
|
||||
**/
|
||||
function getReadEditButton(pk, state, small=false) {
|
||||
|
||||
let bReadText = '';
|
||||
let bReadIcon = '';
|
||||
let bReadTarget = '';
|
||||
|
||||
if (state) {
|
||||
var bReadText = '{% trans "Mark as unread" %}';
|
||||
var bReadIcon = 'fas fa-bookmark icon-red';
|
||||
var bReadTarget = 'unread';
|
||||
bReadText = '{% trans "Mark as unread" %}';
|
||||
bReadIcon = 'fas fa-bookmark icon-red';
|
||||
bReadTarget = 'unread';
|
||||
} else {
|
||||
var bReadText = '{% trans "Mark as read" %}';
|
||||
var bReadIcon = 'far fa-bookmark icon-green';
|
||||
var bReadTarget = 'read';
|
||||
bReadText = '{% trans "Mark as read" %}';
|
||||
bReadIcon = 'far fa-bookmark icon-green';
|
||||
bReadTarget = 'read';
|
||||
}
|
||||
|
||||
var style = (small) ? 'btn-sm ' : '';
|
||||
let style = (small) ? 'btn-sm ' : '';
|
||||
|
||||
return `<button title='${bReadText}' class='notification-read btn ${style}btn-outline-secondary float-right' type='button' pk='${pk}' target='${bReadTarget}'><span class='${bReadIcon}'></span></button>`;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,23 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
calculateTotalPrice,
|
||||
constructForm,
|
||||
constructFormBody,
|
||||
exportFormatOptions,
|
||||
formatCurrency,
|
||||
getFormFieldValue,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreeSave,
|
||||
loadTableFilters,
|
||||
makeCopyButton,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
reloadBootstrapTable,
|
||||
renderLink,
|
||||
setupFilterList,
|
||||
wrapButtons,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -138,11 +154,13 @@ function exportOrder(redirect_url, options={}) {
|
||||
var TotalPriceRef = ''; // reference to total price field
|
||||
var TotalPriceOptions = {}; // options to reload the price
|
||||
|
||||
|
||||
function loadOrderTotal(reference, options={}) {
|
||||
TotalPriceRef = reference;
|
||||
TotalPriceOptions = options;
|
||||
}
|
||||
|
||||
|
||||
function reloadTotal() {
|
||||
inventreeGet(
|
||||
TotalPriceOptions.url,
|
||||
@ -153,7 +171,7 @@ function reloadTotal() {
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -2,19 +2,48 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
baseCurrency,
|
||||
Chart,
|
||||
constructForm,
|
||||
constructFormBody,
|
||||
convertCurrency,
|
||||
formatCurrency,
|
||||
formatDecimal,
|
||||
formatPriceRange,
|
||||
getCurrencyConversionRates,
|
||||
getFormFieldValue,
|
||||
getTableData,
|
||||
global_settings,
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
inventreeSave,
|
||||
linkButtonsToSelection,
|
||||
loadTableFilters,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
moment,
|
||||
orderParts,
|
||||
purchaseOrderStatusDisplay,
|
||||
receivePurchaseOrderItems,
|
||||
renderClipboard,
|
||||
renderDate,
|
||||
renderLink,
|
||||
setFormGroupVisibility,
|
||||
setupFilterList,
|
||||
shortenString,
|
||||
showAlertDialog,
|
||||
showApiError,
|
||||
showMessage,
|
||||
showModalSpinner,
|
||||
thumbnailImage,
|
||||
withTitle,
|
||||
wrapButtons,
|
||||
yesNoLabel,
|
||||
*/
|
||||
|
||||
@ -2300,7 +2329,7 @@ function loadPartTable(table, url, options={}) {
|
||||
|
||||
$(table).bootstrapTable('refresh');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Start the ball rolling
|
||||
showModalSpinner(opts.modal);
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
/* globals
|
||||
constructForm,
|
||||
showMessage,
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -20,7 +23,7 @@ function installPlugin() {
|
||||
confirm: {},
|
||||
},
|
||||
onSuccess: function(data) {
|
||||
msg = '{% trans "The Plugin was installed" %}';
|
||||
let msg = '{% trans "The Plugin was installed" %}';
|
||||
showMessage(msg, {style: 'success', details: data.result, timeout: 30000});
|
||||
}
|
||||
});
|
||||
|
@ -4,6 +4,20 @@
|
||||
/* Functions for retrieving and displaying pricing data */
|
||||
|
||||
/* globals
|
||||
constructForm,
|
||||
global_settings,
|
||||
imageHoverIcon,
|
||||
inventreeGet,
|
||||
loadBarChart,
|
||||
loadDoughnutChart,
|
||||
makeEditButton,
|
||||
makeDeleteButton,
|
||||
randomColor,
|
||||
renderDate,
|
||||
renderLink,
|
||||
shortenString,
|
||||
withTitle,
|
||||
wrapButtons,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -150,7 +164,7 @@ function calculateTotalPrice(dataset, value_func, currency_func, options={}) {
|
||||
var common_currency = true;
|
||||
|
||||
for (var idx = 0; idx < dataset.length; idx++) {
|
||||
var row = dataset[idx];
|
||||
let row = dataset[idx];
|
||||
|
||||
var row_currency = currency_func(row);
|
||||
|
||||
@ -177,7 +191,7 @@ function calculateTotalPrice(dataset, value_func, currency_func, options={}) {
|
||||
var total = null;
|
||||
|
||||
for (var ii = 0; ii < dataset.length; ii++) {
|
||||
var row = dataset[ii];
|
||||
let row = dataset[ii];
|
||||
|
||||
// Pass the row back to the decoder
|
||||
var value = value_func(row);
|
||||
|
@ -2,20 +2,60 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
addClearCallback,
|
||||
addFieldCallback,
|
||||
barcodeDialog,
|
||||
calculateTotalPrice,
|
||||
clearEvents,
|
||||
closeModal,
|
||||
constructFormBody,
|
||||
companyFormFields,
|
||||
constructField,
|
||||
constructForm,
|
||||
constructOrderTableButtons,
|
||||
createSupplierPart,
|
||||
endDate,
|
||||
formatCurrency,
|
||||
formatDecimal,
|
||||
FullCalendar,
|
||||
initializeChoiceField,
|
||||
initializeRelatedField,
|
||||
getFormFieldElement,
|
||||
getFormFieldValue,
|
||||
getTableData,
|
||||
global_settings,
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
launchModalForm,
|
||||
linkButtonsToSelection,
|
||||
loadTableFilters,
|
||||
makeCopyButton,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makeProgressBar,
|
||||
makeRemoveButton,
|
||||
purchaseOrderStatusDisplay,
|
||||
receivePurchaseOrderItems,
|
||||
reloadBootstrapTable,
|
||||
renderClipboard,
|
||||
renderDate,
|
||||
renderLink,
|
||||
showAlertDialog,
|
||||
showApiError,
|
||||
showBarcodeMessage,
|
||||
setRelatedFieldData,
|
||||
setupFilterList,
|
||||
startDate,
|
||||
stockCodes,
|
||||
supplierPartFields,
|
||||
thumbnailImage,
|
||||
updateFieldValue,
|
||||
wrapButtons,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -169,7 +209,7 @@ function createPurchaseOrder(options={}) {
|
||||
title: '{% trans "Duplication Options" %}',
|
||||
collapsible: false,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
constructForm('{% url "api-po-list" %}', {
|
||||
method: 'POST',
|
||||
@ -273,8 +313,7 @@ function poLineItemFields(options={}) {
|
||||
success: function(response) {
|
||||
// Returned prices are in increasing order of quantity
|
||||
if (response.length > 0) {
|
||||
var idx = 0;
|
||||
var index = 0;
|
||||
let index = 0;
|
||||
|
||||
for (var idx = 0; idx < response.length; idx++) {
|
||||
if (response[idx].quantity > quantity) {
|
||||
@ -1711,9 +1750,9 @@ function loadPurchaseOrderTable(table, options) {
|
||||
onLoadSuccess: function() {
|
||||
|
||||
if (display_mode == 'calendar') {
|
||||
var el = document.getElementById('purchase-order-calendar');
|
||||
let el = document.getElementById('purchase-order-calendar');
|
||||
|
||||
calendar = new FullCalendar.Calendar(el, {
|
||||
let calendar = new FullCalendar.Calendar(el, {
|
||||
initialView: 'dayGridMonth',
|
||||
nowIndicator: true,
|
||||
aspectRatio: 2.5,
|
||||
|
@ -4,11 +4,31 @@
|
||||
/* globals
|
||||
companyFormFields,
|
||||
constructForm,
|
||||
formatCurrency,
|
||||
getFormFieldValue,
|
||||
global_settings,
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
loadTableFilters,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makeRemoveButton,
|
||||
reloadBootstrapTable,
|
||||
renderDate,
|
||||
renderLink,
|
||||
returnOrderLineItemStatusDisplay,
|
||||
returnOrderStatusDisplay,
|
||||
setupFilterList,
|
||||
showApiError,
|
||||
showAlertDialog,
|
||||
thumbnailImage,
|
||||
wrapButtons,
|
||||
yesNoLabel,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
|
@ -3,17 +3,50 @@
|
||||
|
||||
|
||||
/* globals
|
||||
addClearCallback,
|
||||
calculateTotalPrice,
|
||||
clearEvents,
|
||||
companyFormFields,
|
||||
constructExpandCollapseButtons,
|
||||
constructField,
|
||||
constructForm,
|
||||
constructOrderTableButtons,
|
||||
endDate,
|
||||
formatCurrency,
|
||||
FullCalendar,
|
||||
getFormFieldValue,
|
||||
global_settings,
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
initializeRelatedField,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
launchModalForm,
|
||||
locationDetail,
|
||||
loadTableFilters,
|
||||
makeCopyButton,
|
||||
makeEditButton,
|
||||
makeDeleteButton,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makeProgressBar,
|
||||
makeRemoveButton,
|
||||
moment,
|
||||
newBuildOrder,
|
||||
orderParts,
|
||||
reloadTotal,
|
||||
renderDate,
|
||||
renderLink,
|
||||
salesOrderStatusDisplay,
|
||||
setupFilterList,
|
||||
showAlertDialog,
|
||||
showApiError,
|
||||
startDate,
|
||||
thumbnailImage,
|
||||
updateFieldValue,
|
||||
wrapButtons,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -359,7 +392,7 @@ function completePendingShipments(order_id, options={}) {
|
||||
completePendingShipmentsHelper(allocated_shipments, 0, options);
|
||||
|
||||
} else {
|
||||
html = `
|
||||
let html = `
|
||||
<div class='alert alert-block alert-danger'>
|
||||
`;
|
||||
|
||||
@ -698,7 +731,7 @@ function loadSalesOrderTable(table, options) {
|
||||
if (display_mode == 'calendar') {
|
||||
var el = document.getElementById('purchase-order-calendar');
|
||||
|
||||
calendar = new FullCalendar.Calendar(el, {
|
||||
let calendar = new FullCalendar.Calendar(el, {
|
||||
initialView: 'dayGridMonth',
|
||||
nowIndicator: true,
|
||||
aspectRatio: 2.5,
|
||||
@ -1557,11 +1590,8 @@ function showAllocationSubTable(index, row, element, options) {
|
||||
field: 'allocated',
|
||||
title: '{% trans "Stock Item" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
var text = '';
|
||||
|
||||
var item = row.item_detail;
|
||||
|
||||
var text = `{% trans "Quantity" %}: ${row.quantity}`;
|
||||
let item = row.item_detail;
|
||||
let text = `{% trans "Quantity" %}: ${row.quantity}`;
|
||||
|
||||
if (item && item.serial != null && row.quantity == 1) {
|
||||
text = `{% trans "Serial Number" %}: ${item.serial}`;
|
||||
@ -1977,10 +2007,10 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
|
||||
var title = '{% trans "Delete line item" %}';
|
||||
|
||||
if (!!row.shipped) {
|
||||
if (row.shipped) {
|
||||
delete_disabled = true;
|
||||
title = '{% trans "Cannot be deleted as items have been shipped" %}';
|
||||
} else if (!!row.allocated) {
|
||||
} else if (row.allocated) {
|
||||
delete_disabled = true;
|
||||
title = '{% trans "Cannot be deleted as items have been allocated" %}';
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* globals
|
||||
getModelRenderer,
|
||||
inventreeGet,
|
||||
inventreePut,
|
||||
sanitizeInputString,
|
||||
user_settings,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -102,6 +107,10 @@ var searchQuery = null;
|
||||
var searchResultTypes = [];
|
||||
var searchRequest = null;
|
||||
|
||||
|
||||
/*
|
||||
* Callback for when the search text is changed
|
||||
*/
|
||||
function searchTextChanged(event) {
|
||||
|
||||
var text = $('#offcanvas-search').find('#search-input').val();
|
||||
@ -110,9 +119,12 @@ function searchTextChanged(event) {
|
||||
|
||||
clearTimeout(searchInputTimer);
|
||||
searchInputTimer = setTimeout(updateSearch, 250);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the search results
|
||||
*/
|
||||
function updateSearch() {
|
||||
|
||||
if (searchText == searchTextCurrent) {
|
||||
|
@ -3,25 +3,61 @@
|
||||
{% load status_codes %}
|
||||
|
||||
/* globals
|
||||
addCachedAlert,
|
||||
baseCurrency,
|
||||
calculateTotalPrice,
|
||||
clearFormInput,
|
||||
constructField,
|
||||
constructForm,
|
||||
constructFormBody,
|
||||
convertCurrency,
|
||||
disableFormInput,
|
||||
enableFormInput,
|
||||
formatCurrency,
|
||||
formatDecimal,
|
||||
formatPriceRange,
|
||||
getCurrencyConversionRates,
|
||||
getFormFieldValue,
|
||||
getTableData,
|
||||
global_settings,
|
||||
handleFormErrors,
|
||||
handleFormSuccess,
|
||||
imageHoverIcon,
|
||||
initializeRelatedField,
|
||||
inventreeDelete,
|
||||
inventreeGet,
|
||||
inventreeLoad,
|
||||
inventreePut,
|
||||
inventreeSave,
|
||||
launchModalForm,
|
||||
linkButtonsToSelection,
|
||||
loadTableFilters,
|
||||
makeDeleteButton,
|
||||
makeEditButton,
|
||||
makeIconBadge,
|
||||
makeIconButton,
|
||||
makeRemoveButton,
|
||||
orderParts,
|
||||
partDetail,
|
||||
renderClipboard,
|
||||
renderDate,
|
||||
renderLink,
|
||||
scanItemsIntoLocation,
|
||||
showAlertDialog,
|
||||
setFormInputPlaceholder,
|
||||
setupFilterList,
|
||||
shortenString,
|
||||
showAlertDialog,
|
||||
showAlertOrCache,
|
||||
showMessage,
|
||||
showModalSpinner,
|
||||
showApiError,
|
||||
stockCodes,
|
||||
stockStatusDisplay,
|
||||
thumbnailImage,
|
||||
updateFieldValue,
|
||||
withTitle,
|
||||
wrapButtons,
|
||||
yesNoLabel,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -792,7 +828,7 @@ function mergeStockItems(items, options={}) {
|
||||
}
|
||||
|
||||
var part = item.part_detail;
|
||||
var location = locationDetail(item, false);
|
||||
let location_detail = locationDetail(item, false);
|
||||
|
||||
var thumbnail = thumbnailImage(part.thumbnail || part.image);
|
||||
|
||||
@ -824,7 +860,7 @@ function mergeStockItems(items, options={}) {
|
||||
<div id='errors-items_item_${pk}'></div>
|
||||
</div>
|
||||
</td>
|
||||
<td id='location_${pk}'>${location}</td>
|
||||
<td id='location_${pk}'>${location_detail}</td>
|
||||
<td id='buttons_${pk}'>${buttons}</td>
|
||||
</tr>
|
||||
`;
|
||||
|
@ -3,10 +3,14 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* globals
|
||||
global_settings
|
||||
buildCodes,
|
||||
global_settings,
|
||||
inventreeGet,
|
||||
purchaseOrderCodes,
|
||||
returnOrderCodes,
|
||||
returnOrderLineItemCodes,
|
||||
salesOrderCodes,
|
||||
stockCodes,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -449,7 +453,7 @@ function getBuildTableFilters() {
|
||||
inventreeGet('{% url "api-owner-list" %}', {}, {
|
||||
async: false,
|
||||
success: function(response) {
|
||||
for (key in response) {
|
||||
for (var key in response) {
|
||||
var owner = response[key];
|
||||
ownersList[owner.pk] = {
|
||||
key: owner.pk,
|
||||
|
@ -1,8 +1,14 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* global
|
||||
constructFormBody,
|
||||
exportFormatOptions,
|
||||
getFormFieldValue,
|
||||
inventreeLoad,
|
||||
inventreeSave,
|
||||
sanitizeData,
|
||||
sanitizeInputString,
|
||||
user_settings,
|
||||
*/
|
||||
|
||||
/* exported
|
||||
@ -58,7 +64,7 @@ function constructOrderTableButtons(options={}) {
|
||||
|
||||
var display_mode = options.display;
|
||||
|
||||
var key = `${options.prefix || order}-table-display-mode`;
|
||||
var key = `${options.prefix || 'order'}-table-display-mode`;
|
||||
|
||||
// If display mode is not provided, look up from session
|
||||
if (!display_mode) {
|
||||
@ -262,7 +268,7 @@ function reloadTableFilters(table, filters, options={}) {
|
||||
}
|
||||
|
||||
// More complex refresh with new filters supplied
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
options = table.bootstrapTable('getOptions');
|
||||
|
||||
// Construct a new list of filters to use for the query
|
||||
var params = {};
|
||||
@ -559,7 +565,7 @@ function customGroupSorter(sortName, sortOrder, sortData) {
|
||||
},
|
||||
formatShowingRows: function(pageFrom, pageTo, totalRows) {
|
||||
|
||||
if (totalRows === undefined || totalRows === NaN) {
|
||||
if (totalRows === undefined || isNaN(totalRows)) {
|
||||
return '{% trans "Showing all rows" %}';
|
||||
} else {
|
||||
return `{% trans "Showing" %} ${pageFrom} {% trans "to" %} ${pageTo} {% trans "of" %} ${totalRows} {% trans "rows" %}`;
|
||||
|
Reference in New Issue
Block a user