{% load i18n %} /* globals attachSelect, closeModal, inventreeGet, openModal, makeOptionsList, modalEnable, modalSetContent, modalSetTitle, modalSubmit, showAlertDialog, */ /* exported printBomReports, printBuildReports, printPurchaseOrderReports, printSalesOrderReports, printTestReports, */ function selectReport(reports, items, options={}) { /** * Present the user with the available reports, * and allow them to select which report to print. * * The intent is that the available report templates have been requested * (via AJAX) from the server. */ // If there is only a single report available, just print! if (reports.length == 1) { if (options.success) { options.success(reports[0].pk); } return; } var modal = options.modal || '#modal-form'; var report_list = makeOptionsList( reports, function(item) { var text = item.name; if (item.description) { text += ` - ${item.description}`; } return text; }, function(item) { return item.pk; } ); // Construct form var html = ''; if (items.length > 0) { html += `