2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 13:35:40 +00:00

Merge pull request #288 from SchrodingersGat/tree-badges

Tree badges
This commit is contained in:
Oliver
2019-05-09 23:06:32 +10:00
committed by GitHub
13 changed files with 142 additions and 26 deletions

View File

@ -14,6 +14,7 @@ from rest_framework import generics, permissions
from django.db.models import Q
from django.conf.urls import url, include
from django.urls import reverse
from .models import Part, PartCategory, BomItem, PartStar
from .models import SupplierPart, SupplierPriceBreak
@ -30,6 +31,10 @@ class PartCategoryTree(TreeSerializer):
title = "Parts"
model = PartCategory
@property
def root_url(self):
return reverse('part-index')
class CategoryList(generics.ListCreateAPIView):

View File

@ -47,18 +47,18 @@ class PartCategory(InvenTreeTree):
verbose_name = "Part Category"
verbose_name_plural = "Part Categories"
@property
def item_count(self):
return self.partcount
@property
def partcount(self):
""" Return the total part count under this category
(including children of child categories)
"""
count = self.parts.count()
for child in self.children.all():
count += child.partcount
return count
return len(Part.objects.filter(category__in=self.getUniqueChildren(),
active=True))
@property
def has_parts(self):

View File

@ -1,7 +1,7 @@
<div class='navigation'>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li><a href='#' id='toggle-part-tree'><b>+</b></a></li>
<li><a href='#' id='toggle-part-tree'><b><span class='glyphicon glyphicon-small glyphicon-th-list'></span></b></a></li>
<li class="breadcrumb-item{% if category is None %} active" aria-current="page{% endif %}"><a href="/part/">Parts</a></li>
{% if category %}
{% for path_item in category.parentpath %}

View File

@ -34,7 +34,11 @@ InvenTree | Part List
{% block js_ready %}
{{ block.super }}
loadTree("{% url 'api-part-tree' %}",
"#part-tree");
"#part-tree",
{
name: 'part',
}
);
$("#toggle-part-tree").click(function() {
toggleSideNav("#sidenav");