mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
navigation plugin
This commit is contained in:
parent
4c8318440c
commit
1c89e83d28
@ -73,6 +73,27 @@ class UrlsMixin:
|
||||
does this plugin use custom urls
|
||||
"""
|
||||
return bool(self.urls)
|
||||
|
||||
|
||||
class NavigationMixin:
|
||||
"""Mixin that enables adding navigation links with the plugin"""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.add_mixin('navigation', 'has_naviation')
|
||||
self.navigation = self.setup_navigation()
|
||||
|
||||
def setup_navigation(self):
|
||||
"""
|
||||
setup navigation links for this plugin
|
||||
"""
|
||||
return getattr(self, 'NAVIGATION', None)
|
||||
|
||||
@property
|
||||
def has_naviation(self):
|
||||
"""
|
||||
does this plugin define navigation elements
|
||||
"""
|
||||
return bool(self.navigation)
|
||||
# endregion
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from django.http import HttpResponse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, IntegrationPlugin):
|
||||
class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPlugin):
|
||||
"""
|
||||
An full integration plugin
|
||||
"""
|
||||
@ -34,6 +34,10 @@ class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, IntegrationPlugin):
|
||||
},
|
||||
}
|
||||
|
||||
NAVIGATION= [
|
||||
{'name': 'SampleIntegration', 'link': 'SampleIntegrationPlugin:hi'},
|
||||
]
|
||||
|
||||
|
||||
class OtherIntegrationPlugin(UrlsMixin, IntegrationPlugin):
|
||||
"""
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% load static %}
|
||||
{% load inventree_extras %}
|
||||
{% load plugin_extras %}
|
||||
{% load i18n %}
|
||||
|
||||
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||
@ -57,6 +58,23 @@
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% plugin_list as pl_list %}
|
||||
{% for plugin_key, plugin in pl_list.items %}
|
||||
{% mixin_enabled plugin 'navigation' as navigation %}
|
||||
{% if navigation %}
|
||||
|
||||
<li class='nav navbar-nav'>
|
||||
<a class='dropdown-toggle' data-toggle='dropdown' href='#'><span class='{{plugin.icon}} icon-header'></span>{{plugin.plugin_name}}</a>
|
||||
<ul class='dropdown-menu'>
|
||||
{% for nav_item in plugin.navigation %}
|
||||
<li><a href="{% url nav_item.name %}"><span class='{{nav_item.icon}} icon-header'></span>{{nav_item.name}}</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% include "search_form.html" %}
|
||||
|
Loading…
Reference in New Issue
Block a user