Navigation: Add support for link badges
Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -42,13 +42,14 @@ class Link(object):
|
||||
def remove(cls, name):
|
||||
del cls._registry[name]
|
||||
|
||||
def __init__(self, text, view=None, args=None, condition=None,
|
||||
def __init__(self, text=None, view=None, args=None, badge_text=None, condition=None,
|
||||
conditional_disable=None, description=None, html_data=None,
|
||||
html_extra_classes=None, icon=None, icon_class=None,
|
||||
keep_query=False, kwargs=None, name=None, permission=None,
|
||||
remove_from_query=None, tags=None, url=None):
|
||||
|
||||
self.args = args or []
|
||||
self.badge_text = badge_text
|
||||
self.condition = condition
|
||||
self.conditional_disable = conditional_disable
|
||||
self.description = description
|
||||
@@ -460,6 +461,11 @@ class ResolvedLink(object):
|
||||
def active(self):
|
||||
return self.link.view == self.current_view_name
|
||||
|
||||
@property
|
||||
def badge_text(self):
|
||||
if self.link.badge_text:
|
||||
return self.link.badge_text(context=self.context)
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
return self.link.description
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
{% endfor %}
|
||||
|
||||
href="{{ link.url }}"
|
||||
>{% if link.icon %}{% if not hide_icon %}<i class="hidden-xs hidden-sm hidden-md {{ link.icon }}"></i>{% endif %}{% endif %}{% if link.icon_class and not hide_icon %}{{ link.icon_class.render }}{% endif %} {{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
>{% if link.icon %}{% if not hide_icon %}
|
||||
<i class="hidden-xs hidden-sm hidden-md {{ link.icon }}"></i>
|
||||
{% endif %}{% endif %}
|
||||
{% if link.icon_class and not hide_icon %}{{ link.icon_class.render }}{% endif %}
|
||||
{{ link.text|default:'' }}{% if link.badge_text %}<span class="badge">{{ link.badge_text }}</span>{% endif %}{% if link.error %} - {{ link.error }}{% endif %}
|
||||
</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user