mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Tree view now supports root URL link
This commit is contained in:
parent
d04f38c724
commit
92930766c6
@ -28,6 +28,15 @@ class TreeSerializer(views.APIView):
|
|||||||
Ref: https://github.com/jonmiles/bootstrap-treeview
|
Ref: https://github.com/jonmiles/bootstrap-treeview
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def root_url(self):
|
||||||
|
""" Return the root URL for the tree. Implementation is class dependent.
|
||||||
|
|
||||||
|
Default implementation returns #
|
||||||
|
"""
|
||||||
|
|
||||||
|
return '#'
|
||||||
|
|
||||||
def itemToJson(self, item):
|
def itemToJson(self, item):
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
@ -60,6 +69,7 @@ class TreeSerializer(views.APIView):
|
|||||||
|
|
||||||
top = {
|
top = {
|
||||||
'text': self.title,
|
'text': self.title,
|
||||||
|
'href': self.root_url,
|
||||||
'nodes': nodes,
|
'nodes': nodes,
|
||||||
'tags': [top_count],
|
'tags': [top_count],
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ from rest_framework import generics, permissions
|
|||||||
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
from .models import Part, PartCategory, BomItem, PartStar
|
from .models import Part, PartCategory, BomItem, PartStar
|
||||||
from .models import SupplierPart, SupplierPriceBreak
|
from .models import SupplierPart, SupplierPriceBreak
|
||||||
@ -30,6 +31,10 @@ class PartCategoryTree(TreeSerializer):
|
|||||||
|
|
||||||
title = "Parts"
|
title = "Parts"
|
||||||
model = PartCategory
|
model = PartCategory
|
||||||
|
|
||||||
|
@property
|
||||||
|
def root_url(self):
|
||||||
|
return reverse('part-index')
|
||||||
|
|
||||||
|
|
||||||
class CategoryList(generics.ListCreateAPIView):
|
class CategoryList(generics.ListCreateAPIView):
|
||||||
|
@ -6,6 +6,7 @@ from django_filters.rest_framework import FilterSet, DjangoFilterBackend
|
|||||||
from django_filters import NumberFilter
|
from django_filters import NumberFilter
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
from django.urls import reverse
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
from .models import StockLocation, StockItem
|
from .models import StockLocation, StockItem
|
||||||
@ -27,6 +28,10 @@ class StockCategoryTree(TreeSerializer):
|
|||||||
title = 'Stock'
|
title = 'Stock'
|
||||||
model = StockLocation
|
model = StockLocation
|
||||||
|
|
||||||
|
@property
|
||||||
|
def root_url(self):
|
||||||
|
return reverse('stock-index')
|
||||||
|
|
||||||
|
|
||||||
class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
""" API detail endpoint for Stock object
|
""" API detail endpoint for Stock object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user