2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 15:41:10 +00:00

Modal for edit and delete part category

This commit is contained in:
Oliver
2018-04-27 20:42:12 +10:00
parent 5162c1d11f
commit bc3dca3aba
4 changed files with 61 additions and 58 deletions

View File

@@ -1,41 +1,33 @@
{% extends 'delete_obj.html' %}
{% block del_title %}
Are you sure you want to delete category '{{ category.name }}'?
{% endblock %}
{% block del_body %}
{% if category.children.all|length > 0 %}
<p>This category contains {{ category.children.all|length }} child categories.<br>
If this category is deleted, these child categories will be moved to
{% if category.parent %}
the '{{ category.parent.name }}' category.
{% else %}
the top level 'Parts' category.
{% endif %}
</p>
{% if category.children.all|length > 0 %}
<p>This category contains {{ category.children.all|length }} child categories.<br>
If this category is deleted, these child categories will be moved to
<ul class='list-group'>
{% for cat in category.children.all %}
<li class='list-group-item'><b>{{ cat.name }}</b> - <i>{{ cat.description }}</i></li>
{% endfor %}
</ul>
{% endif %}
{% if category.parts.all|length > 0 %}
<p>This category contains {{ category.parts.all|length }} parts.<br>
{% if category.parent %}
the '{{ category.parent.name }}' category.
If this category is deleted, these parts will be moved to the parent category '{{ category.parent.pathstring }}'
{% else %}
the top level 'Parts' category.
If this category is deleted, these parts will be moved to the top-level category 'Parts'
{% endif %}
</p>
<ul class='list-group'>
{% for cat in category.children.all %}
<li class='list-group-item'><b>{{ cat.name }}</b> - <i>{{ cat.description }}</i></li>
{% endfor %}
</ul>
{% endif %}
{% if category.parts.all|length > 0 %}
<p>This category contains {{ category.parts.all|length }} parts.<br>
{% if category.parent %}
If this category is deleted, these parts will be moved to the parent category '{{ category.parent.pathstring }}'
{% else %}
If this category is deleted, these parts will be moved to the top-level category 'Parts'
{% endif %}
</p>
<ul class='list-group'>
{% for part in category.parts.all %}
<li class='list-group-item'><b>{{ part.name }}</b> - <i>{{ part.description }}</i></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
</p>
<ul class='list-group'>
{% for part in category.parts.all %}
<li class='list-group-item'><b>{{ part.name }}</b> - <i>{{ part.description }}</i></li>
{% endfor %}
</ul>
{% endif %}

View File

@@ -25,19 +25,14 @@
<button type='button' class='btn btn-primary' id='create-cat'>
New Category
</button>
<button class="btn btn-success" id='create-part'>New Part</button>
<a href="{% url 'category-edit' category.id %}">
<button class="btn btn-info">Edit Category</button>
</a>
<a href="{% url 'category-delete' category.id %}">
<button class="btn btn-danger">Delete Category</button>
</a>
<button class="btn btn-info" id='edit-category'>Edit Category</button>
<button class="btn btn-success" id='create-part'>New Part</button>
<button class="btn btn-danger" id='delete-category'>Delete Category</button>
</div>
{% include 'modal.html' %}
{% include 'modal_delete.html' %}
{% endblock %}
@@ -49,6 +44,19 @@
$(document).ready(function (){
$('#part-list').footable();
$("#edit-category").click(function () {
launchModalForm("#modal-form",
"{% url 'category-edit' category.id %}",
{reload: true},
);
});
$("#delete-category").click(function() {
launchDeleteForm("#modal-delete",
"{% url 'category-delete' category.id %}",
{redirect: "{% url 'part-index' %}"});
});
$("#create-cat").click(function() {
launchModalForm("#modal-form",
"{% url 'category-create' %}",