mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Modals dialogs for 'Build'
This commit is contained in:
parent
c1c16bd013
commit
0dcdce82f8
@ -14,11 +14,7 @@ class EditBuildForm(forms.ModelForm):
|
|||||||
super(EditBuildForm, self).__init__(*args, **kwargs)
|
super(EditBuildForm, self).__init__(*args, **kwargs)
|
||||||
self.helper = FormHelper()
|
self.helper = FormHelper()
|
||||||
|
|
||||||
self.helper.form_id = 'id-edit-part-form'
|
self.helper.form_tag = False
|
||||||
self.helper.form_class = 'blueForms'
|
|
||||||
self.helper.form_method = 'post'
|
|
||||||
|
|
||||||
self.helper.add_input(Submit('submit', 'Submit'))
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Build
|
model = Build
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Build Details</h3>
|
<h3>Build Details</h3>
|
||||||
@ -35,7 +36,53 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<h3>Required Parts</h3>
|
||||||
|
<table class='table table-striped' id='build-list' data-sorting='true'>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Part</th>
|
||||||
|
<th>Required</th>
|
||||||
|
<th>Available</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in build.part.bom_items.all %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{% url 'part-detail' item.sub_part.id %}">{{ item.sub_part.name }}</a></td>
|
||||||
|
<td>{{ build.quantity }} × {{ item.quantity }}</td>
|
||||||
|
<td>{{ item.sub_part.available_stock }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<a href="{% url 'build-edit' build.id %}"><button class="btn btn-info">Edit Build</button></a>
|
<button class="btn btn-info" id='edit-build'>Edit Build</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% include 'modals.html' %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<script type='text/javascript' src="{% static 'script/footable.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$("#build-list").footable();
|
||||||
|
|
||||||
|
$("#edit-build").click(function () {
|
||||||
|
launchModalForm("#modal-form",
|
||||||
|
"{% url 'build-edit' build.id %}",
|
||||||
|
{
|
||||||
|
reload: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -11,6 +11,7 @@ from .models import Build
|
|||||||
|
|
||||||
from .forms import EditBuildForm
|
from .forms import EditBuildForm
|
||||||
|
|
||||||
|
from InvenTree.views import AjaxUpdateView, AjaxCreateView
|
||||||
|
|
||||||
class BuildIndex(ListView):
|
class BuildIndex(ListView):
|
||||||
model = Build
|
model = Build
|
||||||
@ -38,11 +39,13 @@ class BuildDetail(DetailView):
|
|||||||
context_object_name = 'build'
|
context_object_name = 'build'
|
||||||
|
|
||||||
|
|
||||||
class BuildCreate(CreateView):
|
class BuildCreate(AjaxCreateView):
|
||||||
model = Build
|
model = Build
|
||||||
template_name = 'build/create.html'
|
template_name = 'build/create.html'
|
||||||
context_object_name = 'build'
|
context_object_name = 'build'
|
||||||
form_class = EditBuildForm
|
form_class = EditBuildForm
|
||||||
|
ajax_form_title = 'Start new Build'
|
||||||
|
ajax_template_name = 'modal_form.html'
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initials = super(BuildCreate, self).get_initial().copy()
|
initials = super(BuildCreate, self).get_initial().copy()
|
||||||
@ -55,8 +58,10 @@ class BuildCreate(CreateView):
|
|||||||
return initials
|
return initials
|
||||||
|
|
||||||
|
|
||||||
class BuildUpdate(UpdateView):
|
class BuildUpdate(AjaxUpdateView):
|
||||||
model = Build
|
model = Build
|
||||||
form_class = EditBuildForm
|
form_class = EditBuildForm
|
||||||
context_object_name = 'build'
|
context_object_name = 'build'
|
||||||
template_name = 'build/update.html'
|
template_name = 'build/update.html'
|
||||||
|
ajax_form_title = 'Edit Build Details'
|
||||||
|
ajax_template_name = 'modal_form.html'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "part/part_base.html" %}
|
{% extends "part/part_base.html" %}
|
||||||
|
{% load static %}
|
||||||
{% block details %}
|
{% block details %}
|
||||||
|
|
||||||
{% include 'part/tabs.html' with tab='build' %}
|
{% include 'part/tabs.html' with tab='build' %}
|
||||||
@ -32,6 +32,30 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<a href="{% url 'build-create' %}?part={{ part.id }}"><button class="btn btn-success">Start New Build</button></a>
|
<button class="btn btn-success" id='start-build'>Start New Build</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% include 'modals.html' %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#start-build").click(function() {
|
||||||
|
launchModalForm("#modal-form",
|
||||||
|
"{% url 'build-create' %}",
|
||||||
|
{
|
||||||
|
follow: true,
|
||||||
|
data: {
|
||||||
|
part: {{ part.id }}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user