{% extends "part/part_app_base.html" %} {% load static %} {% load i18n %} {% block content %}
{% if category %}

{{ category.name }} {% if user.is_staff and roles.part.change %} {% endif %}

{{ category.description }}

{% else %}

{% trans "Part Categories" %}

{% trans "All parts" %}

{% endif %}

{% if roles.part.add %} {% endif %} {% if category %} {% if roles.part.change %} {% endif %} {% if roles.part.delete %} {% endif %} {% endif %}

{% if category %}

{% trans "Category Details" %}

{% if category.default_location %} {% endif %} {% if category.default_keywords %} {% endif %}
{% trans "Category Path" %} {{ category.pathstring }}
{% trans "Category Description" %} {{ category.description }}
{% trans "Default Location" %} {{ category.default_location.pathstring }}
{% trans "Keywords" %} {{ category.default_keywords }}
{% trans "Subcategories" %} {{ category.children.count }}
{% trans "Parts (Including subcategories)" %} {{ category.partcount }}
{% else %}

{% trans "Category Details" %}

{% trans "Part Categories" %} {{ category_count }}
{% trans "Parts" %} {{ part_count }}
{% endif %}
{% if category and category.children.all|length > 0 %} {% include "part/subcategories.html" with children=category.children.all collapse_id="categories" %} {% elif children|length > 0 %} {% include "part/subcategories.html" with children=children collapse_id="categories" %} {% endif %}
{% if roles.part.add %} {% endif %}
{% block category_tables %}
{% endblock category_tables %} {% endblock %} {% block js_load %} {{ block.super }} {% endblock %} {% block js_ready %} {{ block.super }} if (inventreeLoadInt("show-part-cats") == 1) { $("#collapse-item-categories").collapse('show'); } $("#collapse-item-categories").on('shown.bs.collapse', function() { inventreeSave('show-part-cats', 1); }); $("#collapse-item-categories").on('hidden.bs.collapse', function() { inventreeDel('show-part-cats'); }); $("#cat-create").click(function() { launchModalForm( "{% url 'category-create' %}", { follow: true, {% if category %} data: { category: {{ category.id }} }, {% endif %} secondary: [ { field: 'default_location', label: '{% trans "New Location" %}', title: '{% trans "Create new location" %}', url: "{% url 'stock-location-create' %}", }, { field: 'parent', label: '{% trans "New Category" %}', title: '{% trans "Create new category" %}', url: "{% url 'category-create' %}", }, ] } ); }) $("#part-export").click(function() { var url = "{% url 'part-export' %}?category={{ category.id }}"; location.href = url; }); {% if roles.part.add %} $("#part-create").click(function() { launchModalForm( "{% url 'part-create' %}", { follow: true, data: { {% if category %} category: {{ category.id }} {% endif %} }, secondary: [ { field: 'category', label: '{% trans "New Category" %}', title: '{% trans "Create new Part Category" %}', url: "{% url 'category-create' %}", }, { field: 'default_location', label: '{% trans "New Location" %}', title: '{% trans "Create new Stock Location" %}', url: "{% url 'stock-location-create' %}", } ] } ); }); {% endif %} {% if category %} $("#cat-edit").click(function () { launchModalForm( "{% url 'category-edit' category.id %}", { reload: true }, ); return false; }); {% if category.parent %} var redirect = "{% url 'category-detail' category.parent.id %}"; {% else %} var redirect = "{% url 'part-index' %}"; {% endif %} $('#cat-delete').click(function() { launchModalForm( "{% url 'category-delete' category.id %}", { redirect: redirect } ); }); {% endif %} loadPartTable( "#part-table", "{% url 'api-part-list' %}", { params: { {% if category %}category: {{ category.id }}, {% else %}category: "null", {% endif %} }, buttons: ['#part-options'], checkbox: true, }, ); {% endblock %}