diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index 524b116743..efa3c30ada 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -750,6 +750,100 @@ function loadStockTable(table, options) { stock.push(item.pk); }); + var title = 'Form title'; + + switch (action) { + case 'move': + title = '{% trans "Transfer Stock" %}'; + break; + case 'count': + title = '{% trans "Count Stock" %}'; + break; + case 'take': + title = '{% trans "Remove Stock" %}'; + break; + case 'add': + title = '{% trans "Add Stock" %}'; + break; + case 'delete': + title = '{% trans "Delete Stock" %}'; + break; + default: + break; + } + + var modal = createNewModal({ + title: title, + }); + + // Generate content for the modal + + var html = ` + + + + + + + + + + + `; + + items.forEach(function(item) { + + var pk = item.pk; + + var image = item.part_detail.thumbnail || item.part_detail.image || blankImage(); + + var status = stockStatusDisplay(item.status, { + classes: 'float-right' + }); + + var quantity = item.quantity; + + if (item.serial != null) { + quantity = `#${item.serial}`; + } + + var buttons = `
`; + + buttons += makeIconButton( + 'fa-trash-alt icon-red', + 'button-stock-item-remove', + pk, + '{% trans "Remove stock item" %}', + ); + + buttons += `
`; + + html += ` + + + + + + `; + + }); + + html += `
{% trans "Part" %}{% trans "Stock" %}{% trans "Location" %}
${item.part_detail.full_name}${status}${quantity}${item.location_detail.pathstring}${buttons}
`; + + $(modal).find('.modal-form-content').html(html); + + // Add a "confirm" button + insertConfirmButton({ + modal: modal, + }); + + attachToggle(modal); + + $(modal + ' .select2-container').addClass('select-full-width'); + $(modal + ' .select2-container').css('width', '100%'); + + return; + // Buttons for launching secondary modals var secondary = [];