mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 14:28:48 +00:00
Add same breadcrumb tree for StockLocation and StockItem
This commit is contained in:
parent
e9ae3eb01d
commit
9e16989c91
@ -277,6 +277,24 @@ class StockLocationList(generics.ListCreateAPIView):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class StockLocationTree(generics.ListAPIView):
|
||||||
|
"""
|
||||||
|
API endpoint for accessing a list of StockLocation objects,
|
||||||
|
ready for rendering as a tree
|
||||||
|
"""
|
||||||
|
|
||||||
|
queryset = StockLocation.objects.all()
|
||||||
|
serializer_class = StockSerializers.LocationTreeSerializer
|
||||||
|
|
||||||
|
filter_backends = [
|
||||||
|
DjangoFilterBackend,
|
||||||
|
filters.OrderingFilter,
|
||||||
|
]
|
||||||
|
|
||||||
|
# Order by tree level (top levels first) and then name
|
||||||
|
ordering = ['level', 'name']
|
||||||
|
|
||||||
|
|
||||||
class StockFilter(rest_filters.FilterSet):
|
class StockFilter(rest_filters.FilterSet):
|
||||||
"""
|
"""
|
||||||
FilterSet for StockItem LIST API
|
FilterSet for StockItem LIST API
|
||||||
@ -1182,6 +1200,9 @@ class LocationDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
stock_api_urls = [
|
stock_api_urls = [
|
||||||
url(r'^location/', include([
|
url(r'^location/', include([
|
||||||
|
|
||||||
|
url(r'^tree/', StockLocationTree.as_view(), name='api-location-tree'),
|
||||||
|
|
||||||
url(r'^(?P<pk>\d+)/', LocationDetail.as_view(), name='api-location-detail'),
|
url(r'^(?P<pk>\d+)/', LocationDetail.as_view(), name='api-location-detail'),
|
||||||
url(r'^.*$', StockLocationList.as_view(), name='api-location-list'),
|
url(r'^.*$', StockLocationList.as_view(), name='api-location-list'),
|
||||||
])),
|
])),
|
||||||
|
@ -390,6 +390,20 @@ class SerializeStockItemSerializer(serializers.Serializer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class LocationTreeSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||||
|
"""
|
||||||
|
Serializer for a simple tree view
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = StockLocation
|
||||||
|
fields = [
|
||||||
|
'pk',
|
||||||
|
'name',
|
||||||
|
'parent',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class LocationSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
class LocationSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||||
""" Detailed information about a stock location
|
""" Detailed information about a stock location
|
||||||
"""
|
"""
|
||||||
|
@ -9,9 +9,15 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
<a href='#' id='breadcrumb-tree-toggle' class="breadcrumb-item"><i class="fas fa-bars"></i></a>
|
||||||
{% include 'stock/loc_link.html' with location=item.location %}
|
{% include 'stock/loc_link.html' with location=item.location %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumb_tree %}
|
||||||
|
<div id="breadcrumb-tree"></div>
|
||||||
|
{% endblock breadcrumb_tree %}
|
||||||
|
|
||||||
|
|
||||||
{% block heading %}
|
{% block heading %}
|
||||||
{% trans "Stock Item" %}: {{ item.part.full_name}}
|
{% trans "Stock Item" %}: {{ item.part.full_name}}
|
||||||
{% endblock heading %}
|
{% endblock heading %}
|
||||||
@ -611,4 +617,18 @@ $('#serial-number-search').click(function() {
|
|||||||
findStockItemBySerialNumber({{ item.part.pk }});
|
findStockItemBySerialNumber({{ item.part.pk }});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
enableBreadcrumbTree({
|
||||||
|
label: 'stockitem',
|
||||||
|
url: '{% url "api-location-tree" %}',
|
||||||
|
{% if item.location %}
|
||||||
|
selected: {{ item.location.pk }},
|
||||||
|
{% endif %}
|
||||||
|
processNode: function(node) {
|
||||||
|
node.text = node.name;
|
||||||
|
node.href = `/stock/item/${node.pk}/`;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
{% include "stock/location_sidebar.html" %}
|
{% include "stock/location_sidebar.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumb_tree %}
|
||||||
|
<div id="breadcrumb-tree"></div>
|
||||||
|
{% endblock breadcrumb_tree %}
|
||||||
|
|
||||||
{% block heading %}
|
{% block heading %}
|
||||||
{% if location %}
|
{% if location %}
|
||||||
{% trans "Stock Location" %}: {{ location.name }}
|
{% trans "Stock Location" %}: {{ location.name }}
|
||||||
@ -348,4 +352,19 @@
|
|||||||
|
|
||||||
enableSidebar('stocklocation');
|
enableSidebar('stocklocation');
|
||||||
|
|
||||||
|
// Enable breadcrumb tree view
|
||||||
|
enableBreadcrumbTree({
|
||||||
|
label: 'location',
|
||||||
|
url: '{% url "api-location-tree" %}',
|
||||||
|
{% if location %}
|
||||||
|
selected: {{ location.pk }},
|
||||||
|
{% endif %}
|
||||||
|
processNode: function(node) {
|
||||||
|
node.text = node.name;
|
||||||
|
node.href = `/stock/location/${node.pk}/`;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
|
<a href='#' id='breadcrumb-tree-toggle' class="breadcrumb-item"><i class="fas fa-bars"></i></a>
|
||||||
{% if item %}
|
{% if item %}
|
||||||
{% include 'stock/loc_link.html' with location=item.location %}
|
{% include 'stock/loc_link.html' with location=item.location %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include 'stock/loc_link.html' with location=location %}
|
{% include 'stock/loc_link.html' with location=location %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock breadcrumbs %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user