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

{{ category.name }}

{{ category.description }}

{% else %}

Parts

{% endif %}

{% if category %} {% endif %}

{% if category %} {% include "part/subcategories.html" with children=category.children.all %} {% else %} {% include "part/subcategories.html" with children=children %} {% endif %}
{% endblock %} {% block js_ready %} {{ block.super }} $("#cat-create").click(function() { launchModalForm("#modal-form", "{% url 'category-create' %}", { follow: true, {% if category %} data: { category: {{ category.id }} } {% endif %} }); }) $("#part-create").click(function() { launchModalForm("#modal-form", "{% url 'part-create' %}", { follow: true, data: { {% if category %} category: {{ category.id }} {% endif %} } }); }); {% if category %} $("#cat-edit").click(function () { launchModalForm("#modal-form", "{% 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('#modal-delete', "{% 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, {% if category %} queryParams: function(p) { return { {% if category %} category: {{ category.id }}, {% endif %} } }, {% 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', }, {% if category == None %} { sortable: true, field: 'category', title: 'Category', formatter: function(value, row, index, field) { if (row.category) { return renderLink(row.category.name, row.category.url); } else { return ''; } } }, {% endif %} { field: 'total_stock', title: 'Stock', searchable: false, sortable: true, } ], url: "{% url 'api-part-list' %}", }); {% endblock %}