2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

Rework build allocation

- Each item renders as a collapsible panel with overview data at the top
This commit is contained in:
Oliver Walters
2019-05-01 07:48:46 +10:00
parent 7e7ac60a1a
commit b6becbc570
6 changed files with 114 additions and 209 deletions

View File

@ -9,6 +9,10 @@
<hr>
{% for bom_item in bom_items.all %}
{% include "build/allocation_item.html" with item=bom_item build=build %}
{% endfor %}
<table class='table table-striped' id='build-table'>
</table>
@ -28,14 +32,18 @@
{% block js_ready %}
{{ block.super }}
makeBuildTable($('#build-table'),
{
build: {{ build.pk }},
part: {{ build.part.pk }},
new_item_url: "{% url 'build-item-create' %}",
}
{% for bom_item in bom_items.all %}
loadAllocationTable(
$("#allocate-table-id-{{ bom_item.sub_part.id }}"),
"{% url 'api-build-item-list' %}?build={{ build.id }}&part={{ bom_item.sub_part.id }}",
$("#new-item-{{ bom_item.sub_part.id }}")
);
{% endfor %}
/*
$("#complete-build").on('click', function() {
launchModalForm(
"{% url 'build-complete' build.id %}",
@ -45,5 +53,6 @@
}
);
});
*/
{% endblock %}

View File

@ -0,0 +1,24 @@
<div class='panel-group'>
<div class='panel pane-default'>
<div class='panel panel-heading'>
<div class='row'>
<div class='col-sm-6'>
<div class='panel-title'>
<a data-toggle='collapse' href='#collapse-item-{{ item.id }}'>{{ item.sub_part.name }}</a>
</div>
</div>
<div class='col-sm-6'>
<div class='btn-group' style='float: right;'>
<button class='btn btn-success btn-sm' id='new-item-{{ item.sub_part.id }}' url="{% url 'build-item-create' %}?part={{ item.sub_part.id }}&build={{ build.id }}">Allocate Parts</button>
</div>
</div>
</div>
</div>
<div id='collapse-item-{{ item.id }}' class='panel-collapse collapse'>
<div class='panel-body'>
<table class='table table-striped table-condensed' id='allocate-table-id-{{ item.sub_part.id }}'>
</table>
</div>
</div>
</div>
</div>

View File

@ -111,6 +111,20 @@ class BuildAllocate(DetailView):
context_object_name = 'build'
template_name = 'build/allocate.html'
def get_context_data(self, **kwargs):
""" Provide extra context information for the Build allocation page """
context = super(DetailView, self).get_context_data(**kwargs)
build = self.get_object()
part = build.part
bom_items = part.bom_items
context['part'] = part
context['bom_items'] = bom_items
return context
class BuildCreate(AjaxCreateView):
""" View to create a new Build object """