mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
here we go js
This commit is contained in:
parent
a77d9d9de7
commit
8c63b53c16
@ -75,7 +75,7 @@ function postBarcodeData(barcode_data, options={}) {
|
||||
enableBarcodeInput(modal, true);
|
||||
|
||||
if (status == 'success') {
|
||||
|
||||
|
||||
if ('success' in response) {
|
||||
if (options.onScan) {
|
||||
options.onScan(response);
|
||||
@ -125,7 +125,7 @@ function enableBarcodeInput(modal, enabled=true) {
|
||||
var barcode = $(modal + ' #barcode');
|
||||
|
||||
barcode.prop('disabled', !enabled);
|
||||
|
||||
|
||||
modalEnable(modal, enabled);
|
||||
|
||||
barcode.focus();
|
||||
@ -157,14 +157,14 @@ function barcodeDialog(title, options={}) {
|
||||
var barcode = getBarcodeData(modal);
|
||||
|
||||
if (barcode && barcode.length > 0) {
|
||||
|
||||
|
||||
postBarcodeData(barcode, options);
|
||||
}
|
||||
}
|
||||
|
||||
$(modal).on('shown.bs.modal', function() {
|
||||
$(modal + ' .modal-form-content').scrollTop(0);
|
||||
|
||||
|
||||
var barcode = $(modal + ' #barcode');
|
||||
|
||||
// Handle 'enter' key on barcode
|
||||
@ -210,10 +210,10 @@ function barcodeDialog(title, options={}) {
|
||||
var content = '';
|
||||
|
||||
content += `<div class='alert alert-info alert-block'>{% trans "Scan barcode data below" %}</div>`;
|
||||
|
||||
|
||||
content += `<div id='barcode-error-message'></div>`;
|
||||
content += `<form class='js-modal-form' method='post'>`;
|
||||
|
||||
|
||||
// Optional content before barcode input
|
||||
content += `<div class='container' id='barcode-header'>`;
|
||||
content += options.headerContent || '';
|
||||
@ -254,14 +254,14 @@ function barcodeScanDialog() {
|
||||
*/
|
||||
|
||||
var modal = '#modal-form';
|
||||
|
||||
|
||||
barcodeDialog(
|
||||
"Scan Barcode",
|
||||
{
|
||||
onScan: function(response) {
|
||||
if ('url' in response) {
|
||||
$(modal).modal('hide');
|
||||
|
||||
|
||||
// Redirect to the URL!
|
||||
window.location.href = response.url;
|
||||
} else {
|
||||
@ -399,7 +399,7 @@ function barcodeCheckIn(location_id, options={}) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (match) {
|
||||
reloadTable();
|
||||
}
|
||||
@ -429,9 +429,9 @@ function barcodeCheckIn(location_id, options={}) {
|
||||
onSubmit: function() {
|
||||
|
||||
// Called when the 'check-in' button is pressed
|
||||
|
||||
|
||||
var data = {location: location_id};
|
||||
|
||||
|
||||
// Extract 'notes' field
|
||||
data.notes = $(modal + ' #notes').val();
|
||||
|
||||
|
@ -33,7 +33,7 @@ function removeRowFromBomWizard(e) {
|
||||
var colNum = 0;
|
||||
|
||||
table.find('tr').each(function() {
|
||||
|
||||
|
||||
colNum++;
|
||||
|
||||
if (colNum >= 3) {
|
||||
@ -111,9 +111,9 @@ function loadBomTable(table, options) {
|
||||
if (options.part_detail) {
|
||||
params.part_detail = true;
|
||||
}
|
||||
|
||||
|
||||
params.sub_part_detail = true;
|
||||
|
||||
|
||||
var filters = {};
|
||||
|
||||
if (!options.disableFilters) {
|
||||
@ -173,7 +173,7 @@ function loadBomTable(table, options) {
|
||||
// Display an extra icon if this part is an assembly
|
||||
if (sub_part.assembly) {
|
||||
var text = `<span title='{% trans "Open subassembly" %}' class='fas fa-stream label-right'></span>`;
|
||||
|
||||
|
||||
html += renderLink(text, `/part/${row.sub_part}/bom/`);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ function loadBomTable(table, options) {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Part description
|
||||
cols.push(
|
||||
{
|
||||
@ -325,7 +325,7 @@ function loadBomTable(table, options) {
|
||||
sortable: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
// Part notes
|
||||
cols.push(
|
||||
{
|
||||
@ -348,18 +348,18 @@ function loadBomTable(table, options) {
|
||||
if (row.part == options.parent_id) {
|
||||
|
||||
var bValidate = `<button title='{% trans "Validate BOM Item" %}' class='bom-validate-button btn btn-default btn-glyph' type='button' pk='${row.pk}'><span class='fas fa-check-circle icon-blue'/></button>`;
|
||||
|
||||
|
||||
var bValid = `<span title='{% trans "This line has been validated" %}' class='fas fa-check-double icon-green'/>`;
|
||||
|
||||
var bEdit = `<button title='{% trans "Edit BOM Item" %}' class='bom-edit-button btn btn-default btn-glyph' type='button' pk='${row.pk}'><span class='fas fa-edit'></span></button>`;
|
||||
|
||||
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'>";
|
||||
|
||||
|
||||
html += bEdit;
|
||||
html += bDelt;
|
||||
|
||||
|
||||
if (!row.validated) {
|
||||
html += bValidate;
|
||||
} else {
|
||||
@ -394,7 +394,7 @@ function loadBomTable(table, options) {
|
||||
{
|
||||
success: function(response) {
|
||||
for (var idx = 0; idx < response.length; idx++) {
|
||||
|
||||
|
||||
response[idx].parentId = bom_pk;
|
||||
|
||||
if (response[idx].sub_part_detail.assembly) {
|
||||
@ -412,7 +412,7 @@ function loadBomTable(table, options) {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
table.inventreeTable({
|
||||
treeEnable: !options.editable,
|
||||
rootParentId: parent_id,
|
||||
@ -497,7 +497,7 @@ function loadBomTable(table, options) {
|
||||
|
||||
var pk = $(this).attr('pk');
|
||||
var url = `/part/bom/${pk}/delete/`;
|
||||
|
||||
|
||||
launchModalForm(
|
||||
url,
|
||||
{
|
||||
@ -509,7 +509,7 @@ function loadBomTable(table, options) {
|
||||
});
|
||||
|
||||
table.on('click', '.bom-edit-button', function() {
|
||||
|
||||
|
||||
var pk = $(this).attr('pk');
|
||||
var url = `/part/bom/${pk}/edit/`;
|
||||
|
||||
@ -524,7 +524,7 @@ function loadBomTable(table, options) {
|
||||
});
|
||||
|
||||
table.on('click', '.bom-validate-button', function() {
|
||||
|
||||
|
||||
var pk = $(this).attr('pk');
|
||||
var url = `/api/bom/${pk}/validate/`;
|
||||
|
||||
|
@ -49,7 +49,7 @@ function makeBuildOutputActionButtons(output, buildInfo, lines) {
|
||||
function reloadTable() {
|
||||
$(panel).find(`#allocation-table-${outputId}`).bootstrapTable('refresh');
|
||||
}
|
||||
|
||||
|
||||
// Find the div where the buttons will be displayed
|
||||
var buildActions = $(panel).find(`#output-actions-${outputId}`);
|
||||
|
||||
@ -82,7 +82,7 @@ function makeBuildOutputActionButtons(output, buildInfo, lines) {
|
||||
//disabled: true
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Add a button to "delete" the particular build output
|
||||
html += makeIconButton(
|
||||
'fa-trash-alt icon-red', 'button-output-delete', outputId,
|
||||
@ -171,7 +171,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
var partId = buildInfo.part;
|
||||
|
||||
var outputId = null;
|
||||
|
||||
|
||||
if (output) {
|
||||
outputId = output.pk;
|
||||
} else {
|
||||
@ -179,7 +179,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
}
|
||||
|
||||
var table = options.table;
|
||||
|
||||
|
||||
if (options.table == null) {
|
||||
table = `#allocation-table-${outputId}`;
|
||||
}
|
||||
@ -187,7 +187,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
// If an "output" is specified, then only "trackable" parts are allocated
|
||||
// Otherwise, only "untrackable" parts are allowed
|
||||
var trackable = ! !output;
|
||||
|
||||
|
||||
function reloadTable() {
|
||||
// Reload the entire build allocation table
|
||||
$(table).bootstrapTable('refresh');
|
||||
@ -492,7 +492,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
if (row.stock_item_detail.location) {
|
||||
var text = row.stock_item_detail.location_name;
|
||||
var url = `/stock/location/${row.stock_item_detail.location}/`;
|
||||
|
||||
|
||||
return renderLink(text, url);
|
||||
} else {
|
||||
return '<i>{% trans "No location set" %}</i>';
|
||||
@ -600,7 +600,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
|
||||
qA *= output.quantity;
|
||||
qB *= output.quantity;
|
||||
|
||||
|
||||
// Handle the case where both numerators are zero
|
||||
if ((aA == 0) && (aB == 0)) {
|
||||
return (qA > qB) ? 1 : -1;
|
||||
@ -610,7 +610,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
if ((qA == 0) || (qB == 0)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
var progressA = parseFloat(aA) / qA;
|
||||
var progressB = parseFloat(aB) / qB;
|
||||
|
||||
@ -618,7 +618,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
||||
if (progressA == progressB) {
|
||||
return (qA < qB) ? 1 : -1;
|
||||
}
|
||||
|
||||
|
||||
return (progressA < progressB) ? 1 : -1;
|
||||
}
|
||||
},
|
||||
@ -670,7 +670,7 @@ function loadBuildTable(table, options) {
|
||||
var filters = {};
|
||||
|
||||
params['part_detail'] = true;
|
||||
|
||||
|
||||
if (!options.disableFilters) {
|
||||
filters = loadTableFilters("build");
|
||||
}
|
||||
@ -801,11 +801,11 @@ function loadBuildTable(table, options) {
|
||||
|
||||
|
||||
function updateAllocationTotal(id, count, required) {
|
||||
|
||||
|
||||
count = parseFloat(count);
|
||||
|
||||
|
||||
$('#allocation-total-'+id).html(count);
|
||||
|
||||
|
||||
var el = $("#allocation-panel-" + id);
|
||||
el.removeClass('part-allocation-pass part-allocation-underallocated part-allocation-overallocated');
|
||||
|
||||
@ -819,7 +819,7 @@ function updateAllocationTotal(id, count, required) {
|
||||
}
|
||||
|
||||
function loadAllocationTable(table, part_id, part, url, required, button) {
|
||||
|
||||
|
||||
// Load the allocation table
|
||||
table.bootstrapTable({
|
||||
url: url,
|
||||
@ -848,9 +848,9 @@ function loadAllocationTable(table, part_id, part, url, required, 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>";
|
||||
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
@ -992,7 +992,7 @@ function loadBuildPartsTable(table, options={}) {
|
||||
// Display an extra icon if this part is an assembly
|
||||
if (sub_part.assembly) {
|
||||
var text = `<span title='{% trans "Open subassembly" %}' class='fas fa-stream label-right'></span>`;
|
||||
|
||||
|
||||
html += renderLink(text, `/part/${row.sub_part}/bom/`);
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ function loadCompanyTable(table, url, options={}) {
|
||||
if (row.is_customer) {
|
||||
html += `<span title='{% trans "Customer" %}' class='fas fa-user-tie label-right'></span>`;
|
||||
}
|
||||
|
||||
|
||||
if (row.is_manufacturer) {
|
||||
html += `<span title='{% trans "Manufacturer" %}' class='fas fa-industry label-right'></span>`;
|
||||
}
|
||||
|
||||
|
||||
if (row.is_supplier) {
|
||||
html += `<span title='{% trans "Supplier" %}' class='fas fa-building label-right'></span>`;
|
||||
}
|
||||
|
@ -185,11 +185,11 @@ function getFilterOptionList(tableKey, filterKey) {
|
||||
function generateAvailableFilterList(tableKey) {
|
||||
|
||||
var remaining = getRemainingTableFilters(tableKey);
|
||||
|
||||
|
||||
var id = 'filter-tag-' + tableKey.toLowerCase();
|
||||
|
||||
var html = `<select class='form-control filter-input' id='${id}' name='tag'>`;
|
||||
|
||||
|
||||
html += "<option value=''>{% trans 'Select filter' %}</option>";
|
||||
|
||||
for (var opt in remaining) {
|
||||
@ -275,7 +275,7 @@ function setupFilterList(tableKey, table, target) {
|
||||
var value = getFilterOptionValue(tableKey, key, filters[key]);
|
||||
var title = getFilterTitle(tableKey, key);
|
||||
var description = getFilterDescription(tableKey, key);
|
||||
|
||||
|
||||
element.append(`<div title='${description}' class='filter-tag'>${title} = ${value}<span ${tag}='${key}' class='close'>x</span></div>`);
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ function setupFilterList(tableKey, table, target) {
|
||||
addClicked = true;
|
||||
|
||||
var html = '';
|
||||
|
||||
|
||||
//`<div class='filter-input'>`;
|
||||
|
||||
html += generateAvailableFilterList(tableKey);
|
||||
@ -315,7 +315,7 @@ function setupFilterList(tableKey, table, target) {
|
||||
if (tag && tag.length > 0) {
|
||||
var filters = addTableFilter(tableKey, tag, val);
|
||||
reloadTable(table, filters);
|
||||
|
||||
|
||||
// Run this function again
|
||||
setupFilterList(tableKey, table, target);
|
||||
}
|
||||
@ -332,7 +332,7 @@ function setupFilterList(tableKey, table, target) {
|
||||
// Add a callback for clearing all the filters
|
||||
element.find(`#${clear}`).click(function() {
|
||||
var filters = clearTableFilters(tableKey);
|
||||
|
||||
|
||||
reloadTable(table, filters);
|
||||
|
||||
setupFilterList(tableKey, table, target);
|
||||
|
@ -40,11 +40,11 @@ function printStockItemLabels(items, options={}) {
|
||||
{
|
||||
success: function(pk) {
|
||||
var href = `/api/label/stock/${pk}/print/?`;
|
||||
|
||||
|
||||
items.forEach(function(item) {
|
||||
href += `items[]=${item}&`;
|
||||
});
|
||||
|
||||
|
||||
window.location.href = href;
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ function selectLabel(labels, items, options={}) {
|
||||
if (item.description) {
|
||||
text += ` - ${item.description}`;
|
||||
}
|
||||
|
||||
|
||||
return text;
|
||||
},
|
||||
function(item) {
|
||||
@ -146,7 +146,7 @@ function selectLabel(labels, items, options={}) {
|
||||
|
||||
// Construct form
|
||||
var html = '';
|
||||
|
||||
|
||||
if (items.length > 0) {
|
||||
|
||||
html += `
|
||||
@ -172,7 +172,7 @@ function selectLabel(labels, items, options={}) {
|
||||
openModal({
|
||||
modal: modal,
|
||||
});
|
||||
|
||||
|
||||
modalEnable(modal, true);
|
||||
modalSetTitle(modal, '{% trans "Select Label Template" %}');
|
||||
modalSetContent(modal, html);
|
||||
|
@ -28,11 +28,11 @@ function makeOptionsList(elements, textFunc, valueFunc, titleFunc) {
|
||||
* - valueFunc: optional function which takes an element and generates the value
|
||||
* - titleFunc: optional function which takes an element and generates a title
|
||||
*/
|
||||
|
||||
|
||||
var options = [];
|
||||
|
||||
elements.forEach(function(element) {
|
||||
|
||||
|
||||
var text = textFunc(element);
|
||||
var value = null;
|
||||
var title = null;
|
||||
@ -63,9 +63,9 @@ function setFieldOptions(fieldName, optionList, options={}) {
|
||||
* - append: If true, options will be appended, otherwise will replace existing options.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
var append = options.append || false;
|
||||
|
||||
|
||||
var modal = options.modal || '#modal-form';
|
||||
|
||||
var field = getFieldByName(modal, fieldName);
|
||||
@ -153,7 +153,7 @@ function enableField(fieldName, enabled, options={}) {
|
||||
}
|
||||
|
||||
function clearField(fieldName, options={}) {
|
||||
|
||||
|
||||
setFieldValue(fieldName, '', options);
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ function afterForm(response, options) {
|
||||
* - Redirect the browser to a different URL
|
||||
* - Reload the page
|
||||
*/
|
||||
|
||||
|
||||
// Should we show alerts immediately or cache them?
|
||||
var cache = (options.follow && response.url) ||
|
||||
options.redirect ||
|
||||
@ -393,11 +393,11 @@ function removeRowFromModalForm(e) {
|
||||
|
||||
|
||||
function renderErrorMessage(xhr) {
|
||||
|
||||
|
||||
var html = '<b>' + xhr.statusText + '</b><br>';
|
||||
|
||||
|
||||
html += '<b>Error Code - ' + xhr.status + '</b><br><hr>';
|
||||
|
||||
|
||||
html += `
|
||||
<div class='panel-group'>
|
||||
<div class='panel panel-default'>
|
||||
@ -410,7 +410,7 @@ function renderErrorMessage(xhr) {
|
||||
<div class='panel-body'>`;
|
||||
|
||||
html += xhr.responseText;
|
||||
|
||||
|
||||
html += `
|
||||
</div>
|
||||
</div>
|
||||
@ -590,7 +590,7 @@ function insertNewItemButton(modal, options) {
|
||||
var html = "<span style='float: right;'>";
|
||||
|
||||
html += "<div type='button' class='btn btn-primary btn-secondary'";
|
||||
|
||||
|
||||
if (options.title) {
|
||||
html += " title='" + options.title + "'";
|
||||
}
|
||||
@ -640,9 +640,9 @@ function attachSecondaryModal(modal, options) {
|
||||
*/
|
||||
|
||||
var select = '#id_' + options.field;
|
||||
|
||||
|
||||
var option = new Option(response.text, response.pk, true, true);
|
||||
|
||||
|
||||
$(modal).find(select).append(option).trigger('change');
|
||||
}
|
||||
}
|
||||
@ -768,7 +768,7 @@ function handleModalForm(url, options) {
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
// There was an error submitting form data via POST
|
||||
|
||||
|
||||
$(modal).modal('hide');
|
||||
showAlertDialog('{% trans "Error posting form data" %}', renderErrorMessage(xhr));
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ function makePartIcons(part, options={}) {
|
||||
if (part.is_template) {
|
||||
html += makeIconBadge('fa-clone', '{% trans "Template part" %}');
|
||||
}
|
||||
|
||||
|
||||
if (part.assembly) {
|
||||
html += makeIconBadge('fa-tools', '{% trans "Assembled part" %}');
|
||||
}
|
||||
@ -71,13 +71,13 @@ function makePartIcons(part, options={}) {
|
||||
if (part.salable) {
|
||||
html += makeIconBadge('fa-dollar-sign', title='{% trans "Salable part" %}');
|
||||
}
|
||||
|
||||
|
||||
if (!part.active) {
|
||||
html += `<span class='label label-warning label-right'>{% trans "Inactive" %}</span>`;
|
||||
}
|
||||
|
||||
return html;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -118,14 +118,14 @@ function loadPartVariantTable(table, partId, options={}) {
|
||||
name += row.IPN;
|
||||
name += ' | ';
|
||||
}
|
||||
|
||||
|
||||
name += value;
|
||||
|
||||
|
||||
if (row.revision) {
|
||||
name += ' | ';
|
||||
name += row.revision;
|
||||
}
|
||||
|
||||
|
||||
if (row.is_template) {
|
||||
name = '<i>' + name + '</i>';
|
||||
}
|
||||
@ -144,7 +144,7 @@ function loadPartVariantTable(table, partId, options={}) {
|
||||
if (row.is_template) {
|
||||
html += makeIconBadge('fa-clone', '{% trans "Template part" %}');
|
||||
}
|
||||
|
||||
|
||||
if (row.assembly) {
|
||||
html += makeIconBadge('fa-tools', '{% trans "Assembled part" %}');
|
||||
}
|
||||
@ -242,7 +242,7 @@ function loadParametricPartTable(table, options={}) {
|
||||
} else {
|
||||
name += row.name;
|
||||
}
|
||||
|
||||
|
||||
return renderLink(name, '/part/' + row.pk + '/');
|
||||
}
|
||||
});
|
||||
@ -297,7 +297,7 @@ function loadPartTable(table, url, options={}) {
|
||||
var params = options.params || {};
|
||||
|
||||
var filters = {};
|
||||
|
||||
|
||||
if (!options.disableFilters) {
|
||||
filters = loadTableFilters("parts");
|
||||
}
|
||||
@ -359,7 +359,7 @@ function loadPartTable(table, url, options={}) {
|
||||
}
|
||||
|
||||
var display = imageHoverIcon(row.thumbnail) + renderLink(name, '/part/' + row.pk + '/');
|
||||
|
||||
|
||||
display += makePartIcons(row);
|
||||
|
||||
return display;
|
||||
@ -378,7 +378,7 @@ function loadPartTable(table, url, options={}) {
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
columns.push({
|
||||
sortable: true,
|
||||
field: 'category_detail',
|
||||
@ -400,7 +400,7 @@ function loadPartTable(table, url, options={}) {
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var link = "stock";
|
||||
|
||||
|
||||
if (value) {
|
||||
// There IS stock available for this part
|
||||
|
||||
@ -421,7 +421,7 @@ function loadPartTable(table, url, options={}) {
|
||||
// There is no stock available
|
||||
value = "0<span class='label label-right label-danger'>{% trans "No Stock" %}</span>";
|
||||
}
|
||||
|
||||
|
||||
return renderLink(value, '/part/' + row.pk + "/" + link + "/");
|
||||
}
|
||||
});
|
||||
@ -596,7 +596,7 @@ function loadPartTestTemplateTable(table, options) {
|
||||
/*
|
||||
* Load PartTestTemplate table.
|
||||
*/
|
||||
|
||||
|
||||
var params = options.params || {};
|
||||
|
||||
var part = options.part || null;
|
||||
@ -671,7 +671,7 @@ function loadPartTestTemplateTable(table, options) {
|
||||
|
||||
if (row.part == part) {
|
||||
var html = `<div class='btn-group float-right' role='group'>`;
|
||||
|
||||
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-test-edit', pk, '{% trans "Edit test result" %}');
|
||||
html += makeIconButton('fa-trash-alt icon-red', 'button-test-delete', pk, '{% trans "Delete test result" %}');
|
||||
|
||||
|
@ -65,7 +65,7 @@ function selectReport(reports, items, options={}) {
|
||||
openModal({
|
||||
modal: modal,
|
||||
});
|
||||
|
||||
|
||||
modalEnable(modal, true);
|
||||
modalSetTitle(modal, '{% trans "Select Test Report Template" %}');
|
||||
modalSetContent(modal, html);
|
||||
|
@ -75,7 +75,7 @@ function loadStockTestResultsTable(table, options) {
|
||||
html += makeIconButton('fa-edit icon-blue', 'button-test-edit', pk, '{% trans "Edit test result" %}');
|
||||
html += makeIconButton('fa-trash-alt icon-red', 'button-test-delete', pk, '{% trans "Delete test result" %}');
|
||||
}
|
||||
|
||||
|
||||
html += "</div>";
|
||||
|
||||
return html;
|
||||
@ -185,11 +185,11 @@ function loadStockTestResultsTable(table, options) {
|
||||
|
||||
// Try to associate this result with a test row
|
||||
tableData.forEach(function(row, index) {
|
||||
|
||||
|
||||
|
||||
|
||||
// The result matches the test template row
|
||||
if (key == row.key) {
|
||||
|
||||
|
||||
// Force the names to be the same!
|
||||
item.test_name = row.test_name;
|
||||
item.required = row.required;
|
||||
@ -250,7 +250,7 @@ function loadStockTable(table, options) {
|
||||
var filters = {};
|
||||
|
||||
var filterKey = options.filterKey || options.name || "stock";
|
||||
|
||||
|
||||
if (!options.disableFilters) {
|
||||
filters = loadTableFilters(filterKey);
|
||||
}
|
||||
@ -286,7 +286,7 @@ function loadStockTable(table, options) {
|
||||
|
||||
// URL (optional)
|
||||
var url = '';
|
||||
|
||||
|
||||
if (row.is_building && row.build) {
|
||||
// StockItem is currently being built!
|
||||
text = '{% trans "In production" %}';
|
||||
@ -532,7 +532,7 @@ function loadStockTable(table, options) {
|
||||
var name = row.part_detail.full_name;
|
||||
|
||||
html = imageHoverIcon(thumb) + renderLink(name, url);
|
||||
|
||||
|
||||
html += makePartIcons(row.part_detail);
|
||||
|
||||
return html;
|
||||
@ -574,7 +574,7 @@ function loadStockTable(table, options) {
|
||||
}
|
||||
|
||||
var html = renderLink(val, `/stock/item/${row.pk}/`);
|
||||
|
||||
|
||||
if (row.is_building) {
|
||||
html += makeIconBadge('fa-tools', '{% trans "Stock item is in production" %}');
|
||||
}
|
||||
@ -848,7 +848,7 @@ function loadStockTable(table, options) {
|
||||
var status_code = label.val();
|
||||
|
||||
closeModal(modal);
|
||||
|
||||
|
||||
if (!status_code) {
|
||||
showAlertDialog(
|
||||
'{% trans "Select Status Code" %}',
|
||||
@ -1130,7 +1130,7 @@ function createNewStockItem(options) {
|
||||
`/api/part/${value}/`, {},
|
||||
{
|
||||
success: function(response) {
|
||||
|
||||
|
||||
// Disable serial number field if the part is not trackable
|
||||
enableField('serial_numbers', response.trackable);
|
||||
clearField('serial_numbers');
|
||||
@ -1141,7 +1141,7 @@ function createNewStockItem(options) {
|
||||
clearField('expiry_date');
|
||||
} else {
|
||||
var expiry = moment().add(response.default_expiry, 'days');
|
||||
|
||||
|
||||
setFieldValue('expiry_date', expiry.format("YYYY-MM-DD"));
|
||||
}
|
||||
}
|
||||
@ -1295,7 +1295,7 @@ function loadInstalledInTable(table, options) {
|
||||
|
||||
// Add some buttons yo!
|
||||
html += `<div class='btn-group float-right' role='group'>`;
|
||||
|
||||
|
||||
html += makeIconButton('fa-unlink', 'button-uninstall', pk, "{% trans 'Uninstall stock item' %}");
|
||||
|
||||
html += `</div>`;
|
||||
@ -1343,17 +1343,17 @@ function loadInstalledInTable(table, options) {
|
||||
title: '{% trans "Part" %}',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
|
||||
|
||||
var url = `/part/${row.sub_part}/`;
|
||||
var thumb = row.sub_part_detail.thumbnail;
|
||||
var name = row.sub_part_detail.full_name;
|
||||
|
||||
|
||||
html = imageHoverIcon(thumb) + renderLink(name, url);
|
||||
|
||||
if (row.not_in_bom) {
|
||||
html = `<i>${html}</i>`
|
||||
}
|
||||
|
||||
|
||||
return html;
|
||||
}
|
||||
},
|
||||
@ -1403,13 +1403,13 @@ function loadInstalledInTable(table, options) {
|
||||
},
|
||||
{
|
||||
success: function(stock_items) {
|
||||
|
||||
|
||||
var table_data = table.bootstrapTable('getData');
|
||||
|
||||
stock_items.forEach(function(item) {
|
||||
|
||||
var match = false;
|
||||
|
||||
|
||||
for (var idx = 0; idx < table_data.length; idx++) {
|
||||
|
||||
var row = table_data[idx];
|
||||
@ -1419,16 +1419,16 @@ function loadInstalledInTable(table, options) {
|
||||
|
||||
// Match on "sub_part"
|
||||
if (row.sub_part == item.part) {
|
||||
|
||||
|
||||
// First time?
|
||||
if (row.installed_count == null) {
|
||||
row.installed_count = 0;
|
||||
row.installed_items = [];
|
||||
}
|
||||
|
||||
|
||||
row.installed_count += item.quantity;
|
||||
row.installed_items.push(item);
|
||||
|
||||
|
||||
// Push the row back into the table
|
||||
table.bootstrapTable('updateRow', idx, row, true);
|
||||
|
||||
@ -1445,7 +1445,7 @@ function loadInstalledInTable(table, options) {
|
||||
if (!match) {
|
||||
// The stock item did *not* match any items in the BOM!
|
||||
// Add a new row to the table...
|
||||
|
||||
|
||||
// Contruct a new "row" to add to the table
|
||||
var new_row = {
|
||||
sub_part: item.part,
|
||||
|
@ -94,7 +94,7 @@ function reloadTable(table, filters) {
|
||||
}
|
||||
|
||||
options.queryParams = function(tableParams) {
|
||||
|
||||
|
||||
for (key in params) {
|
||||
tableParams[key] = params[key];
|
||||
}
|
||||
@ -145,7 +145,7 @@ $.fn.inventreeTable = function(options) {
|
||||
var filters = options.queryParams || options.filters || {};
|
||||
|
||||
options.queryParams = function(params) {
|
||||
|
||||
|
||||
// Override the way that we ask the server to sort results
|
||||
// It seems bootstrap-table does not offer a "native" way to do this...
|
||||
if ('sort' in params) {
|
||||
@ -200,7 +200,7 @@ $.fn.inventreeTable = function(options) {
|
||||
|
||||
// Callback when a column is changed
|
||||
options.onColumnSwitch = function(field, checked) {
|
||||
|
||||
|
||||
var columns = table.bootstrapTable('getVisibleColumns');
|
||||
|
||||
var text = visibleColumnString(columns);
|
||||
@ -225,7 +225,7 @@ $.fn.inventreeTable = function(options) {
|
||||
|
||||
if (visible && Array.isArray(visible)) {
|
||||
visible.forEach(function(column) {
|
||||
|
||||
|
||||
// Visible field should *not* be visible! (hide it!)
|
||||
if (column.switchable && !columns.includes(column.field)) {
|
||||
table.bootstrapTable('hideColumn', column.field);
|
||||
@ -301,7 +301,7 @@ function customGroupSorter(sortName, sortOrder, sortData) {
|
||||
bb = bb.toString();
|
||||
|
||||
var cmp = aa.localeCompare(bb);
|
||||
|
||||
|
||||
if (cmp === -1) {
|
||||
return order * -1;
|
||||
} else if (cmp === 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user