mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
More modal forms
- supplier-part-edit - supplier-part-delete
This commit is contained in:
parent
bc3dca3aba
commit
e1e3cc71e6
@ -1,5 +1 @@
|
|||||||
{% extends 'delete_obj.html' %}
|
Are you sure you want to delete this supplier part?
|
||||||
|
|
||||||
{% block del_title %}
|
|
||||||
Are you sure you want to delete this supplier part?
|
|
||||||
{% endblock %}
|
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h3>Supplier part information</h3>
|
<h3>Supplier part information</h3>
|
||||||
@ -30,13 +30,40 @@
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<a href="{% url 'supplier-part-edit' part.id %}">
|
<button class="btn btn-info" id='part-edit'>Edit supplier part</button>
|
||||||
<button class="btn btn-info">Edit supplier part</button>
|
<button class="btn btn-danger" id='part-delete'>Delete supplier part</button>
|
||||||
</a>
|
|
||||||
<a href="{% url 'supplier-part-delete' part.id %}">
|
|
||||||
<button class="btn btn-danger">Delete supplier part</button>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'modal.html' %}
|
||||||
|
{% include 'modal_delete.html' %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
$('#part-edit').click(function () {
|
||||||
|
launchModalForm("#modal-form",
|
||||||
|
"{% url 'supplier-part-edit' part.id %}",
|
||||||
|
{
|
||||||
|
reload: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#part-delete').click(function() {
|
||||||
|
launchDeleteForm("#modal-delete",
|
||||||
|
"{% url 'supplier-part-delete' part.id %}",
|
||||||
|
{
|
||||||
|
redirect: "{% url 'company-index' %}"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -80,11 +80,7 @@ class EditSupplierPartForm(forms.ModelForm):
|
|||||||
super(EditSupplierPartForm, self).__init__(*args, **kwargs)
|
super(EditSupplierPartForm, 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 = SupplierPart
|
model = SupplierPart
|
||||||
|
@ -74,7 +74,8 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
$("#new-bom-item").click(function () {
|
$("#new-bom-item").click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm("#modal-form",
|
||||||
"{% url 'bom-item-create' %}/?parent={{ part.id }}");
|
"{% url 'bom-item-create' %}",
|
||||||
|
{data: {parent: {{ part.id }} }});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
{% extends "part/part_base.html" %}
|
{% extends "part/part_base.html" %}
|
||||||
|
{% load static %}
|
||||||
{% block details %}
|
{% block details %}
|
||||||
|
|
||||||
{% include 'part/tabs.html' with tab='suppliers' %}
|
{% include 'part/tabs.html' with tab='suppliers' %}
|
||||||
|
|
||||||
<h3>Part Suppliers</h3>
|
<h3>Part Suppliers</h3>
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped" id='supplier-table' data-sorting='true'>
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>SKU</th>
|
<th>SKU</th>
|
||||||
<th>Supplier</th>
|
<th>Supplier</th>
|
||||||
<th>MPN</th>
|
<th>MPN</th>
|
||||||
<th>URL</th>
|
<th>URL</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for spart in part.supplier_parts.all %}
|
{% for spart in part.supplier_parts.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{% url 'supplier-part-detail' spart.id %}">{{ spart.SKU }}</a></td>
|
<td><a href="{% url 'supplier-part-detail' spart.id %}">{{ spart.SKU }}</a></td>
|
||||||
@ -25,12 +28,38 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<a href="{% url 'supplier-part-create' %}?part={{ part.id }}">
|
<button class="btn btn-success" id='supplier-create'>New Supplier Part</button>
|
||||||
<button class="btn btn-success">New Supplier Part</button>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'modal.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 (){
|
||||||
|
|
||||||
|
$('#supplier-table').footable();
|
||||||
|
|
||||||
|
$('#supplier-create').click(function () {
|
||||||
|
launchModalForm("#modal-form",
|
||||||
|
"{% url 'supplier-part-create' %}",
|
||||||
|
{
|
||||||
|
reload: true,
|
||||||
|
data: {part: {{ part.id }} }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -224,17 +224,21 @@ class SupplierPartDetail(DetailView):
|
|||||||
queryset = SupplierPart.objects.all()
|
queryset = SupplierPart.objects.all()
|
||||||
|
|
||||||
|
|
||||||
class SupplierPartEdit(UpdateView):
|
class SupplierPartEdit(AjaxUpdateView):
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
template_name = 'company/partedit.html'
|
template_name = 'company/partedit.html'
|
||||||
context_object_name = 'part'
|
context_object_name = 'part'
|
||||||
form_class = EditSupplierPartForm
|
form_class = EditSupplierPartForm
|
||||||
|
ajax_template_name = 'modal_form.html'
|
||||||
|
ajax_form_title = 'Edit Supplier Part'
|
||||||
|
|
||||||
|
|
||||||
class SupplierPartCreate(CreateView):
|
class SupplierPartCreate(AjaxCreateView):
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
form_class = EditSupplierPartForm
|
form_class = EditSupplierPartForm
|
||||||
template_name = 'company/partcreate.html'
|
ajax_template_name = 'modal_form.html'
|
||||||
|
ajax_form_title = 'Create new Supplier Part'
|
||||||
|
#template_name = 'company/partcreate.html'
|
||||||
context_object_name = 'part'
|
context_object_name = 'part'
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
@ -255,13 +259,7 @@ class SupplierPartCreate(CreateView):
|
|||||||
return initials
|
return initials
|
||||||
|
|
||||||
|
|
||||||
class SupplierPartDelete(DeleteView):
|
class SupplierPartDelete(AjaxDeleteView):
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
success_url = '/supplier/'
|
success_url = '/supplier/'
|
||||||
template_name = 'company/partdelete.html'
|
template_name = 'company/partdelete.html'
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
|
||||||
if 'confirm' in request.POST:
|
|
||||||
return super(SupplierPartDelete, self).post(request, *args, **kwargs)
|
|
||||||
else:
|
|
||||||
return HttpResponseRedirect(self.get_object().get_absolute_url())
|
|
||||||
|
Loading…
Reference in New Issue
Block a user