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

Added pages for editing categories

- category-detail
- category-delete
- category-edit
- category-new
This commit is contained in:
Oliver
2018-04-15 11:40:03 +10:00
parent 5b5b8f4d12
commit 17b9f4ec8c
11 changed files with 249 additions and 35 deletions

View File

@@ -0,0 +1,50 @@
{% extends 'base.html' %}
{% block content %}
<div class="panel panel-danger">
<div class="panel-heading">Are you sure you want to delete category '{{ category.name }}'?</div>
<div class='panel-body'>
<p><b>Deleting this category is a permanent action and cannot be undone.</b></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
{% if category.parent %}
the '{{ category.parent.name }}' category.
{% else %}
the top level 'Parts' category.
{% endif %}
</p>
<ul class='list-group'>
{% for cat in category.children.all %}
<li class='list-group-item'>{{ cat.name }} - {{ cat.description }}</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'>{{ part.name }} - {{ part.description }}</li>
{% endfor %}
</ul>
{% endif %}
<form action="" method="post">{% csrf_token %}
<input type="submit" name='confirm' value="Confirm" />
<input type="submit" name="cancel" value="Cancel" />
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,31 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
{% include "part/cat_link.html" with category=category %}
{% include "part/category_subcategories.html" with children=category.children.all %}
{% include "part/category_parts.html" with parts=category.parts.all %}
<div class='container-fluid'>
<a href="{% url 'category-create' %}?category={{ category.id }}">
<button class="btn btn-default">New Category</button>
</a>
<a href="{% url 'part-create' %}?category={{ category.id }}">
<button class="btn btn-default">New Part</button>
</a>
<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="button btn-danger">Delete Category</button>
</a>
</div>
{% endblock %}

View File

@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block content %}
{% include "part/cat_link.html" with category=category %}
<div class='panel panel-primary'>
<div class='panel-heading'>Edit details for category '{{ category.name }}'</div>
<div class='panel-body'>
{% load crispy_forms_tags %}
{% crispy form %}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
{% include "part/cat_link.html" with category=category %}
<div class='panel panel-primary'>
<div class='panel-heading'>Create a new part category{% if category %} in category '{{ category.name }}'{% endif %}</div>
<div class='panel-body'>
{% load crispy_forms_tags %}
{% crispy form %}
{% endblock %}

View File

@@ -0,0 +1,10 @@
{% if parts|length > 0 %}
Parts:
<ul class="list-group">
{% for part in parts %}
<li class="list-group-item">
<a href="{% url 'part-detail' part.id %}">{{ part.name }}</a> - {{ part.description }}
</li>
{% endfor %}
</ul>
{% endif %}

View File

@@ -0,0 +1,11 @@
{% if children|length > 0 %}
Subcategories:
<ul class="list-group">
{% for child in children %}
<li class="list-group-item">
<a href="{% url 'category-detail' child.id %}">{{ child.name }}</a> - {{ child.description }}
<span class='badge'>{{ child.partcount }}</span>
</li>
{% endfor %}
</ul>
{% endif %}

View File

@@ -2,10 +2,14 @@
{% block details %}
Edit part information:
<div class='panel panel-primary'>
<div class='panel-heading'>Edit details for part '{{ part.name }}'</div>
<div class='panel-body'>
{% load crispy_forms_tags %}
{% crispy form %}
</div>
{% endblock %}

View File

@@ -5,31 +5,17 @@
{% include "part/cat_link.html" with category=category %}
{% if children|length > 0 %}
Subcategories:
<ul class="list-group">
{% for child in children %}
<li class="list-group-item">
<a href="/part/list/?category={{ child.id }}">{{ child.name }}</a> - {{ child.description }}
<span class='badge'>{{ child.partcount }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
{% include "part/category_subcategories.html" with children=children %}
{% if parts|length > 0 %}
Parts:
<ul class="list-group">
{% for part in parts %}
<li class="list-group-item">
<a href="{% url 'part-detail' part.id %}">{{ part.name }}</a> - {{ part.description }}
</li>
{% endfor %}
</ul>
{% endif %}
{% include "part/category_parts.html" with parts=parts %}
<a href="/part/create/{% if category %}?category={{ category.id }}{% endif %}">
<div class='container-fluid'>
<a href="{% url 'category-create' %}">
<button class="btn btn-default">New Category</button>
</a>
<a href="{% url 'part-create' %}">
<button class="btn btn-default">New Part</button>
</a>
</div>
{% endblock %}