Use collapse template in allocation page

This commit is contained in:
Oliver Walters 2019-05-02 18:53:03 +10:00
parent 18c5ad7a6e
commit fbb120da53
3 changed files with 36 additions and 36 deletions

View File

@ -11,7 +11,7 @@
<hr>
{% for bom_item in bom_items.all %}
{% include "build/allocation_item.html" with item=bom_item build=build %}
{% include "build/allocation_item.html" with item=bom_item build=build collapse_id=bom_item.id %}
{% endfor %}
<table class='table table-striped' id='build-table'>

View File

@ -1,14 +1,12 @@
{% extends "collapse.html" %}
{% load inventree_extras %}
<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>
{% block collapse_title %}
{{ item.sub_part.name }}
{% endblock %}
{% block collapse_heading %}
<div class='col-sm-1' align='right'>
Required:
</div>
@ -26,13 +24,9 @@
<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'>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='allocate-table-id-{{ item.sub_part.id }}'>
</table>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -307,6 +307,12 @@ class Part(models.Model):
def used_in_count(self):
return self.used_in.count()
def required_parts(self):
parts = []
for bom in self.bom_items.all():
parts.append(bom.sub_part)
return parts
@property
def supplier_count(self):
# Return the number of supplier parts available for this part