mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
lots of linting fixes for JS files
This commit is contained in:
parent
cb403a5b29
commit
888fa51cd7
@ -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
|
||||
|
@ -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();
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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 = `<a href='/part/${item.id}/'><span>`;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
@ -112,4 +112,4 @@ function onPanelLoad(panel, callback) {
|
||||
$(panelId).off('fadeInStarted');
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,4 @@ const global_settings = {
|
||||
{% for key, value in GLOBAL_SETTINGS.items %}
|
||||
{{ key }}: {% primitive_to_javascript value %},
|
||||
{% endfor %}
|
||||
};
|
||||
};
|
||||
|
@ -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 += "<hr>";
|
||||
message += '<hr>';
|
||||
message += renderErrorMessage(xhr);
|
||||
|
||||
showAlertDialog(title, message);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ function postBarcodeData(barcode_data, options={}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ function showBarcodeMessage(modal, message, style='danger') {
|
||||
|
||||
html += message;
|
||||
|
||||
html += "</div>";
|
||||
html += '</div>';
|
||||
|
||||
$(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 = `<b>{% trans "Unlink Barcode" %}</b><br>`;
|
||||
|
||||
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',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -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 "<span class='warning-msg'>{% trans 'No supplier pricing available' %}</span>";
|
||||
return `<span class='warning-msg'>{% trans 'No supplier pricing available' %}</span>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -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 = `<button title='{% trans "Delete BOM Item" %}' class='bom-delete-button btn btn-default btn-glyph' type='button' pk='${row.pk}'><span class='fas fa-trash-alt icon-red'></span></button>`;
|
||||
|
||||
var html = "<div class='btn-group' role='group'>";
|
||||
var html = `<div class='btn-group' role='group'>`;
|
||||
|
||||
html += bEdit;
|
||||
html += bDelt;
|
||||
@ -422,7 +418,7 @@ function loadBomTable(table, options) {
|
||||
html += bValid;
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
html += `</div>`;
|
||||
|
||||
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({
|
||||
|
@ -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 = "<button class='btn item-edit-button btn-sm' type='button' title='{% trans "Edit stock allocation" %}' url='/build/item/" + row.pk + "/edit/'><span class='fas fa-edit'></span></button>";
|
||||
var bDel = "<button class='btn item-del-button btn-sm' type='button' title='{% trans "Delete stock allocation" %}' url='/build/item/" + row.pk + "/delete/'><span class='fas fa-trash-alt icon-red'></span></button>";
|
||||
var bEdit = `<button class='btn item-edit-button btn-sm' type='button' title='{% trans "Edit stock allocation" %}' url='/build/item/${row.pk}/edit/'><span class='fas fa-edit'></span></button>`;
|
||||
var bDel = `<button class='btn item-del-button btn-sm' type='button' title='{% trans "Delete stock allocation" %}' url='/build/item/${row.pk}/delete/'><span class='fas fa-trash-alt icon-red'></span></button>`;
|
||||
|
||||
html += "<div class='btn-group' style='float: right;'>" + bEdit + bDel + "</div>";
|
||||
html += `
|
||||
<div class='btn-group' style='float: right;'>
|
||||
${bEdit}
|
||||
${bDel}
|
||||
</div>
|
||||
`;
|
||||
|
||||
return html;
|
||||
}
|
||||
@ -1266,4 +1271,4 @@ function loadBuildPartsTable(table, options={}) {
|
||||
original: params,
|
||||
columns: columns,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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={}) {
|
||||
<p>{% trans "The following manufacturer parts will be deleted" %}:</p>
|
||||
<ul>`;
|
||||
|
||||
selections.forEach(function(item) {
|
||||
parts.push(item.pk);
|
||||
selections.forEach(function(item) {
|
||||
parts.push(item.pk);
|
||||
|
||||
text += `
|
||||
<li>
|
||||
<p>${item.MPN} - ${item.part_detail.full_name}</p>
|
||||
</li>`;
|
||||
});
|
||||
|
||||
text += `
|
||||
</ul>
|
||||
</div>`;
|
||||
<li>
|
||||
<p>${item.MPN} - ${item.part_detail.full_name}</p>
|
||||
</li>`;
|
||||
});
|
||||
|
||||
text += `
|
||||
</ul>
|
||||
</div>`;
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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 = `<select class='form-control filter-input' id='${id}' name='tag'>`;
|
||||
|
||||
html += "<option value=''>{% trans 'Select filter' %}</option>";
|
||||
html += `<option value=''>{% trans 'Select filter' %}</option>`;
|
||||
|
||||
for (var opt in remaining) {
|
||||
var title = getFilterTitle(tableKey, opt);
|
||||
@ -306,15 +306,11 @@ function setupFilterList(tableKey, table, target) {
|
||||
|
||||
var html = '';
|
||||
|
||||
//`<div class='filter-input'>`;
|
||||
|
||||
html += generateAvailableFilterList(tableKey);
|
||||
html += generateFilterInput(tableKey);
|
||||
|
||||
html += `<button title='{% trans "Create filter" %}' class='btn btn-default filter-tag' id='${make}'><span class='fas fa-plus'></span></button>`;
|
||||
|
||||
//html += '</div>';
|
||||
|
||||
element.append(html);
|
||||
|
||||
// Add a callback for when the filter tag selection is changed
|
||||
@ -357,7 +353,7 @@ function setupFilterList(tableKey, table, target) {
|
||||
});
|
||||
|
||||
// Add callback for deleting each filter
|
||||
element.find(".close").click(function() {
|
||||
element.find('.close').click(function() {
|
||||
var me = $(this);
|
||||
|
||||
var filter = me.attr(`filter-tag-${tableKey}`);
|
||||
|
@ -312,58 +312,58 @@ function constructForm(url, options) {
|
||||
*/
|
||||
|
||||
switch (options.method) {
|
||||
case 'POST':
|
||||
if (canCreate(OPTIONS)) {
|
||||
constructCreateForm(OPTIONS.actions.POST, options);
|
||||
} else {
|
||||
// User does not have permission to POST to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Create operation not allowed" %}'
|
||||
);
|
||||
console.log(`'POST action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
case 'PUT':
|
||||
case 'PATCH':
|
||||
if (canChange(OPTIONS)) {
|
||||
constructChangeForm(OPTIONS.actions.PUT, options);
|
||||
} else {
|
||||
// User does not have permission to PUT/PATCH to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Update operation not allowed" %}'
|
||||
);
|
||||
console.log(`${options.method} action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
case 'DELETE':
|
||||
if (canDelete(OPTIONS)) {
|
||||
constructDeleteForm(OPTIONS.actions.DELETE, options);
|
||||
} else {
|
||||
// User does not have permission to DELETE to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Delete operation not allowed" %}'
|
||||
);
|
||||
console.log(`DELETE action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
case 'GET':
|
||||
if (canView(OPTIONS)) {
|
||||
// TODO?
|
||||
} else {
|
||||
// User does not have permission to GET to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "View operation not allowed" %}'
|
||||
);
|
||||
console.log(`GET action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.log(`constructForm() called with invalid method '${options.method}'`);
|
||||
break;
|
||||
case 'POST':
|
||||
if (canCreate(OPTIONS)) {
|
||||
constructCreateForm(OPTIONS.actions.POST, options);
|
||||
} else {
|
||||
// User does not have permission to POST to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Create operation not allowed" %}'
|
||||
);
|
||||
console.log(`'POST action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
case 'PUT':
|
||||
case 'PATCH':
|
||||
if (canChange(OPTIONS)) {
|
||||
constructChangeForm(OPTIONS.actions.PUT, options);
|
||||
} else {
|
||||
// User does not have permission to PUT/PATCH to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Update operation not allowed" %}'
|
||||
);
|
||||
console.log(`${options.method} action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
case 'DELETE':
|
||||
if (canDelete(OPTIONS)) {
|
||||
constructDeleteForm(OPTIONS.actions.DELETE, options);
|
||||
} else {
|
||||
// User does not have permission to DELETE to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Delete operation not allowed" %}'
|
||||
);
|
||||
console.log(`DELETE action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
case 'GET':
|
||||
if (canView(OPTIONS)) {
|
||||
// TODO?
|
||||
} else {
|
||||
// User does not have permission to GET to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "View operation not allowed" %}'
|
||||
);
|
||||
console.log(`GET action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.log(`constructForm() called with invalid method '${options.method}'`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -402,7 +402,7 @@ function constructFormBody(fields, options) {
|
||||
}
|
||||
|
||||
// Provide each field object with its own name
|
||||
for(field in fields) {
|
||||
for (field in fields) {
|
||||
fields[field].name = field;
|
||||
|
||||
// If any "instance_filters" are defined for the endpoint, copy them across (overwrite)
|
||||
@ -460,11 +460,11 @@ function constructFormBody(fields, options) {
|
||||
var field = fields[field_name];
|
||||
|
||||
switch (field.type) {
|
||||
// Skip field types which are simply not supported
|
||||
case 'nested object':
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
// Skip field types which are simply not supported
|
||||
case 'nested object':
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
html += constructField(field_name, field, options);
|
||||
@ -674,13 +674,13 @@ function submitFormData(fields, options) {
|
||||
error: function(xhr) {
|
||||
|
||||
switch (xhr.status) {
|
||||
case 400: // Bad request
|
||||
handleFormErrors(xhr.responseJSON, fields, options);
|
||||
break;
|
||||
default:
|
||||
$(options.modal).modal('hide');
|
||||
showApiError(xhr);
|
||||
break;
|
||||
case 400:
|
||||
handleFormErrors(xhr.responseJSON, fields, options);
|
||||
break;
|
||||
default:
|
||||
$(options.modal).modal('hide');
|
||||
showApiError(xhr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -726,22 +726,22 @@ function updateFieldValue(name, value, field, options) {
|
||||
var el = $(options.modal).find(`#id_${name}`);
|
||||
|
||||
switch (field.type) {
|
||||
case 'boolean':
|
||||
el.prop('checked', value);
|
||||
break;
|
||||
case 'related field':
|
||||
// Clear?
|
||||
if (value == null && !field.required) {
|
||||
el.val(null).trigger('change');
|
||||
}
|
||||
// TODO - Specify an actual value!
|
||||
break;
|
||||
case 'file upload':
|
||||
case 'image upload':
|
||||
break;
|
||||
default:
|
||||
el.val(value);
|
||||
break;
|
||||
case 'boolean':
|
||||
el.prop('checked', value);
|
||||
break;
|
||||
case 'related field':
|
||||
// Clear?
|
||||
if (value == null && !field.required) {
|
||||
el.val(null).trigger('change');
|
||||
}
|
||||
// TODO - Specify an actual value!
|
||||
break;
|
||||
case 'file upload':
|
||||
case 'image upload':
|
||||
break;
|
||||
default:
|
||||
el.val(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,21 +766,21 @@ function getFormFieldValue(name, field, options) {
|
||||
var value = null;
|
||||
|
||||
switch (field.type) {
|
||||
case 'boolean':
|
||||
value = el.is(":checked");
|
||||
break;
|
||||
case 'date':
|
||||
case 'datetime':
|
||||
value = el.val();
|
||||
case 'boolean':
|
||||
value = el.is(':checked');
|
||||
break;
|
||||
case 'date':
|
||||
case 'datetime':
|
||||
value = el.val();
|
||||
|
||||
// Ensure empty values are sent as nulls
|
||||
if (!value || value.length == 0) {
|
||||
value = null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
value = el.val();
|
||||
break;
|
||||
// Ensure empty values are sent as nulls
|
||||
if (!value || value.length == 0) {
|
||||
value = null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
value = el.val();
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -808,19 +808,19 @@ function handleFormSuccess(response, options) {
|
||||
|
||||
// Display any messages
|
||||
if (response && response.success) {
|
||||
showAlertOrCache("alert-success", response.success, cache);
|
||||
showAlertOrCache('alert-success', response.success, cache);
|
||||
}
|
||||
|
||||
if (response && response.info) {
|
||||
showAlertOrCache("alert-info", response.info, cache);
|
||||
showAlertOrCache('alert-info', response.info, cache);
|
||||
}
|
||||
|
||||
if (response && response.warning) {
|
||||
showAlertOrCache("alert-warning", response.warning, cache);
|
||||
showAlertOrCache('alert-warning', response.warning, cache);
|
||||
}
|
||||
|
||||
if (response && response.danger) {
|
||||
showAlertOrCache("alert-danger", response.danger, cache);
|
||||
showAlertOrCache('alert-danger', response.danger, cache);
|
||||
}
|
||||
|
||||
if (options.onSuccess) {
|
||||
@ -1041,9 +1041,9 @@ function initializeGroups(fields, options) {
|
||||
var group_options = options.groups[group];
|
||||
|
||||
if (group_options.collapsed) {
|
||||
$(modal).find(`#form-panel-content-${group}`).collapse("hide");
|
||||
$(modal).find(`#form-panel-content-${group}`).collapse('hide');
|
||||
} else {
|
||||
$(modal).find(`#form-panel-content-${group}`).collapse("show");
|
||||
$(modal).find(`#form-panel-content-${group}`).collapse('show');
|
||||
}
|
||||
|
||||
if (group_options.hidden) {
|
||||
@ -1084,14 +1084,14 @@ function initializeRelatedFields(fields, options) {
|
||||
if (!field || field.hidden) continue;
|
||||
|
||||
switch (field.type) {
|
||||
case 'related field':
|
||||
initializeRelatedField(field, fields, options);
|
||||
break;
|
||||
case 'choice':
|
||||
initializeChoiceField(field, fields, options);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'related field':
|
||||
initializeRelatedField(field, fields, options);
|
||||
break;
|
||||
case 'choice':
|
||||
initializeChoiceField(field, fields, options);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1130,7 +1130,7 @@ function addSecondaryModal(field, fields, options) {
|
||||
if (secondary.fields instanceof Function) {
|
||||
|
||||
// Extract form values at time of button press
|
||||
var data = extractFormData(fields, options)
|
||||
var data = extractFormData(fields, options);
|
||||
|
||||
secondary.fields = secondary.fields(data);
|
||||
}
|
||||
@ -1397,41 +1397,41 @@ function renderModelData(name, model, data, parameters, options) {
|
||||
|
||||
// Find a custom renderer
|
||||
switch (model) {
|
||||
case 'company':
|
||||
renderer = renderCompany;
|
||||
break;
|
||||
case 'stockitem':
|
||||
renderer = renderStockItem;
|
||||
break;
|
||||
case 'stocklocation':
|
||||
renderer = renderStockLocation;
|
||||
break;
|
||||
case 'part':
|
||||
renderer = renderPart;
|
||||
break;
|
||||
case 'partcategory':
|
||||
renderer = renderPartCategory;
|
||||
break;
|
||||
case 'partparametertemplate':
|
||||
renderer = renderPartParameterTemplate;
|
||||
break;
|
||||
case 'manufacturerpart':
|
||||
renderer = renderManufacturerPart;
|
||||
break;
|
||||
case 'supplierpart':
|
||||
renderer = renderSupplierPart;
|
||||
break;
|
||||
case 'build':
|
||||
renderer = renderBuild;
|
||||
break;
|
||||
case 'owner':
|
||||
renderer = renderOwner;
|
||||
break;
|
||||
case 'user':
|
||||
renderer = renderUser;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'company':
|
||||
renderer = renderCompany;
|
||||
break;
|
||||
case 'stockitem':
|
||||
renderer = renderStockItem;
|
||||
break;
|
||||
case 'stocklocation':
|
||||
renderer = renderStockLocation;
|
||||
break;
|
||||
case 'part':
|
||||
renderer = renderPart;
|
||||
break;
|
||||
case 'partcategory':
|
||||
renderer = renderPartCategory;
|
||||
break;
|
||||
case 'partparametertemplate':
|
||||
renderer = renderPartParameterTemplate;
|
||||
break;
|
||||
case 'manufacturerpart':
|
||||
renderer = renderManufacturerPart;
|
||||
break;
|
||||
case 'supplierpart':
|
||||
renderer = renderSupplierPart;
|
||||
break;
|
||||
case 'build':
|
||||
renderer = renderBuild;
|
||||
break;
|
||||
case 'owner':
|
||||
renderer = renderOwner;
|
||||
break;
|
||||
case 'user':
|
||||
renderer = renderUser;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (renderer != null) {
|
||||
@ -1552,18 +1552,18 @@ function constructField(name, parameters, options) {
|
||||
// Some fields can have 'clear' inputs associated with them
|
||||
if (!parameters.required && !parameters.read_only) {
|
||||
switch (parameters.type) {
|
||||
case 'string':
|
||||
case 'url':
|
||||
case 'email':
|
||||
case 'integer':
|
||||
case 'float':
|
||||
case 'decimal':
|
||||
case 'related field':
|
||||
case 'date':
|
||||
extra = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'string':
|
||||
case 'url':
|
||||
case 'email':
|
||||
case 'integer':
|
||||
case 'float':
|
||||
case 'decimal':
|
||||
case 'related field':
|
||||
case 'date':
|
||||
extra = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1586,7 +1586,7 @@ function constructField(name, parameters, options) {
|
||||
</span>`;
|
||||
}
|
||||
|
||||
html += `</div>`; // input-group
|
||||
html += `</div>`; // input-group
|
||||
}
|
||||
|
||||
if (parameters.help_text) {
|
||||
@ -1597,8 +1597,8 @@ function constructField(name, parameters, options) {
|
||||
html += `<div id='errors-${name}'></div>`;
|
||||
|
||||
|
||||
html += `</div>`; // controls
|
||||
html += `</div>`; // form-group
|
||||
html += `</div>`; // controls
|
||||
html += `</div>`; // form-group
|
||||
|
||||
if (parameters.after) {
|
||||
html += parameters.after;
|
||||
@ -1656,39 +1656,39 @@ function constructInput(name, parameters, options) {
|
||||
var func = null;
|
||||
|
||||
switch (parameters.type) {
|
||||
case 'boolean':
|
||||
func = constructCheckboxInput;
|
||||
break;
|
||||
case 'string':
|
||||
case 'url':
|
||||
case 'email':
|
||||
func = constructTextInput;
|
||||
break;
|
||||
case 'integer':
|
||||
case 'float':
|
||||
case 'decimal':
|
||||
func = constructNumberInput;
|
||||
break;
|
||||
case 'choice':
|
||||
func = constructChoiceInput;
|
||||
break;
|
||||
case 'related field':
|
||||
func = constructRelatedFieldInput;
|
||||
break;
|
||||
case 'image upload':
|
||||
case 'file upload':
|
||||
func = constructFileUploadInput;
|
||||
break;
|
||||
case 'date':
|
||||
func = constructDateInput;
|
||||
break;
|
||||
case 'candy':
|
||||
func = constructCandyInput;
|
||||
break;
|
||||
default:
|
||||
// Unsupported field type!
|
||||
break;
|
||||
}
|
||||
case 'boolean':
|
||||
func = constructCheckboxInput;
|
||||
break;
|
||||
case 'string':
|
||||
case 'url':
|
||||
case 'email':
|
||||
func = constructTextInput;
|
||||
break;
|
||||
case 'integer':
|
||||
case 'float':
|
||||
case 'decimal':
|
||||
func = constructNumberInput;
|
||||
break;
|
||||
case 'choice':
|
||||
func = constructChoiceInput;
|
||||
break;
|
||||
case 'related field':
|
||||
func = constructRelatedFieldInput;
|
||||
break;
|
||||
case 'image upload':
|
||||
case 'file upload':
|
||||
func = constructFileUploadInput;
|
||||
break;
|
||||
case 'date':
|
||||
func = constructDateInput;
|
||||
break;
|
||||
case 'candy':
|
||||
func = constructCandyInput;
|
||||
break;
|
||||
default:
|
||||
// Unsupported field type!
|
||||
break;
|
||||
}
|
||||
|
||||
if (func != null) {
|
||||
html = func(name, parameters, options);
|
||||
@ -1804,18 +1804,18 @@ function constructTextInput(name, parameters) {
|
||||
var type = '';
|
||||
|
||||
switch (parameters.type) {
|
||||
default:
|
||||
classes = 'textinput textInput form-control';
|
||||
type = 'text';
|
||||
break;
|
||||
case 'url':
|
||||
classes = 'urlinput form-control';
|
||||
type = 'url';
|
||||
break;
|
||||
case 'email':
|
||||
classes = 'emailinput form-control';
|
||||
type = 'email';
|
||||
break;
|
||||
default:
|
||||
classes = 'textinput textInput form-control';
|
||||
type = 'text';
|
||||
break;
|
||||
case 'url':
|
||||
classes = 'urlinput form-control';
|
||||
type = 'url';
|
||||
break;
|
||||
case 'email':
|
||||
classes = 'emailinput form-control';
|
||||
type = 'email';
|
||||
break;
|
||||
}
|
||||
|
||||
return constructInputOptions(
|
||||
@ -1947,4 +1947,4 @@ function constructHelpText(name, parameters) {
|
||||
var html = `<div id='hint_id_${name}' ${style}class='help-block'><i>${parameters.help_text}</i></div>`;
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ function yesNoLabel(value) {
|
||||
|
||||
|
||||
function editButton(url, text='{% trans "Edit" %}') {
|
||||
return "<button class='btn btn-success edit-button btn-sm' type='button' url='" + url + "'>" + text + "</button>";
|
||||
return `<button class='btn btn-success edit-button btn-sm' type='button' url='${url}'>${text}</button>`;
|
||||
}
|
||||
|
||||
|
||||
function deleteButton(url, text='{% trans "Delete" %}') {
|
||||
return "<button class='btn btn-danger delete-button btn-sm' type='button' url='" + url + "'>" + text + "</button>";
|
||||
return `<button class='btn btn-danger delete-button btn-sm' type='button' url='${url}'>${text}</button>`;
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ function makeIconButton(icon, cls, pk, title, options={}) {
|
||||
var extraProps = '';
|
||||
|
||||
if (options.disabled) {
|
||||
extraProps += "disabled='true' ";
|
||||
extraProps += `disabled='true' `;
|
||||
}
|
||||
|
||||
html += `<button pk='${pk}' id='${id}' class='${classes}' title='${title}' ${extraProps}>`;
|
||||
@ -184,4 +184,4 @@ function renderLink(text, url, options={}) {
|
||||
}
|
||||
|
||||
return `<a href="${url}">${text}</a>`;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ function printStockLocationLabels(locations) {
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ function createNewModal(options={}) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
// Simulate a click on the 'Submit' button
|
||||
$(modal_name).find("#modal-form-submit").click();
|
||||
$(modal_name).find('#modal-form-submit').click();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -271,7 +271,7 @@ function reloadFieldOptions(fieldName, options) {
|
||||
setFieldOptions(fieldName, opts);
|
||||
},
|
||||
error: function() {
|
||||
console.log("Error GETting field options");
|
||||
console.log('Error GETting field options');
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -290,7 +290,7 @@ function enableField(fieldName, enabled, options={}) {
|
||||
|
||||
var field = getFieldByName(modal, fieldName);
|
||||
|
||||
field.prop("disabled", !enabled);
|
||||
field.prop('disabled', !enabled);
|
||||
}
|
||||
|
||||
function clearField(fieldName, options={}) {
|
||||
@ -361,7 +361,7 @@ function attachToggle(modal) {
|
||||
* and also larger toggle style buttons are easier to press!
|
||||
*/
|
||||
|
||||
$(modal).find("input[type='checkbox']").each(function() {
|
||||
$(modal).find(`input[type='checkbox']`).each(function() {
|
||||
$(this).bootstrapToggle({
|
||||
size: 'small',
|
||||
onstyle: 'success',
|
||||
@ -376,7 +376,7 @@ function attachSelect(modal) {
|
||||
* Provides search filtering for dropdown items
|
||||
*/
|
||||
|
||||
$(modal + ' .select').select2({
|
||||
$(modal + ' .select').select2({
|
||||
dropdownParent: $(modal),
|
||||
// dropdownAutoWidth parameter is required to work properly with modal forms
|
||||
dropdownAutoWidth: false,
|
||||
@ -394,7 +394,7 @@ function loadingMessageContent() {
|
||||
*/
|
||||
|
||||
// TODO - This can be made a lot better
|
||||
return "<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> {% trans 'Waiting for server...' %}";
|
||||
return `<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> {% trans 'Waiting for server...' %}`;
|
||||
}
|
||||
|
||||
|
||||
@ -409,26 +409,26 @@ function afterForm(response, options) {
|
||||
* - Reload the page
|
||||
*/
|
||||
|
||||
// Should we show alerts immediately or cache them?
|
||||
// Should we show alerts immediately or cache them?
|
||||
var cache = (options.follow && response.url) ||
|
||||
options.redirect ||
|
||||
options.reload;
|
||||
|
||||
// Display any messages
|
||||
if (response.success) {
|
||||
showAlertOrCache("alert-success", response.success, cache);
|
||||
showAlertOrCache('alert-success', response.success, cache);
|
||||
}
|
||||
|
||||
if (response.info) {
|
||||
showAlertOrCache("alert-info", response.info, cache);
|
||||
showAlertOrCache('alert-info', response.info, cache);
|
||||
}
|
||||
|
||||
if (response.warning) {
|
||||
showAlertOrCache("alert-warning", response.warning, cache);
|
||||
showAlertOrCache('alert-warning', response.warning, cache);
|
||||
}
|
||||
|
||||
if (response.danger) {
|
||||
showAlertOrCache("alert-danger", response.danger, cache);
|
||||
showAlertOrCache('alert-danger', response.danger, cache);
|
||||
}
|
||||
|
||||
// Was a callback provided?
|
||||
@ -612,7 +612,7 @@ function showQuestionDialog(title, content, options={}) {
|
||||
|
||||
modalSetContent(modal, content);
|
||||
|
||||
$(modal).on('click', "#modal-form-submit", function() {
|
||||
$(modal).on('click', '#modal-form-submit', function() {
|
||||
$(modal).modal('hide');
|
||||
|
||||
if (options.accept) {
|
||||
@ -653,7 +653,7 @@ function openModal(options) {
|
||||
event.preventDefault();
|
||||
|
||||
// Simulate a click on the 'Submit' button
|
||||
$(modal).find("#modal-form-submit").click();
|
||||
$(modal).find('#modal-form-submit').click();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -715,17 +715,17 @@ function insertNewItemButton(modal, options) {
|
||||
* Inserts a button at the end of this lael element.
|
||||
*/
|
||||
|
||||
var html = "<span style='float: right;'>";
|
||||
var html = `<span style='float: right;'>`;
|
||||
|
||||
html += "<div type='button' class='btn btn-primary btn-secondary'";
|
||||
html += `<div type='button' class='btn btn-primary btn-secondary'`;
|
||||
|
||||
if (options.title) {
|
||||
html += " title='" + options.title + "'";
|
||||
html += ` title='${ options.title}'`;
|
||||
}
|
||||
|
||||
html += " id='btn-new-" + options.field + "'>" + options.label + "</div>";
|
||||
html += ` id='btn-new-${options.field}'>${options.label}</div>`;
|
||||
|
||||
html += "</span>";
|
||||
html += '</span>';
|
||||
|
||||
$(modal).find('label[for="id_'+ options.field + '"]').append(html);
|
||||
}
|
||||
@ -750,7 +750,7 @@ function attachSecondaryModal(modal, options) {
|
||||
var data = options.data || {};
|
||||
|
||||
// Add a callback to the button
|
||||
$(modal).find("#btn-new-" + options.field).on('click', function() {
|
||||
$(modal).find('#btn-new-' + options.field).on('click', function() {
|
||||
|
||||
// Launch the secondary modal
|
||||
launchModalForm(
|
||||
@ -791,12 +791,14 @@ function attachSecondaries(modal, secondaries) {
|
||||
}
|
||||
|
||||
function insertActionButton(modal, options) {
|
||||
/* Insert a custom submition button */
|
||||
/* Insert a custom submission button */
|
||||
|
||||
var html = "<span style='float: right;'>";
|
||||
html += "<button name='" + options.name + "' type='submit' class='btn btn-default modal-form-button'";
|
||||
html += " value='" + options.name + "'>" + options.title + "</button>";
|
||||
html += "</span>";
|
||||
var html = `
|
||||
<span style='float: right;'>
|
||||
<button name='${options.name}' type='submit' class='btn btn-default modal-form-button' value='${options.name}'>
|
||||
${options.title}
|
||||
</button>
|
||||
</span>`;
|
||||
|
||||
$(modal).find('#modal-footer-buttons').append(html);
|
||||
}
|
||||
@ -819,8 +821,8 @@ function attachFieldCallback(modal, callback) {
|
||||
* - action: A function to perform
|
||||
*/
|
||||
|
||||
// Find the field input in the form
|
||||
var field = getFieldByName(modal, callback.field);
|
||||
// Find the field input in the form
|
||||
var field = getFieldByName(modal, callback.field);
|
||||
|
||||
field.change(function() {
|
||||
|
||||
@ -932,7 +934,7 @@ function handleModalForm(url, options) {
|
||||
showAlertDialog('{% trans "Error posting form data" %}', renderErrorMessage(xhr));
|
||||
},
|
||||
complete: function() {
|
||||
//TODO
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -976,7 +978,7 @@ function launchModalForm(url, options = {}) {
|
||||
url: url,
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
beforeSend: function() {
|
||||
openModal({
|
||||
modal: modal,
|
||||
submit_text: submit_text,
|
||||
@ -1029,7 +1031,7 @@ function launchModalForm(url, options = {}) {
|
||||
showAlertDialog('{% trans "Invalid server response" %}', '{% trans "JSON response missing form data" %}');
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
error: function(xhr) {
|
||||
|
||||
$(modal).modal('hide');
|
||||
|
||||
@ -1068,8 +1070,8 @@ function launchModalForm(url, options = {}) {
|
||||
showAlertDialog('{% trans "Error requesting form data" %}', renderErrorMessage(xhr));
|
||||
}
|
||||
|
||||
console.log("Modal form error: " + xhr.status);
|
||||
console.log("Message: " + xhr.responseText);
|
||||
console.log('Modal form error: ' + xhr.status);
|
||||
console.log('Message: ' + xhr.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1118,4 +1120,4 @@ function showModalImage(image_url) {
|
||||
modal.click(function() {
|
||||
hideModalImage();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -142,14 +142,14 @@ function renderOwner(name, data, parameters, options) {
|
||||
var html = `<span>${data.name}</span>`;
|
||||
|
||||
switch (data.label) {
|
||||
case 'user':
|
||||
html += `<span class='float-right fas fa-user'></span>`;
|
||||
break;
|
||||
case 'group':
|
||||
html += `<span class='float-right fas fa-users'></span>`;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'user':
|
||||
html += `<span class='float-right fas fa-user'></span>`;
|
||||
break;
|
||||
case 'group':
|
||||
html += `<span class='float-right fas fa-users'></span>`;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return html;
|
||||
|
@ -170,7 +170,7 @@ function newSupplierPartFromOrderWizard(e) {
|
||||
|
||||
if (response.supplier_detail) {
|
||||
text += response.supplier_detail.name;
|
||||
text += " | ";
|
||||
text += ' | ';
|
||||
}
|
||||
|
||||
text += response.SKU;
|
||||
@ -180,8 +180,7 @@ function newSupplierPartFromOrderWizard(e) {
|
||||
$('#modal-form').find(dropdown).append(option).trigger('change');
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -230,7 +229,7 @@ function newPurchaseOrderFromOrderWizard(e) {
|
||||
$('#modal-form').find(dropdown).append(option).trigger('change');
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -275,7 +274,7 @@ function loadPurchaseOrderTable(table, options) {
|
||||
|
||||
options.params['supplier_detail'] = true;
|
||||
|
||||
var filters = loadTableFilters("purchaseorder");
|
||||
var filters = loadTableFilters('purchaseorder');
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
@ -283,7 +282,7 @@ function loadPurchaseOrderTable(table, options) {
|
||||
|
||||
options.url = options.url || '{% url "api-po-list" %}';
|
||||
|
||||
setupFilterList("purchaseorder", $(table));
|
||||
setupFilterList('purchaseorder', $(table));
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: options.url,
|
||||
@ -373,7 +372,7 @@ function loadSalesOrderTable(table, options) {
|
||||
options.params = options.params || {};
|
||||
options.params['customer_detail'] = true;
|
||||
|
||||
var filters = loadTableFilters("salesorder");
|
||||
var filters = loadTableFilters('salesorder');
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
@ -381,7 +380,7 @@ function loadSalesOrderTable(table, options) {
|
||||
|
||||
options.url = options.url || '{% url "api-so-list" %}';
|
||||
|
||||
setupFilterList("salesorder", $(table));
|
||||
setupFilterList('salesorder', $(table));
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: options.url,
|
||||
@ -490,13 +489,13 @@ function loadSalesOrderAllocationTable(table, options={}) {
|
||||
options.params['item_detail'] = true;
|
||||
options.params['order_detail'] = true;
|
||||
|
||||
var filters = loadTableFilters("salesorderallocation");
|
||||
var filters = loadTableFilters('salesorderallocation');
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
}
|
||||
|
||||
setupFilterList("salesorderallocation", $(table));
|
||||
setupFilterList('salesorderallocation', $(table));
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: '{% url "api-so-allocation-list" %}',
|
||||
@ -562,4 +561,4 @@ function loadSalesOrderAllocationTable(table, options={}) {
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ function partGroups() {
|
||||
collapsible: true,
|
||||
hidden: !global_settings.PART_PURCHASEABLE,
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Construct fieldset for part forms
|
||||
function partFields(options={}) {
|
||||
|
||||
@ -143,14 +143,14 @@ function partFields(options={}) {
|
||||
|
||||
// Pop expiry field
|
||||
if (!global_settings.STOCK_ENABLE_EXPIRY) {
|
||||
delete fields["default_expiry"];
|
||||
delete fields['default_expiry'];
|
||||
}
|
||||
|
||||
// Additional fields when "creating" a new part
|
||||
if (options.create) {
|
||||
|
||||
// No supplier parts available yet
|
||||
delete fields["default_supplier"];
|
||||
delete fields['default_supplier'];
|
||||
|
||||
if (global_settings.PART_CREATE_INITIAL) {
|
||||
|
||||
@ -446,13 +446,13 @@ function loadPartVariantTable(table, partId, options={}) {
|
||||
params.ancestor = partId;
|
||||
|
||||
// Load filters
|
||||
var filters = loadTableFilters("variants");
|
||||
var filters = loadTableFilters('variants');
|
||||
|
||||
for (var key in params) {
|
||||
filters[key] = params[key];
|
||||
}
|
||||
|
||||
setupFilterList("variants", $(table));
|
||||
setupFilterList('variants', $(table));
|
||||
|
||||
var cols = [
|
||||
{
|
||||
@ -534,7 +534,7 @@ function loadPartVariantTable(table, partId, options={}) {
|
||||
];
|
||||
|
||||
table.inventreeTable({
|
||||
url: "{% url 'api-part-list' %}",
|
||||
url: '{% url "api-part-list" %}',
|
||||
name: 'partvariants',
|
||||
showColumns: true,
|
||||
original: params,
|
||||
@ -575,7 +575,7 @@ function loadPartParameterTable(table, url, options) {
|
||||
var params = options.params || {};
|
||||
|
||||
// Load filters
|
||||
var filters = loadTableFilters("part-parameters");
|
||||
var filters = loadTableFilters('part-parameters');
|
||||
|
||||
for (var key in params) {
|
||||
filters[key] = params[key];
|
||||
@ -682,8 +682,8 @@ function loadParametricPartTable(table, options={}) {
|
||||
* - table_data: Parameters data
|
||||
*/
|
||||
|
||||
var table_headers = options.headers
|
||||
var table_data = options.data
|
||||
var table_headers = options.headers;
|
||||
var table_data = options.data;
|
||||
|
||||
var columns = [];
|
||||
|
||||
@ -719,8 +719,6 @@ function loadParametricPartTable(table, options={}) {
|
||||
title: header,
|
||||
sortable: true,
|
||||
filterControl: 'input',
|
||||
/* TODO: Search icons are not displayed */
|
||||
/*clear: 'fa-times icon-red',*/
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -822,14 +820,14 @@ function loadPartTable(table, url, options={}) {
|
||||
var col = null;
|
||||
|
||||
if (!options.disableFilters) {
|
||||
filters = loadTableFilters("parts");
|
||||
filters = loadTableFilters('parts');
|
||||
}
|
||||
|
||||
for (var key in params) {
|
||||
filters[key] = params[key];
|
||||
}
|
||||
|
||||
setupFilterList("parts", $(table), options.filterTarget || null);
|
||||
setupFilterList('parts', $(table), options.filterTarget || null);
|
||||
|
||||
var columns = [
|
||||
{
|
||||
@ -891,7 +889,7 @@ function loadPartTable(table, url, options={}) {
|
||||
|
||||
return display;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!options.params.ordering) {
|
||||
col['sortable'] = true;
|
||||
@ -905,7 +903,7 @@ function loadPartTable(table, url, options={}) {
|
||||
formatter: function(value, row) {
|
||||
|
||||
if (row.is_template) {
|
||||
value = '<i>' + value + '</i>';
|
||||
value = `<i>${value}</i>`;
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -918,7 +916,7 @@ function loadPartTable(table, url, options={}) {
|
||||
title: '{% trans "Category" %}',
|
||||
formatter: function(value, row) {
|
||||
if (row.category) {
|
||||
return renderLink(value.pathstring, "/part/category/" + row.category + "/");
|
||||
return renderLink(value.pathstring, `/part/category/${row.category}/`);
|
||||
} else {
|
||||
return '{% trans "No category" %}';
|
||||
}
|
||||
@ -936,30 +934,30 @@ function loadPartTable(table, url, options={}) {
|
||||
title: '{% trans "Stock" %}',
|
||||
searchable: false,
|
||||
formatter: function(value, row) {
|
||||
var link = "stock";
|
||||
var link = 'stock';
|
||||
|
||||
if (value) {
|
||||
// There IS stock available for this part
|
||||
|
||||
// Is stock "low" (below the 'minimum_stock' quantity)?
|
||||
if (row.minimum_stock && row.minimum_stock > value) {
|
||||
value += "<span class='label label-right label-warning'>{% trans "Low stock" %}</span>";
|
||||
value += `<span class='label label-right label-warning'>{% trans "Low stock" %}</span>`;
|
||||
}
|
||||
|
||||
} else if (row.on_order) {
|
||||
// There is no stock available, but stock is on order
|
||||
value = "0<span class='label label-right label-primary'>{% trans "On Order" %}: " + row.on_order + "</span>";
|
||||
link = "orders";
|
||||
value = `0<span class='label label-right label-primary'>{% trans "On Order" %}: ${row.on_order}</span>`;
|
||||
link = 'orders';
|
||||
} else if (row.building) {
|
||||
// There is no stock available, but stock is being built
|
||||
value = "0<span class='label label-right label-info'>{% trans "Building" %}: " + row.building + "</span>";
|
||||
link = "builds";
|
||||
value = `0<span class='label label-right label-info'>{% trans "Building" %}: ${row.building}</span>`;
|
||||
link = 'builds';
|
||||
} else {
|
||||
// There is no stock available
|
||||
value = "0<span class='label label-right label-danger'>{% trans "No Stock" %}</span>";
|
||||
value = `0<span class='label label-right label-danger'>{% trans "No Stock" %}</span>`;
|
||||
}
|
||||
|
||||
return renderLink(value, '/part/' + row.pk + "/" + link + "/");
|
||||
return renderLink(value, `/part/${row.pk}/${link}/`);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1027,8 +1025,8 @@ function loadPartTable(table, url, options={}) {
|
||||
|
||||
/* Button callbacks for part table buttons */
|
||||
|
||||
$("#multi-part-order").click(function() {
|
||||
var selections = $(table).bootstrapTable("getSelections");
|
||||
$('#multi-part-order').click(function() {
|
||||
var selections = $(table).bootstrapTable('getSelections');
|
||||
|
||||
var parts = [];
|
||||
|
||||
@ -1036,15 +1034,15 @@ function loadPartTable(table, url, options={}) {
|
||||
parts.push(item.pk);
|
||||
});
|
||||
|
||||
launchModalForm("/order/purchase-order/order-parts/", {
|
||||
launchModalForm('/order/purchase-order/order-parts/', {
|
||||
data: {
|
||||
parts: parts,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$("#multi-part-category").click(function() {
|
||||
var selections = $(table).bootstrapTable("getSelections");
|
||||
$('#multi-part-category').click(function() {
|
||||
var selections = $(table).bootstrapTable('getSelections');
|
||||
|
||||
var parts = [];
|
||||
|
||||
@ -1052,7 +1050,7 @@ function loadPartTable(table, url, options={}) {
|
||||
parts.push(item.pk);
|
||||
});
|
||||
|
||||
launchModalForm("/part/set-category/", {
|
||||
launchModalForm('/part/set-category/', {
|
||||
data: {
|
||||
parts: parts,
|
||||
},
|
||||
@ -1073,7 +1071,7 @@ function loadPartTable(table, url, options={}) {
|
||||
});
|
||||
|
||||
$('#multi-part-export').click(function() {
|
||||
var selections = $(table).bootstrapTable("getSelections");
|
||||
var selections = $(table).bootstrapTable('getSelections');
|
||||
|
||||
var parts = '';
|
||||
|
||||
@ -1172,7 +1170,7 @@ function loadPartTestTemplateTable(table, options) {
|
||||
|
||||
var filterListElement = options.filterList || '#filter-list-parttests';
|
||||
|
||||
var filters = loadTableFilters("parttests");
|
||||
var filters = loadTableFilters('parttests');
|
||||
|
||||
var original = {};
|
||||
|
||||
@ -1180,7 +1178,7 @@ function loadPartTestTemplateTable(table, options) {
|
||||
original[k] = params[k];
|
||||
}
|
||||
|
||||
setupFilterList("parttests", table, filterListElement);
|
||||
setupFilterList('parttests', table, filterListElement);
|
||||
|
||||
// Override the default values, or add new ones
|
||||
for (var key in params) {
|
||||
@ -1192,7 +1190,7 @@ function loadPartTestTemplateTable(table, options) {
|
||||
formatNoMatches: function() {
|
||||
return '{% trans "No test templates matching query" %}';
|
||||
},
|
||||
url: "{% url 'api-part-test-template-list' %}",
|
||||
url: '{% url "api-part-test-template-list" %}',
|
||||
queryParams: filters,
|
||||
name: 'testtemplate',
|
||||
original: original,
|
||||
@ -1213,7 +1211,7 @@ function loadPartTestTemplateTable(table, options) {
|
||||
},
|
||||
{
|
||||
field: 'required',
|
||||
title: "{% trans 'Required' %}",
|
||||
title: '{% trans "Required" %}',
|
||||
sortable: true,
|
||||
formatter: function(value) {
|
||||
return yesNoLabel(value);
|
||||
@ -1280,28 +1278,29 @@ function loadPriceBreakTable(table, options) {
|
||||
onLoadSuccess: function(tableData) {
|
||||
if (linkedGraph) {
|
||||
// sort array
|
||||
tableData = tableData.sort((a,b)=>a.quantity-b.quantity);
|
||||
tableData = tableData.sort((a, b) => (a.quantity - b.quantity));
|
||||
|
||||
// split up for graph definition
|
||||
var graphLabels = Array.from(tableData, x => x.quantity);
|
||||
var graphData = Array.from(tableData, x => x.price);
|
||||
var graphLabels = Array.from(tableData, (x) => (x.quantity));
|
||||
var graphData = Array.from(tableData, (x) => (x.price));
|
||||
|
||||
// destroy chart if exists
|
||||
if (chart){
|
||||
if (chart) {
|
||||
chart.destroy();
|
||||
}
|
||||
chart = loadLineChart(linkedGraph,
|
||||
{
|
||||
labels: graphLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: '{% trans "Unit Price" %}',
|
||||
data: graphData,
|
||||
backgroundColor: 'rgba(255, 206, 86, 0.2)',
|
||||
borderColor: 'rgb(255, 206, 86)',
|
||||
stepped: true,
|
||||
fill: true,
|
||||
},]
|
||||
datasets: [
|
||||
{
|
||||
label: '{% trans "Unit Price" %}',
|
||||
data: graphData,
|
||||
backgroundColor: 'rgba(255, 206, 86, 0.2)',
|
||||
borderColor: 'rgb(255, 206, 86)',
|
||||
stepped: true,
|
||||
fill: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -1325,7 +1324,7 @@ function loadPriceBreakTable(table, options) {
|
||||
formatter: function(value, row) {
|
||||
var html = value;
|
||||
|
||||
html += `<div class='btn-group float-right' role='group'>`
|
||||
html += `<div class='btn-group float-right' role='group'>`;
|
||||
|
||||
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}" %}`);
|
||||
@ -1375,8 +1374,8 @@ function initPriceBreakSet(table, options) {
|
||||
}
|
||||
);
|
||||
|
||||
function reloadPriceBreakTable(){
|
||||
table.bootstrapTable("refresh");
|
||||
function reloadPriceBreakTable() {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
|
||||
pb_new_btn.click(function() {
|
||||
@ -1464,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',
|
||||
@ -1477,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" %}',
|
||||
|
@ -208,10 +208,10 @@ function printBuildReports(builds) {
|
||||
window.location.href = href;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -265,7 +265,7 @@ function printBomReports(parts) {
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -316,10 +316,10 @@ function printPurchaseOrderReports(orders) {
|
||||
window.location.href = href;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -370,8 +370,8 @@ function printSalesOrderReports(orders) {
|
||||
window.location.href = href;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ function stockStatusCodes() {
|
||||
{% for code in StockStatus.list %}
|
||||
{
|
||||
key: {{ code.key }},
|
||||
text: "{{ code.value }}",
|
||||
text: '{{ code.value }}',
|
||||
},
|
||||
{% endfor %}
|
||||
];
|
||||
@ -102,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" %}',
|
||||
@ -151,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
|
||||
@ -214,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();
|
||||
@ -265,7 +277,7 @@ function adjustStock(action, items, options={}) {
|
||||
read_only: readonly,
|
||||
title: readonly ? '{% trans "Quantity cannot be adjusted for serialized stock" %}' : '{% trans "Specify stock quantity" %}',
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
var buttons = `<div class='btn-group float-right' role='group'>`;
|
||||
@ -352,7 +364,7 @@ function adjustStock(action, items, options={}) {
|
||||
inventreeDelete(
|
||||
`/api/stock/${item.pk}/`,
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
// Wait for *all* the requests to complete
|
||||
@ -410,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -503,15 +515,15 @@ function loadStockTestResultsTable(table, options) {
|
||||
html += makeIconButton('fa-trash-alt icon-red', 'button-test-delete', pk, '{% trans "Delete test result" %}');
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
html += '</div>';
|
||||
|
||||
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,
|
||||
@ -530,7 +542,7 @@ function loadStockTestResultsTable(table, options) {
|
||||
table.treegrid({
|
||||
treeColumn: 0,
|
||||
});
|
||||
table.treegrid("collapseAll");
|
||||
table.treegrid('collapseAll');
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
@ -596,7 +608,7 @@ function loadStockTestResultsTable(table, options) {
|
||||
stock_item: options.stock_item,
|
||||
user_detail: true,
|
||||
attachment_detail: true,
|
||||
ordering: "-date",
|
||||
ordering: '-date',
|
||||
},
|
||||
{
|
||||
success: function(data) {
|
||||
@ -646,13 +658,12 @@ function loadStockTestResultsTable(table, options) {
|
||||
});
|
||||
|
||||
// Push data back into the table
|
||||
table.bootstrapTable("load", tableData);
|
||||
table.bootstrapTable('load', tableData);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -728,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);
|
||||
@ -882,7 +893,7 @@ function loadStockTable(table, options) {
|
||||
if (row.status == {{ StockStatus.REJECTED }}) {
|
||||
html += makeIconBadge('fa-times-circle icon-red', '{% trans "Stock item has been rejected" %}');
|
||||
} else if (row.status == {{ StockStatus.LOST }}) {
|
||||
html += makeIconBadge('fa-question-circle','{% trans "Stock item is 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" %}');
|
||||
}
|
||||
@ -1055,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',
|
||||
@ -1122,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 = [];
|
||||
|
||||
@ -1244,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() {
|
||||
@ -1277,7 +1288,7 @@ function loadStockTable(table, options) {
|
||||
});
|
||||
|
||||
printTestReports(items);
|
||||
})
|
||||
});
|
||||
|
||||
if (global_settings.BARCODE_ENABLE) {
|
||||
$('#multi-item-barcode-scan-into-location').click(function() {
|
||||
@ -1287,7 +1298,7 @@ function loadStockTable(table, options) {
|
||||
|
||||
selections.forEach(function(item) {
|
||||
items.push(item.pk);
|
||||
})
|
||||
});
|
||||
|
||||
scanItemsIntoLocation(items);
|
||||
});
|
||||
@ -1305,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 = [];
|
||||
|
||||
@ -1318,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');
|
||||
|
||||
@ -1337,7 +1348,7 @@ function loadStockTable(table, options) {
|
||||
function(item) {
|
||||
return item.text;
|
||||
},
|
||||
function (item) {
|
||||
function(item) {
|
||||
return item.key;
|
||||
}
|
||||
);
|
||||
@ -1409,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 = [];
|
||||
|
||||
@ -1528,10 +1539,10 @@ function loadStockTrackingTable(table, options) {
|
||||
field: 'label',
|
||||
title: '{% trans "Description" %}',
|
||||
formatter: function(value, row) {
|
||||
var html = "<b>" + value + "</b>";
|
||||
var html = '<b>' + value + '</b>';
|
||||
|
||||
if (row.notes) {
|
||||
html += "<br><i>" + row.notes + "</i>";
|
||||
html += '<br><i>' + row.notes + '</i>';
|
||||
}
|
||||
|
||||
return html;
|
||||
@ -1763,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,
|
||||
@ -1794,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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1803,7 +1814,7 @@ function createNewStockItem(options) {
|
||||
},
|
||||
];
|
||||
|
||||
launchModalForm("{% url 'stock-item-create' %}", options);
|
||||
launchModalForm('{% url "stock-item-create" %}', options);
|
||||
}
|
||||
|
||||
|
||||
@ -1813,7 +1824,7 @@ function loadInstalledInTable(table, options) {
|
||||
*/
|
||||
|
||||
table.inventreeTable({
|
||||
url: "{% url 'api-stock-list' %}",
|
||||
url: '{% url "api-stock-list" %}',
|
||||
queryParams: {
|
||||
installed_in: options.stock_item,
|
||||
part_detail: true,
|
||||
@ -1892,8 +1903,8 @@ function loadInstalledInTable(table, options) {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
tableKey = tableKey.toLowerCase();
|
||||
|
||||
// Filters for "variant" table
|
||||
if (tableKey == "variants") {
|
||||
if (tableKey == 'variants') {
|
||||
return {
|
||||
active: {
|
||||
type: 'bool',
|
||||
@ -49,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',
|
||||
@ -70,7 +70,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
allow_variants: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Allow Variant Stock" %}',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -85,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',
|
||||
@ -115,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" %}',
|
||||
@ -123,7 +123,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
},
|
||||
serial: {
|
||||
title: '{% trans "Serial number" %}',
|
||||
description: '{% trans "Serial number" %}'
|
||||
description: '{% trans "Serial number" %}',
|
||||
},
|
||||
batch: {
|
||||
title: '{% trans "Batch" %}',
|
||||
@ -192,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" %}',
|
||||
@ -252,7 +252,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
required: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Required" %}',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
}
|
||||
|
||||
// Filters for the "Order" table
|
||||
if (tableKey == "purchaseorder") {
|
||||
if (tableKey == 'purchaseorder') {
|
||||
|
||||
return {
|
||||
status: {
|
||||
@ -293,7 +293,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
};
|
||||
}
|
||||
|
||||
if (tableKey == "salesorder") {
|
||||
if (tableKey == 'salesorder') {
|
||||
return {
|
||||
status: {
|
||||
title: '{% trans "Order status" %}',
|
||||
@ -315,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',
|
||||
@ -343,7 +343,7 @@ function getAvailableTableFilters(tableKey) {
|
||||
},
|
||||
has_stock: {
|
||||
type: 'bool',
|
||||
title: '{% trans "Stock available" %}'
|
||||
title: '{% trans "Stock available" %}',
|
||||
},
|
||||
low_stock: {
|
||||
type: 'bool',
|
||||
|
@ -253,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');
|
||||
@ -275,7 +275,8 @@ $.fn.inventreeTable = function(options) {
|
||||
if (options.buttons) {
|
||||
linkButtonsToSelection(table, options.buttons);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function customGroupSorter(sortName, sortOrder, sortData) {
|
||||
|
||||
@ -381,7 +382,7 @@ function customGroupSorter(sortName, sortOrder, sortData) {
|
||||
},
|
||||
formatAllRows: function() {
|
||||
return '{% trans "All" %}';
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['en-US-custom']);
|
||||
|
Loading…
Reference in New Issue
Block a user