Tweak PluginMenuButton icon_class to require additional "fa" class

This commit is contained in:
Jeremy Stretch 2020-04-10 10:36:03 -04:00
parent 19a10cee82
commit 5de085d83d
3 changed files with 6 additions and 6 deletions

View File

@ -304,8 +304,8 @@ menu_items = (
link='plugins:netbox_animal_sounds:random_animal',
link_text='Random sound',
buttons=(
PluginMenuButton('home', 'Button A', 'fa-info', ButtonColorChoices.BLUE),
PluginMenuButton('home', 'Button B', 'fa-warning', ButtonColorChoices.GREEN),
PluginMenuButton('home', 'Button A', 'fa fa-info', ButtonColorChoices.BLUE),
PluginMenuButton('home', 'Button B', 'fa fa-warning', ButtonColorChoices.GREEN),
)
),
)
@ -322,7 +322,7 @@ A `PluginMenuButton` has the following attributes:
* `link` - The name of the URL path to which this button links
* `title` - The tooltip text (displayed when the mouse hovers over the button)
* `icon_class` - Button icon CSS class
* `icon_class` - Button icon CSS class (NetBox currently supports [Font Awesome 4.7](https://fontawesome.com/v4.7.0/icons/))
* `color` - One of the choices provided by `ButtonColorChoices` (optional)
* `permissions` - A list of permissions required to display this button (optional)

View File

@ -9,12 +9,12 @@ menu_items = (
PluginMenuButton(
link='admin:dummy_plugin_dummymodel_add',
title='Add a new dummy model',
icon_class='fa-plus',
icon_class='fa fa-plus',
),
PluginMenuButton(
link='admin:dummy_plugin_dummymodel_add',
title='Add a new dummy model',
icon_class='fa-plus',
icon_class='fa fa-plus',
),
)
),

View File

@ -10,7 +10,7 @@
<div class="buttons pull-right">
{% for button in menu_item.buttons %}
{% if not button.permissions or request.user|has_perms:button.permissions %}
<a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="fa {{ button.icon_class }}"></i></a>
<a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="{{ button.icon_class }}"></i></a>
{% endif %}
{% endfor %}
</div>