mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Refactor build page template
- Only load build outputs table as required
This commit is contained in:
		| @@ -401,33 +401,21 @@ function reloadTable() { | |||||||
|     $('#allocation-table-untracked').bootstrapTable('refresh'); |     $('#allocation-table-untracked').bootstrapTable('refresh'); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Get the list of BOM items required for this build | onPanelLoad('outputs', function() { | ||||||
| inventreeGet( |     {% if build.active %} | ||||||
|     '{% url "api-bom-list" %}', |  | ||||||
|     { |  | ||||||
|         part: {{ build.part.pk }}, |  | ||||||
|         sub_part_detail: true, |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|         success: function(response) { |  | ||||||
|  |  | ||||||
|     var build_info = { |     var build_info = { | ||||||
|         pk: {{ build.pk }}, |         pk: {{ build.pk }}, | ||||||
|         part: {{ build.part.pk }}, |         part: {{ build.part.pk }}, | ||||||
|         quantity: {{ build.quantity }}, |         quantity: {{ build.quantity }}, | ||||||
|                 bom_items: response, |  | ||||||
|         {% if build.take_from %} |         {% if build.take_from %} | ||||||
|         source_location: {{ build.take_from.pk }}, |         source_location: {{ build.take_from.pk }}, | ||||||
|         {% endif %} |         {% endif %} | ||||||
|                 {% if build.has_tracked_bom_items %} |  | ||||||
|         tracked_parts: true, |         tracked_parts: true, | ||||||
|                 {% else %} |  | ||||||
|                 tracked_parts: false, |  | ||||||
|                 {% endif %} |  | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|             {% if build.active %} |  | ||||||
|     loadBuildOutputTable(build_info); |     loadBuildOutputTable(build_info); | ||||||
|  |  | ||||||
|     linkButtonsToSelection( |     linkButtonsToSelection( | ||||||
|         '#build-output-table', |         '#build-output-table', | ||||||
|         [ |         [ | ||||||
| @@ -491,8 +479,20 @@ inventreeGet( | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     {% endif %} |     {% endif %} | ||||||
|  | }); | ||||||
|  |  | ||||||
| {% if build.active and build.has_untracked_bom_items %} | {% if build.active and build.has_untracked_bom_items %} | ||||||
|  |  | ||||||
|  | var build_info = { | ||||||
|  |     pk: {{ build.pk }}, | ||||||
|  |     part: {{ build.part.pk }}, | ||||||
|  |     quantity: {{ build.quantity }}, | ||||||
|  |     {% if build.take_from %} | ||||||
|  |     source_location: {{ build.take_from.pk }}, | ||||||
|  |     {% endif %} | ||||||
|  |     tracked_parts: false, | ||||||
|  | }; | ||||||
|  |  | ||||||
| // Load allocation table for un-tracked parts | // Load allocation table for un-tracked parts | ||||||
| loadBuildOutputAllocationTable( | loadBuildOutputAllocationTable( | ||||||
|     build_info, |     build_info, | ||||||
| @@ -502,9 +502,6 @@ inventreeGet( | |||||||
|     } |     } | ||||||
| ); | ); | ||||||
| {% endif %} | {% endif %} | ||||||
|         } |  | ||||||
|     } |  | ||||||
| ); |  | ||||||
|  |  | ||||||
| $('#btn-create-output').click(function() { | $('#btn-create-output').click(function() { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -741,18 +741,6 @@ function loadBuildOutputTable(build_info, options={}) { | |||||||
|     params.is_building = true; |     params.is_building = true; | ||||||
|     params.build = build_info.pk; |     params.build = build_info.pk; | ||||||
|  |  | ||||||
|     // Construct a list of "tracked" BOM items |  | ||||||
|     var tracked_bom_items = []; |  | ||||||
|  |  | ||||||
|     var has_tracked_items = false; |  | ||||||
|  |  | ||||||
|     build_info.bom_items.forEach(function(bom_item) { |  | ||||||
|         if (bom_item.sub_part_detail.trackable) { |  | ||||||
|             tracked_bom_items.push(bom_item); |  | ||||||
|             has_tracked_items = true; |  | ||||||
|         }; |  | ||||||
|     }); |  | ||||||
|  |  | ||||||
|     var filters = {}; |     var filters = {}; | ||||||
|  |  | ||||||
|     for (var key in params) { |     for (var key in params) { | ||||||
| @@ -1031,7 +1019,7 @@ function loadBuildOutputTable(build_info, options={}) { | |||||||
|         sortable: true, |         sortable: true, | ||||||
|         search: false, |         search: false, | ||||||
|         sidePagination: 'client', |         sidePagination: 'client', | ||||||
|         detailView: has_tracked_items, |         detailView: true, | ||||||
|         detailFilter: function(index, row) { |         detailFilter: function(index, row) { | ||||||
|             return true; |             return true; | ||||||
|         }, |         }, | ||||||
| @@ -1105,7 +1093,7 @@ function loadBuildOutputTable(build_info, options={}) { | |||||||
|             { |             { | ||||||
|                 field: 'allocated', |                 field: 'allocated', | ||||||
|                 title: '{% trans "Allocated Stock" %}', |                 title: '{% trans "Allocated Stock" %}', | ||||||
|                 visible: has_tracked_items, |                 visible: true, | ||||||
|                 switchable: false, |                 switchable: false, | ||||||
|                 formatter: function(value, row) { |                 formatter: function(value, row) { | ||||||
|                     return `<div id='output-progress-${row.pk}'><span class='fas fa-spin fa-spinner'></span></div>`; |                     return `<div id='output-progress-${row.pk}'><span class='fas fa-spin fa-spinner'></span></div>`; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user