From 14ef56785e6bab415e808da83273ac4638906199 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 16 Oct 2021 14:27:02 +1100 Subject: [PATCH] Add option to select multiple build outputs - Can "complete" these outputs --- InvenTree/build/templates/build/detail.html | 54 +++++++++++++++++---- InvenTree/build/templates/build/navbar.html | 15 ++++-- InvenTree/templates/js/translated/build.js | 8 ++- InvenTree/templates/js/translated/tables.js | 6 +-- 4 files changed, 65 insertions(+), 18 deletions(-) diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index b7cdf12921..eca8ffc1a0 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -213,19 +213,31 @@
- {% if not build.is_complete %}

{% trans "Incomplete Build Outputs" %}

- {% if build.active %} -
- - +
+
+ {% if build.active %} +
+ + + + {% endif %} +
+
- +
{% for item in build.incomplete_outputs %} {% include "build/allocation_card.html" with item=item tracked_items=build.has_tracked_bom_items %} @@ -233,10 +245,10 @@
- {% endif %}
- {% endif %} +
+

{% trans "Completed Build Outputs" %} @@ -336,6 +348,28 @@ inventreeGet( {% if build.active %} loadBuildOutputTable(build_info); + linkButtonsToSelection( + '#build-output-table', + [ + '#output-options', + '#multi-output-complete', + ] + ); + + $('#multi-output-complete').click(function() { + var outputs = $('#build-output-table').bootstrapTable('getSelections'); + + completeBuildOutputs( + build_info.pk, + outputs, + { + success: function() { + $('#build-output-table').bootstrapTable('refresh'); + } + } + ); + }); + {% endif %} {% for item in build.incomplete_outputs %} diff --git a/InvenTree/build/templates/build/navbar.html b/InvenTree/build/templates/build/navbar.html index e4c4fe4e50..de68558d8f 100644 --- a/InvenTree/build/templates/build/navbar.html +++ b/InvenTree/build/templates/build/navbar.html @@ -25,10 +25,19 @@ {% endif %} -
  • + {% if not build.is_complete %} +
  • - - {% trans "Build Outputs" %} + + {% trans "In Progress Items" %} + +
  • + {% endif %} + +
  • + + + {% trans "Completed Items" %}
  • diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 2515cbc346..7fb10bd743 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -423,8 +423,6 @@ function completeBuildOutputs(build_id, outputs, options={}) { output: pk, }); output_pk_values.push(pk); - } else { - console.log(`Could not find row for ${pk}`); } }); @@ -753,6 +751,12 @@ function loadBuildOutputTable(build_info, options={}) { setupBuildOutputButtonCallbacks(); }, columns: [ + { + title: '', + visible: true, + checkbox: true, + switchable: false, + }, { field: 'part', title: '{% trans "Part" %}', diff --git a/InvenTree/templates/js/translated/tables.js b/InvenTree/templates/js/translated/tables.js index 3138c1e73d..fed7a5d980 100644 --- a/InvenTree/templates/js/translated/tables.js +++ b/InvenTree/templates/js/translated/tables.js @@ -56,10 +56,10 @@ function enableButtons(elements, enabled) { } +/* Link a bootstrap-table object to one or more buttons. + * The buttons will only be enabled if there is at least one row selected + */ function linkButtonsToSelection(table, buttons) { - /* Link a bootstrap-table object to one or more buttons. - * The buttons will only be enabled if there is at least one row selected - */ if (typeof table === 'string') { table = $(table);