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

{{ category.name }}

{{ category.description }}

{% if category.default_location %}

Default Location: {{ category.default_location }}

{% endif %} {% else %}

Part Categories

{% endif %}

{% if category %} {% endif %}

{% if category and category.children.all|length > 0 %} {% include "part/subcategories.html" with children=category.children.all collapse_id="children"%} {% elif children|length > 0 %} {% include "part/subcategories.html" with children=children %} {% endif %}
{% endblock %} {% block js_load %} {{ block.super }} {% endblock %} {% block js_ready %} {{ block.super }} $("#cat-create").click(function() { launchModalForm( "{% url 'category-create' %}", { follow: true, {% if category %} data: { category: {{ category.id }} }, {% endif %} secondary: [ { field: 'default_location', label: 'New Location', title: 'Create new location', url: "{% url 'stock-location-create' %}", }, { field: 'parent', label: 'New Category', title: 'Create new category', url: "{% url 'category-create' %}", }, ] }); }) $("#part-create").click(function() { launchModalForm( "{% url 'part-create' %}", { follow: true, data: { {% if category %} category: {{ category.id }} {% endif %} }, secondary: [ { field: 'category', label: 'New Category', title: 'Create new Part Category', url: "{% url 'category-create' %}", }, { field: 'default_location', label: 'New Location', title: 'Create new Stock Location', url: "{% url 'stock-location-create' %}", } ] } ); }); {% 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' %}", { query: { {% if category %} category: {{ category.id }}, include_child_categories: true, {% endif %} }, buttons: ['#part-options'], }, ); {% endblock %}