Merge pull request #207 from SchrodingersGat/build-list

Split build list display
This commit is contained in:
Oliver 2019-05-02 21:32:33 +10:00 committed by GitHub
commit a70ec0b179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 20 deletions

View File

@ -133,6 +133,9 @@ class Build(models.Model):
for item in self.allocated_stock.all(): for item in self.allocated_stock.all():
item.delete() item.delete()
# Date of 'completion' is the date the build was cancelled
self.completion_date = datetime.now().date()
self.status = self.CANCELLED self.status = self.CANCELLED
self.save() self.save()

View File

@ -1,4 +1,20 @@
{% extends "collapse.html" %}
{% block collapse_title %}
<b>{{ title }}</b> - {{ builds | length }}
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed build-table' id='build-table-{{collapse_id}}' data-toolbar='#button-toolbar'>
<thead>
<tr>
<th>Build</th>
<th>Part</th>
<th>Quantity</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for build in builds %} {% for build in builds %}
<tr> <tr>
<td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td> <td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td>
@ -7,3 +23,6 @@
<td>{% include "build_status.html" with build=build %} <td>{% include "build_status.html" with build=build %}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -2,28 +2,40 @@
{% load static %} {% load static %}
{% block content %} {% block content %}
<h3>Part Builds</h3>
<div id='button-toolbar'> <h4>Active Builds</h4>
<button class="btn btn-success" id='new-build'>Start New Build</button>
<div id='active-build-toolbar'>
<div class='btn-group'>
<button class="btn btn-success" id='new-build'>Start New Build</button>
</div>
</div> </div>
<table class='table table-striped table-condensed' id='build-table' data-toolbar='#button-toolbar'> <table class='table table-striped table-condensed build-table' id='build-table-{{collapse_id}}' data-toolbar='#active-build-toolbar'>
<thead> <thead>
<tr>
<th>Build</th>
<th>Part</th>
<th>Quantity</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for build in active %}
<tr> <tr>
<th>Build</th> <td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td>
<th>Part</th> <td><a href="{% url 'part-build' build.part.id %}">{{ build.part.name }}</a></td>
<th>Quantity</th> <td>{{ build.quantity }}</td>
<th>Status</th> <td>{% include "build_status.html" with build=build %}
</tr> </tr>
</thead> {% endfor %}
<tbody>
{% include "build/build_list.html" with builds=builds %}
</tbody> </tbody>
</table> </table>
<p></p>
{% include "build/build_list.html" with builds=completed title="Completed Builds" collapse_id="complete" %}
<p></p>
{% include "build/build_list.html" with builds=cancelled title="Cancelled Builds" collapse_id="cancelled" %}
{% include 'modals.html' %} {% include 'modals.html' %}
@ -39,9 +51,10 @@
}); });
}); });
$("#build-table").bootstrapTable({ $(".build-table").bootstrapTable({
sortable: true, sortable: true,
search: true, search: true,
formatNoMatches: function() { return 'No builds found'; },
columns: [ columns: [
{ {
field: 'name', field: 'name',

View File

@ -33,12 +33,10 @@ class BuildIndex(ListView):
context = super(BuildIndex, self).get_context_data(**kwargs).copy() context = super(BuildIndex, self).get_context_data(**kwargs).copy()
""" context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, ])
context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, Build.HOLDING])
context['complete'] = self.get_queryset().filter(status=Build.COMPLETE) context['completed'] = self.get_queryset().filter(status=Build.COMPLETE)
context['cancelled'] = self.get_queryset().filter(status=Build.CANCELLED) context['cancelled'] = self.get_queryset().filter(status=Build.CANCELLED)
"""
return context return context