{% extends "part/part_app_base.html" %} {% load static %} {% load i18n %} {% block sidebar %} {% include 'part/category_sidebar.html' %} {% endblock %} {% block heading %} {% if category %} {% trans "Part Category" %}: {{ category.name }} {% else %} {% trans "Parts" %} {% endif %} {% endblock %} {% block actions %} {% if user.is_staff and roles.part_category.change %} {% url 'admin:part_partcategory_change' category.pk as url %} {% include "admin_button.html" with url=url %} {% endif %} {% if category %} {% if roles.part_category.change %} {% endif %} {% if roles.part_category.delete %} {% endif %} {% endif %} {% if roles.part_category.add %} {% endif %} {% endblock %} {% block details_left %} {% if category %}

{{ category.description }}

{% else %}

{% trans "Top level part category" %}

{% endif %} {% endblock %} {% block details_right %} {% if category %} {% 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 "Part Categories" %} {{ category_count }}
{% trans "Parts" %} {{ part_count }}
{% endif %} {% endblock %} {% block page_content %} {% if messages %} {% for message in messages %}
{{ message|safe }}
{% endfor %} {% endif %}

{% trans "Parts" %}

{% include "spacer.html" %}
{% if roles.part.add %} {% endif %}
{% include "filter_list.html" with id="parts" %}

{% trans "Part Parameters" %}

{% trans "Subcategories" %}

{% include "filter_list.html" with id="category" %}
{% endblock %} {% block js_load %} {{ block.super }} {% endblock %} {% block js_ready %} {{ block.super }} {% if category %} loadParametricPartTable( "#parametric-part-table", { headers: {{ headers|safe }}, data: {{ parameters|safe }}, } ); {% endif %} enableSidebar('category'); loadPartCategoryTable( $('#subcategory-table'), { params: { {% if category %} parent: {{ category.pk }}, {% else %} parent: null, {% endif %} } } ); $("#cat-create").click(function() { var fields = categoryFields(); {% if category %} fields.parent.value = {{ category.pk }}; {% endif %} constructForm('{% url "api-part-category-list" %}', { fields: fields, method: 'POST', title: '{% trans "Create Part Category" %}', follow: true, }); }); $("#part-export").click(function() { var url = "{% url 'part-export' %}?category={{ category.id }}"; location.href = url; }); {% if roles.part.add %} $("#part-create").click(function() { var fields = partFields({ create: true, }); {% if category %} fields.category.value = {{ category.pk }}; {% endif %} constructForm('{% url "api-part-list" %}', { method: 'POST', fields: fields, groups: partGroups(), title: '{% trans "Create Part" %}', onSuccess: function(data) { // Follow the new part location.href = `/part/${data.pk}/`; }, }); }); {% endif %} {% if category %} $("#cat-edit").click(function () { editCategory({{ category.pk }}); }); {% 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, gridView: true, }, ); {% endblock %}