{% 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 %} }); }) $("#part-create").click(function() { launchModalForm( "{% url 'part-create' %}", { follow: true, data: { {% if category %} category: {{ category.id }} {% 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() { launchDeleteForm("{% url 'category-delete' category.id %}", { redirect: redirect }); }); {% endif %} $("#part-table").bootstrapTable({ sortable: true, search: true, sortName: 'description', idField: 'pk', method: 'get', pagination: true, rememberOrder: true, queryParams: function(p) { return { active: true, {% if category %} category: {{ category.id }}, include_child_categories: true, {% endif %} } }, columns: [ { checkbox: true, title: 'Select', searchable: false, }, { field: 'pk', title: 'ID', visible: false, }, { field: 'name', title: 'Part', sortable: true, formatter: function(value, row, index, field) { return renderLink(value, row.url); } }, { sortable: true, field: 'description', title: 'Description', }, { sortable: true, field: 'category_name', title: 'Category', formatter: function(value, row, index, field) { if (row.category) { return renderLink(row.category_name, "/part/category/" + row.category + "/"); } else { return ''; } } }, { field: 'total_stock', title: 'Stock', searchable: false, sortable: true, formatter: function(value, row, index, field) { if (value) { return renderLink(value, row.url + 'stock/'); } else { return "No stock"; } } } ], url: "{% url 'api-part-list' %}", }); linkButtonsToSelection( $("#part-table"), ['#part-options'] ); {% endblock %}