mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Added AjaxDeleteView
- AjaxDeleteView handles ajaxified delete GET and POST events - Added modal deletion window - Added launchDeleteForm jQuery function
This commit is contained in:
@ -7,37 +7,6 @@
|
||||
|
||||
{% block del_body %}
|
||||
|
||||
{% if part.used_in_count %}
|
||||
<p>This part is used in BOMs for {{ part.used_in_count }} other parts. If you delete this part, the BOMs for the following parts will be updated:
|
||||
<ul class="list-group">
|
||||
{% for child in part.used_in.all %}
|
||||
<li class='list-group-item'>{{ child.part.name }} - {{ child.part.description }}</li>
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if part.locations.all|length > 0 %}
|
||||
<p>There are {{ part.locations.all|length }} stock entries defined for this part. If you delete this part, the following stock entries will also be deleted:
|
||||
<ul class='list-group'>
|
||||
{% for stock in part.locations.all %}
|
||||
<li class='list-group-item'>{{ stock.location.name }} - {{ stock.quantity }} items</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if part.supplier_parts.all|length > 0 %}
|
||||
<p>There are {{ part.supplier_parts.all|length }} suppliers defined for this part. If you delete this part, the following supplier parts will also be deleted.
|
||||
<ul class='list-group'>
|
||||
{% for spart in part.supplier_parts.all %}
|
||||
<li class='list-group-item'>{{ spart.supplier.name }} - {{ spart.SKU }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if part.serials.all|length > 0 %}
|
||||
<p>There are {{ part.serials.all|length }} unique parts tracked for '{{ part.name }}'. Deleting this part will permanently remove this tracking information.</p>
|
||||
{% endif %}
|
||||
{$ include 'part/partial_delete' with part=part %}
|
||||
|
||||
{% endblock %}
|
@ -88,6 +88,7 @@
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block javascript %}
|
||||
|
||||
<script type='text/javascript' src="{% static 'script/modal_form.js' %}"></script>
|
||||
@ -97,6 +98,13 @@ $(document).ready(function () {
|
||||
$("#edit-part").click(function() {
|
||||
launchModalForm("#modal-form", "{% url 'part-edit' part.id %}");
|
||||
});
|
||||
|
||||
$('#delete-part').click(function() {
|
||||
launchDeleteForm("#modal-delete",
|
||||
"{% url 'part-delete' part.id %}",
|
||||
{redirect: "{% url 'part-index' %}"}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
32
InvenTree/part/templates/part/partial_delete.html
Normal file
32
InvenTree/part/templates/part/partial_delete.html
Normal file
@ -0,0 +1,32 @@
|
||||
{% if part.used_in_count %}
|
||||
<p>This part is used in BOMs for {{ part.used_in_count }} other parts. If you delete this part, the BOMs for the following parts will be updated:
|
||||
<ul class="list-group">
|
||||
{% for child in part.used_in.all %}
|
||||
<li class='list-group-item'>{{ child.part.name }} - {{ child.part.description }}</li>
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if part.locations.all|length > 0 %}
|
||||
<p>There are {{ part.locations.all|length }} stock entries defined for this part. If you delete this part, the following stock entries will also be deleted:
|
||||
<ul class='list-group'>
|
||||
{% for stock in part.locations.all %}
|
||||
<li class='list-group-item'>{{ stock.location.name }} - {{ stock.quantity }} items</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if part.supplier_parts.all|length > 0 %}
|
||||
<p>There are {{ part.supplier_parts.all|length }} suppliers defined for this part. If you delete this part, the following supplier parts will also be deleted.
|
||||
<ul class='list-group'>
|
||||
{% for spart in part.supplier_parts.all %}
|
||||
<li class='list-group-item'>{{ spart.supplier.name }} - {{ spart.SKU }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if part.serials.all|length > 0 %}
|
||||
<p>There are {{ part.serials.all|length }} unique parts tracked for '{{ part.name }}'. Deleting this part will permanently remove this tracking information.</p>
|
||||
{% endif %}
|
@ -19,7 +19,7 @@ from .forms import EditBomItemForm
|
||||
|
||||
from .forms import EditSupplierPartForm
|
||||
|
||||
from InvenTree.views import AjaxCreateView, AjaxUpdateView
|
||||
from InvenTree.views import AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
||||
|
||||
class PartIndex(ListView):
|
||||
model = Part
|
||||
@ -92,17 +92,21 @@ class PartEdit(AjaxUpdateView):
|
||||
ajax_form_title = 'Edit Part Properties'
|
||||
|
||||
|
||||
class PartDelete(DeleteView):
|
||||
class PartDelete(AjaxDeleteView):
|
||||
model = Part
|
||||
template_name = 'part/delete.html'
|
||||
ajax_template_name = 'part/partial_delete.html'
|
||||
ajax_form_title = 'Confirm Part Deletion'
|
||||
|
||||
success_url = '/part/'
|
||||
|
||||
"""
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'confirm' in request.POST:
|
||||
return super(PartDelete, self).post(request, *args, **kwargs)
|
||||
else:
|
||||
return HttpResponseRedirect(self.get_object().get_absolute_url())
|
||||
"""
|
||||
|
||||
|
||||
class CategoryDetail(DetailView):
|
||||
|
Reference in New Issue
Block a user