diff --git a/.eslintrc.yml b/.eslintrc.yml index ba0e8d6cac..43363404b3 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -15,6 +15,11 @@ rules: padded-blocks: off prefer-const: off max-len: off + require-jsdoc: off + valid-jsdoc: off + no-multiple-empty-lines: off + comma-dangle: off + prefer-spread: off indent: - error - 4 diff --git a/InvenTree/templates/js/dynamic/calendar.js b/InvenTree/templates/js/dynamic/calendar.js index fd36d689f5..268337bd52 100644 --- a/InvenTree/templates/js/dynamic/calendar.js +++ b/InvenTree/templates/js/dynamic/calendar.js @@ -15,12 +15,12 @@ function startDate(calendar) { // Extract the first displayed date on the calendar - return calendar.currentData.dateProfile.activeRange.start.toISOString().split("T")[0]; + return calendar.currentData.dateProfile.activeRange.start.toISOString().split('T')[0]; } function endDate(calendar) { // Extract the last display date on the calendar - return calendar.currentData.dateProfile.activeRange.end.toISOString().split("T")[0]; + return calendar.currentData.dateProfile.activeRange.end.toISOString().split('T')[0]; } function clearEvents(calendar) { @@ -30,5 +30,5 @@ function clearEvents(calendar) { events.forEach(function(event) { event.remove(); - }) -} \ No newline at end of file + }); +} diff --git a/InvenTree/templates/js/dynamic/inventree.js b/InvenTree/templates/js/dynamic/inventree.js index 2a151fcdaf..7d608c1886 100644 --- a/InvenTree/templates/js/dynamic/inventree.js +++ b/InvenTree/templates/js/dynamic/inventree.js @@ -17,7 +17,7 @@ function attachClipboard(selector, containerselector, textElement) { // set container - if (containerselector){ + if (containerselector) { containerselector = document.getElementById(containerselector); } else { containerselector = document.body; @@ -26,15 +26,15 @@ function attachClipboard(selector, containerselector, textElement) { var text = null; // set text-function - if (textElement){ + if (textElement) { text = function() { return document.getElementById(textElement).textContent; - } + }; } else { text = function(trigger) { var content = trigger.parentElement.parentElement.textContent; return content.trim(); - } + }; } // create Clipboard @@ -51,15 +51,15 @@ function inventreeDocReady() { * This will be called for every page that extends "base.html" */ - window.addEventListener("dragover",function(e){ + window.addEventListener('dragover', function(e) { e = e || event; e.preventDefault(); - },false); + }, false); - window.addEventListener("drop",function(e){ + window.addEventListener('drop', function(e) { e = e || event; e.preventDefault(); - },false); + }, false); /* Add drag-n-drop functionality to any element * marked with the class 'dropzone' @@ -93,19 +93,19 @@ function inventreeDocReady() { // Callback to launch the 'Database Stats' window $('#launch-stats').click(function() { - launchModalForm("/stats/", { + launchModalForm('/stats/', { no_post: true, }); }); // Initialize clipboard-buttons attachClipboard('.clip-btn'); - attachClipboard('.clip-btn', 'modal-about'); // modals - attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // version-text + attachClipboard('.clip-btn', 'modal-about'); + attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // Add autocomplete to the search-bar - $("#search-bar" ).autocomplete({ - source: function (request, response) { + $('#search-bar').autocomplete({ + source: function(request, response) { $.ajax({ url: '/api/part/', data: { @@ -113,8 +113,8 @@ function inventreeDocReady() { limit: user_settings.SEARCH_PREVIEW_RESULTS, offset: 0 }, - success: function (data) { - var transformed = $.map(data.results, function (el) { + success: function(data) { + var transformed = $.map(data.results, function(el) { return { label: el.name, id: el.pk, @@ -123,13 +123,13 @@ function inventreeDocReady() { }); response(transformed); }, - error: function () { + error: function() { response([]); } }); }, - create: function () { - $(this).data('ui-autocomplete')._renderItem = function (ul, item) { + create: function() { + $(this).data('ui-autocomplete')._renderItem = function(ul, item) { var html = ``; @@ -147,7 +147,9 @@ function inventreeDocReady() { window.location = '/part/' + ui.item.id + '/'; }, minLength: 2, - classes: {'ui-autocomplete': 'dropdown-menu search-menu'}, + classes: { + 'ui-autocomplete': 'dropdown-menu search-menu', + }, }); } @@ -217,21 +219,27 @@ function enableDragAndDrop(element, url, options) { } +/** + * Save a key:value pair to local storage + * @param {String} name - settting key + * @param {String} value - setting value + */ function inventreeSave(name, value) { - /* - * Save a key:value pair to local storage - */ - var key = "inventree-" + name; + var key = `inventree-${name}`; localStorage.setItem(key, value); } -function inventreeLoad(name, defaultValue) { - /* - * Retrieve a key:value pair from local storage - */ - var key = "inventree-" + name; +/** + * Retrieve a key:value pair from local storage + * @param {*} name - setting key + * @param {*} defaultValue - default value (returned if no matching key:value pair is found) + * @returns + */ +function inventreeLoad(name, defaultValue) { + + var key = `inventree-${name}`; var value = localStorage.getItem(key); diff --git a/InvenTree/templates/js/dynamic/nav.js b/InvenTree/templates/js/dynamic/nav.js index 0b49be23c6..cf652724ed 100644 --- a/InvenTree/templates/js/dynamic/nav.js +++ b/InvenTree/templates/js/dynamic/nav.js @@ -112,4 +112,4 @@ function onPanelLoad(panel, callback) { $(panelId).off('fadeInStarted'); }); -} \ No newline at end of file +} diff --git a/InvenTree/templates/js/dynamic/settings.js b/InvenTree/templates/js/dynamic/settings.js index 7f606b7548..cb21e1fefc 100644 --- a/InvenTree/templates/js/dynamic/settings.js +++ b/InvenTree/templates/js/dynamic/settings.js @@ -17,4 +17,4 @@ const global_settings = { {% for key, value in GLOBAL_SETTINGS.items %} {{ key }}: {% primitive_to_javascript value %}, {% endfor %} -}; \ No newline at end of file +}; diff --git a/InvenTree/templates/js/translated/api.js b/InvenTree/templates/js/translated/api.js index 6ca4b2672d..841cf467ba 100644 --- a/InvenTree/templates/js/translated/api.js +++ b/InvenTree/templates/js/translated/api.js @@ -13,14 +13,17 @@ showApiError, */ -$.urlParam = function(name){ +$.urlParam = function(name) { // eslint-disable-next-line no-useless-escape var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); - if (results==null) { - return null; + + if (results == null) { + return null; } + return decodeURI(results[1]) || 0; -} +}; + // using jQuery function getCookie(name) { @@ -42,7 +45,6 @@ function getCookie(name) { function inventreeGet(url, filters={}, options={}) { // Middleware token required for data update - //var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val(); var csrftoken = getCookie('csrftoken'); return $.ajax({ @@ -112,7 +114,6 @@ function inventreePut(url, data={}, options={}) { var method = options.method || 'PUT'; // Middleware token required for data update - //var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val(); var csrftoken = getCookie('csrftoken'); return $.ajax({ @@ -168,29 +169,35 @@ function showApiError(xhr) { var message = null; switch (xhr.status) { - case 0: // No response + // No response + case 0: title = '{% trans "No Response" %}'; message = '{% trans "No response from the InvenTree server" %}'; break; - case 400: // Bad request + // Bad request + case 400: // Note: Normally error code 400 is handled separately, // and should now be shown here! title = '{% trans "Error 400: Bad request" %}'; message = '{% trans "API request returned error code 400" %}'; break; - case 401: // Not authenticated + // Not authenticated + case 401: title = '{% trans "Error 401: Not Authenticated" %}'; message = '{% trans "Authentication credentials not supplied" %}'; break; - case 403: // Permission denied + // Permission denied + case 403: title = '{% trans "Error 403: Permission Denied" %}'; message = '{% trans "You do not have the required permissions to access this function" %}'; break; - case 404: // Resource not found + // Resource not found + case 404: title = '{% trans "Error 404: Resource Not Found" %}'; message = '{% trans "The requested resource could not be located on the server" %}'; break; - case 408: // Timeout + // Timeout + case 408: title = '{% trans "Error 408: Timeout" %}'; message = '{% trans "Connection timeout while requesting data from server" %}'; break; @@ -200,8 +207,8 @@ function showApiError(xhr) { break; } - message += "
"; + message += '
'; message += renderErrorMessage(xhr); showAlertDialog(title, message); -} \ No newline at end of file +} diff --git a/InvenTree/templates/js/translated/attachment.js b/InvenTree/templates/js/translated/attachment.js index 1c4e9f2781..88c73ed3e3 100644 --- a/InvenTree/templates/js/translated/attachment.js +++ b/InvenTree/templates/js/translated/attachment.js @@ -12,7 +12,7 @@ function reloadAttachmentTable() { - $('#attachment-table').bootstrapTable("refresh"); + $('#attachment-table').bootstrapTable('refresh'); } @@ -24,7 +24,7 @@ function loadAttachmentTable(url, options) { url: url, name: options.name || 'attachments', formatNoMatches: function() { - return '{% trans "No attachments found" %}' + return '{% trans "No attachments found" %}'; }, sortable: true, search: false, @@ -67,7 +67,7 @@ function loadAttachmentTable(url, options) { } else { var images = ['.png', '.jpg', '.bmp', '.gif', '.svg', '.tif']; - images.forEach(function (suffix) { + images.forEach(function(suffix) { if (fn.endsWith(suffix)) { icon = 'fa-file-image'; } @@ -118,4 +118,4 @@ function loadAttachmentTable(url, options) { } ] }); -} \ No newline at end of file +} diff --git a/InvenTree/templates/js/translated/barcode.js b/InvenTree/templates/js/translated/barcode.js index 42aaf3c416..a1d6fb7adf 100644 --- a/InvenTree/templates/js/translated/barcode.js +++ b/InvenTree/templates/js/translated/barcode.js @@ -121,7 +121,7 @@ function postBarcodeData(barcode_data, options={}) { } } } - ) + ); } @@ -131,7 +131,7 @@ function showBarcodeMessage(modal, message, style='danger') { html += message; - html += ""; + html += ''; $(modal + ' #barcode-error-message').html(html); } @@ -278,7 +278,7 @@ function barcodeScanDialog() { var modal = '#modal-form'; barcodeDialog( - "Scan Barcode", + '{% trans "Scan Barcode" %}', { onScan: function(response) { if ('url' in response) { @@ -307,7 +307,7 @@ function linkBarcodeDialog(stockitem) { var modal = '#modal-form'; barcodeDialog( - "{% trans 'Link Barcode to Stock Item' %}", + '{% trans "Link Barcode to Stock Item" %}', { url: '/api/barcode/link/', data: { @@ -330,13 +330,13 @@ function unlinkBarcode(stockitem) { var html = `{% trans "Unlink Barcode" %}
`; - html += "{% trans 'This will remove the association between this stock item and the barcode' %}"; + html += '{% trans "This will remove the association between this stock item and the barcode" %}'; showQuestionDialog( - "{% trans 'Unlink Barcode' %}", + '{% trans "Unlink Barcode" %}', html, { - accept_text: "{% trans 'Unlink' %}", + accept_text: '{% trans "Unlink" %}', accept: function() { inventreePut( `/api/stock/${stockitem}/`, @@ -471,7 +471,7 @@ function barcodeCheckIn(location_id) { data.items = entries; inventreePut( - "{% url 'api-stock-transfer' %}", + '{% url "api-stock-transfer" %}', data, { method: 'POST', @@ -502,7 +502,7 @@ function barcodeCheckIn(location_id) { }); if (duplicate) { - showBarcodeMessage(modal, '{% trans "Stock Item already scanned" %}', "warning"); + showBarcodeMessage(modal, '{% trans "Stock Item already scanned" %}', 'warning'); } else { if (stockitem.location == location_id) { @@ -513,14 +513,14 @@ function barcodeCheckIn(location_id) { // Add this stock item to the list items.push(stockitem); - showBarcodeMessage(modal, '{% trans "Added stock item" %}', "success"); + showBarcodeMessage(modal, '{% trans "Added stock item" %}', 'success'); reloadTable(); } } else { // Barcode does not match a stock item - showBarcodeMessage(modal, '{% trans "Barcode does not match Stock Item" %}', "warning"); + showBarcodeMessage(modal, '{% trans "Barcode does not match Stock Item" %}', 'warning'); } }, } @@ -585,7 +585,7 @@ function scanItemsIntoLocation(item_id_list, options={}) { items.push({ pk: pk, }); - }) + }); var data = { location: stock_location.pk, @@ -611,7 +611,7 @@ function scanItemsIntoLocation(item_id_list, options={}) { } } } - ) + ); }, onScan: function(response) { updateLocationInfo(null); @@ -627,10 +627,10 @@ function scanItemsIntoLocation(item_id_list, options={}) { showBarcodeMessage( modal, '{% trans "Barcode does not match a valid location" %}', - "warning", + 'warning', ); } } } - ) -} \ No newline at end of file + ); +} diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index 399d2a08f3..bcfa7ef5ff 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -146,7 +146,7 @@ function loadBomTable(table, options) { var params = { part: options.parent_id, ordering: 'name', - } + }; if (options.part_detail) { params.part_detail = true; @@ -264,8 +264,7 @@ function loadBomTable(table, options) { }, }); - cols.push( - { + cols.push({ field: 'sub_part_detail.stock', title: '{% trans "Available" %}', searchable: false, @@ -283,24 +282,21 @@ function loadBomTable(table, options) { } }); - cols.push( - { + cols.push({ field: 'purchase_price_range', title: '{% trans "Purchase Price Range" %}', searchable: false, sortable: true, }); - cols.push( - { + cols.push({ field: 'purchase_price_avg', title: '{% trans "Purchase Price Average" %}', searchable: false, sortable: true, }); - cols.push( - { + cols.push({ field: 'price_range', title: '{% trans "Supplier Cost" %}', sortable: true, @@ -308,7 +304,7 @@ function loadBomTable(table, options) { if (value) { return value; } else { - return "{% trans 'No supplier pricing available' %}"; + return `{% trans 'No supplier pricing available' %}`; } } }); @@ -328,7 +324,7 @@ function loadBomTable(table, options) { formatter: function(value) { return yesNoLabel(value); } - }) + }); cols.push({ field: 'inherited', @@ -352,8 +348,8 @@ function loadBomTable(table, options) { cols.push( { - 'field': 'can_build', - 'title': '{% trans "Can Build" %}', + field: 'can_build', + title: '{% trans "Can Build" %}', formatter: function(value, row) { var can_build = 0; @@ -380,7 +376,7 @@ function loadBomTable(table, options) { }, sortable: true, } - ) + ); // Part notes cols.push( @@ -411,7 +407,7 @@ function loadBomTable(table, options) { var bDelt = ``; - var html = "
"; + var html = `
`; html += bEdit; html += bDelt; @@ -422,7 +418,7 @@ function loadBomTable(table, options) { html += bValid; } - html += "
"; + html += `
`; return html; } else { @@ -454,7 +450,7 @@ function loadBomTable(table, options) { response[idx].parentId = bom_pk; if (response[idx].sub_part_detail.assembly) { - requestSubItems(response[idx].pk, response[idx].sub_part) + requestSubItems(response[idx].pk, response[idx].sub_part); } } @@ -466,7 +462,7 @@ function loadBomTable(table, options) { console.log('Error requesting BOM for part=' + part_pk); } } - ) + ); } table.inventreeTable({ diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 703e843d76..d359d6cf4e 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -125,7 +125,7 @@ function makeBuildOutputActionButtons(output, buildInfo, lines) { html += makeIconButton( 'fa-magic icon-blue', 'button-output-auto', outputId, '{% trans "Auto-allocate stock items to this output" %}', - ); + ); } if (lines > 0) { @@ -133,7 +133,7 @@ function makeBuildOutputActionButtons(output, buildInfo, lines) { html += makeIconButton( 'fa-minus-circle icon-red', 'button-output-unallocate', outputId, '{% trans "Unallocate stock from build output" %}', - ); + ); } @@ -144,7 +144,7 @@ function makeBuildOutputActionButtons(output, buildInfo, lines) { 'fa-check icon-green', 'button-output-complete', outputId, '{% trans "Complete build output" %}', { - //disabled: true + // disabled: true } ); @@ -152,7 +152,7 @@ function makeBuildOutputActionButtons(output, buildInfo, lines) { html += makeIconButton( 'fa-trash-alt icon-red', 'button-output-delete', outputId, '{% trans "Delete build output" %}', - ); + ); // TODO - Add a button to "destroy" the particular build output (mark as damaged, scrap) } @@ -229,13 +229,13 @@ function loadBuildOrderAllocationTable(table, options={}) { options.params['build_detail'] = true; options.params['location_detail'] = true; - var filters = loadTableFilters("buildorderallocation"); + var filters = loadTableFilters('buildorderallocation'); for (var key in options.params) { filters[key] = options.params[key]; } - setupFilterList("buildorderallocation", $(table)); + setupFilterList('buildorderallocation', $(table)); $(table).inventreeTable({ url: '{% url "api-build-item-list" %}', @@ -246,7 +246,7 @@ function loadBuildOrderAllocationTable(table, options={}) { paginationVAlign: 'bottom', original: options.params, formatNoMatches: function() { - return '{% trans "No build order allocations found" %}' + return '{% trans "No build order allocations found" %}'; }, columns: [ { @@ -372,13 +372,13 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { // Register button callbacks once table data are loaded // Callback for 'allocate' button - $(table).find(".button-add").click(function() { + $(table).find('.button-add').click(function() { // Primary key of the 'sub_part' var pk = $(this).attr('pk'); // Launch form to allocate new stock against this output - launchModalForm("{% url 'build-item-create' %}", { + launchModalForm('{% url "build-item-create" %}', { success: reloadTable, data: { part: pk, @@ -418,7 +418,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { } } } - ) + ); } } ] @@ -472,7 +472,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { // Load table of BOM items $(table).inventreeTable({ - url: "{% url 'api-bom-list' %}", + url: '{% url "api-bom-list" %}', queryParams: { part: partId, sub_part_detail: true, @@ -492,7 +492,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { build: buildId, part_detail: true, location_detail: true, - } + }; if (output) { params.sub_part_trackable = true; @@ -521,7 +521,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { var key = parseInt(part); if (!(key in allocations)) { - allocations[key] = new Array(); + allocations[key] = []; } allocations[key].push(item); @@ -827,7 +827,7 @@ function loadBuildTable(table, options) { params['part_detail'] = true; if (!options.disableFilters) { - filters = loadTableFilters("build"); + filters = loadTableFilters('build'); } for (var key in params) { @@ -838,7 +838,7 @@ function loadBuildTable(table, options) { var filterTarget = options.filterTarget || null; - setupFilterList("build", table, filterTarget); + setupFilterList('build', table, filterTarget); $(table).inventreeTable({ method: 'get', @@ -915,7 +915,7 @@ function loadBuildTable(table, options) { row.completed, row.quantity, { - //style: 'max', + // style: 'max', } ); } @@ -985,7 +985,7 @@ function updateAllocationTotal(id, count, required) { $('#allocation-total-'+id).html(count); - var el = $("#allocation-panel-" + id); + var el = $('#allocation-panel-' + id); el.removeClass('part-allocation-pass part-allocation-underallocated part-allocation-overallocated'); if (count < required) { @@ -1027,10 +1027,15 @@ function loadAllocationTable(table, part_id, part, url, required, button) { formatter: function(value, row) { var html = parseFloat(value); - var bEdit = ""; - var bDel = ""; + var bEdit = ``; + var bDel = ``; - html += "
" + bEdit + bDel + "
"; + html += ` +
+ ${bEdit} + ${bDel} +
+ `; return html; } @@ -1266,4 +1271,4 @@ function loadBuildPartsTable(table, options={}) { original: params, columns: columns, }); -} \ No newline at end of file +} diff --git a/InvenTree/templates/js/translated/company.js b/InvenTree/templates/js/translated/company.js index e490f8914e..c014139e1b 100644 --- a/InvenTree/templates/js/translated/company.js +++ b/InvenTree/templates/js/translated/company.js @@ -24,6 +24,10 @@ */ +/** + * Construct a set of form fields for creating / editing a ManufacturerPart + * @returns + */ function manufacturerPartFields() { return { @@ -40,6 +44,10 @@ function manufacturerPartFields() { } +/** + * Launches a form to create a new ManufacturerPart + * @param {object} options + */ function createManufacturerPart(options={}) { var fields = manufacturerPartFields(); @@ -62,7 +70,7 @@ function createManufacturerPart(options={}) { return company_fields; } - } + }; constructForm('{% url "api-manufacturer-part-list" %}', { fields: fields, @@ -73,6 +81,11 @@ function createManufacturerPart(options={}) { } +/** + * Launches a form to edit a ManufacturerPart + * @param {integer} part - ID of a ManufacturerPart + * @param {object} options + */ function editManufacturerPart(part, options={}) { var url = `/api/company/part/manufacturer/${part}/`; @@ -288,13 +301,13 @@ function loadCompanyTable(table, url, options={}) { // Query parameters var params = options.params || {}; - var filters = loadTableFilters("company"); + var filters = loadTableFilters('company'); for (var key in params) { filters[key] = params[key]; } - setupFilterList("company", $(table)); + setupFilterList('company', $(table)); var columns = [ { @@ -391,18 +404,18 @@ function deleteManufacturerParts(selections, options={}) {

{% trans "The following manufacturer parts will be deleted" %}:

- `; +
  • +

    ${item.MPN} - ${item.part_detail.full_name}

    +
  • `; + }); + + text += ` + + `; showQuestionDialog( '{% trans "Delete Manufacturer Parts" %}', @@ -426,7 +439,7 @@ function deleteManufacturerParts(selections, options={}) { if (options.onSuccess) { options.onSuccess(); } - }) + }); } } ); @@ -443,13 +456,13 @@ function loadManufacturerPartTable(table, url, options) { var params = options.params || {}; // Load filters - var filters = loadTableFilters("manufacturer-part"); + var filters = loadTableFilters('manufacturer-part'); for (var key in params) { filters[key] = params[key]; } - setupFilterList("manufacturer-part", $(table)); + setupFilterList('manufacturer-part', $(table)); $(table).inventreeTable({ url: url, @@ -505,7 +518,7 @@ function loadManufacturerPartTable(table, url, options) { return html; } else { - return "-"; + return '-'; } } }, @@ -563,8 +576,9 @@ function loadManufacturerPartTable(table, url, options) { { onSuccess: function() { $(table).bootstrapTable('refresh'); + } } - }); + ); }); $(table).find('.button-manufacturer-part-delete').click(function() { @@ -575,9 +589,10 @@ function loadManufacturerPartTable(table, url, options) { { onSuccess: function() { $(table).bootstrapTable('refresh'); + } } - }); - }) + ); + }); } }); } @@ -591,7 +606,7 @@ function loadManufacturerPartParameterTable(table, url, options) { var params = options.params || {}; // Load filters - var filters = loadTableFilters("manufacturer-part-parameters"); + var filters = loadTableFilters('manufacturer-part-parameters'); // Overwrite explicit parameters for (var key in params) { @@ -607,7 +622,9 @@ function loadManufacturerPartParameterTable(table, url, options) { queryParams: filters, name: 'manufacturerpartparameters', groupBy: false, - formatNoMatches: function() { return '{% trans "No parameters found" %}'; }, + formatNoMatches: function() { + return '{% trans "No parameters found" %}'; + }, columns: [ { checkbox: true, @@ -695,13 +712,13 @@ function loadSupplierPartTable(table, url, options) { var params = options.params || {}; // Load filters - var filters = loadTableFilters("supplier-part"); + var filters = loadTableFilters('supplier-part'); for (var key in params) { filters[key] = params[key]; } - setupFilterList("supplier-part", $(table)); + setupFilterList('supplier-part', $(table)); $(table).inventreeTable({ url: url, @@ -710,7 +727,9 @@ function loadSupplierPartTable(table, url, options) { queryParams: filters, name: 'supplierparts', groupBy: false, - formatNoMatches: function() { return '{% trans "No supplier parts found" %}'; }, + formatNoMatches: function() { + return '{% trans "No supplier parts found" %}'; + }, columns: [ { checkbox: true, @@ -755,7 +774,7 @@ function loadSupplierPartTable(table, url, options) { return html; } else { - return "-"; + return '-'; } }, }, @@ -781,7 +800,7 @@ function loadSupplierPartTable(table, url, options) { return html; } else { - return "-"; + return '-'; } } }, @@ -795,7 +814,7 @@ function loadSupplierPartTable(table, url, options) { if (value && row.manufacturer_part) { return renderLink(value, `/manufacturer-part/${row.manufacturer_part}/`); } else { - return "-"; + return '-'; } } }, @@ -870,7 +889,7 @@ function loadSupplierPartTable(table, url, options) { } } ); - }) + }); } }); -} \ No newline at end of file +} diff --git a/InvenTree/templates/js/translated/filters.js b/InvenTree/templates/js/translated/filters.js index 8d70715ff0..d7e8f45ca5 100644 --- a/InvenTree/templates/js/translated/filters.js +++ b/InvenTree/templates/js/translated/filters.js @@ -27,12 +27,12 @@ function defaultFilters() { return { - stock: "cascade=1&in_stock=1", - build: "", - parts: "cascade=1", - company: "", - salesorder: "", - purchaseorder: "", + stock: 'cascade=1&in_stock=1', + build: '', + parts: 'cascade=1', + company: '', + salesorder: '', + purchaseorder: '', }; } @@ -45,7 +45,7 @@ function defaultFilters() { */ function loadTableFilters(tableKey) { - var lookup = "table-filters-" + tableKey.toLowerCase(); + var lookup = 'table-filters-' + tableKey.toLowerCase(); var defaults = defaultFilters()[tableKey] || ''; @@ -53,7 +53,7 @@ function loadTableFilters(tableKey) { var filters = {}; - filterstring.split("&").forEach(function(item) { + filterstring.split('&').forEach(function(item) { item = item.trim(); if (item.length > 0) { @@ -78,7 +78,7 @@ function loadTableFilters(tableKey) { * @param {*} filters - object of string:string pairs */ function saveTableFilters(tableKey, filters) { - var lookup = "table-filters-" + tableKey.toLowerCase(); + var lookup = 'table-filters-' + tableKey.toLowerCase(); var strings = []; @@ -201,7 +201,7 @@ function generateAvailableFilterList(tableKey) { var html = `