Adds 'locate item' and 'locate location' buttons

This commit is contained in:
Oliver Walters 2022-05-09 22:48:26 +10:00
parent 256af802e2
commit 4704db5183
4 changed files with 23 additions and 1 deletions

View File

@ -44,6 +44,12 @@ def mixin_enabled(plugin, key, *args, **kwargs):
"""
return plugin.mixin_enabled(key)
@register.simple_tag()
def mixin_available(mixin, *args, **kwargs):
"""
Returns True if there is at least one active plugin which supports the provided mixin
"""
return len(registry.with_mixin(mixin)) > 0
@register.simple_tag()
def navigation_enabled(*args, **kwargs):

View File

@ -1,5 +1,6 @@
{% extends "page_base.html" %}
{% load static %}
{% load plugin_extras %}
{% load inventree_extras %}
{% load status_codes %}
{% load i18n %}
@ -18,7 +19,6 @@
<div id="breadcrumb-tree"></div>
{% endblock breadcrumb_tree %}
{% block heading %}
{% trans "Stock Item" %}: {{ item.part.full_name}}
{% endblock heading %}
@ -29,6 +29,12 @@
{% url 'admin:stock_stockitem_change' item.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% mixin_available "locate" as locate_available %}
{% if plugins_enabled and locate_available %}
<button id='locate-item-button' title='{% trans "Identify stock item" %}' class='btn btn-outline-secondary' typy='button'>
<span class='fas fa-search-location'></span>
</button>
{% endif %}
{% if barcodes %}
<!-- Barcode actions menu -->
<div class='btn-group' role='group'>

View File

@ -1,6 +1,7 @@
{% extends "stock/stock_app_base.html" %}
{% load static %}
{% load inventree_extras %}
{% load plugin_extras %}
{% load i18n %}
{% block sidebar %}
@ -27,6 +28,14 @@
{% include "admin_button.html" with url=url %}
{% endif %}
{% mixin_available "locate" as locate_available %}
{% if plugins_enabled and locate_available %}
<button id='locate-location-button' title='{% trans "Identify stock location" %}' class='btn btn-outline-secondary' typy='button'>
<span class='fas fa-search-location'></span>
</button>
{% endif %}
{% if barcodes %}
<!-- Barcode actions menu -->
{% if location %}

View File

@ -2,6 +2,7 @@
{% load i18n %}
{% load inventree_extras %}
{% plugins_enabled as plugins_enabled %}
{% settings_value 'BARCODE_ENABLE' as barcodes %}
{% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %}
{% settings_value "REPORT_ENABLE" as report_enabled %}