mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Initial work on BS4 button templatetag
Newfeatureitis strikes again
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
{% load button from filters %}
|
||||
<div class="btn-group py-3">
|
||||
<a href="{% url 'event_update' event.pk %}" class="btn btn-warning"><span
|
||||
class="fas fa-edit"></span> <span
|
||||
class="hidden-xs">Edit</span></a>
|
||||
{% button 'event_update' event.pk 'edit' %}
|
||||
{% if event.is_rig %}
|
||||
<a href="{% url 'event_print' event.pk %}" target="_blank" class="btn btn-primary"><i
|
||||
class="fas fa-print"></i> <span
|
||||
class="hidden-xs">Print</span></a>
|
||||
{% button 'event_print' event.pk 'print' %}
|
||||
{% endif %}
|
||||
<a href="{% url 'event_duplicate' event.pk %}" class="btn btn-info" title="Duplicate Rig"><span
|
||||
class="fas fa-copy"></span> <span
|
||||
class="hidden-xs">Duplicate</span></a>
|
||||
{% button 'event_duplicate' event.pk 'duplicate' %}
|
||||
{% if event.is_rig %}
|
||||
{% if event.internal %}
|
||||
<a class="btn item-add modal-href event-authorise-request
|
||||
|
||||
@@ -186,3 +186,20 @@ def linkornone(attr, namespace, autoescape=True):
|
||||
return mark_safe("<a href='{}://{}' target='_blank'><span class='overflow-ellipsis'>{}</span></a>".format(namespace, attr, str(attr)))
|
||||
else:
|
||||
return "None"
|
||||
|
||||
|
||||
@register.inclusion_tag('button.html')
|
||||
def button(url, pk, type, clazz=None, icon=None, text=None):
|
||||
if type == 'edit':
|
||||
clazz = "btn-warning"
|
||||
icon = "fa-edit"
|
||||
text = "Edit"
|
||||
elif type == 'print':
|
||||
clazz = "btn-primary"
|
||||
icon = "fa-print"
|
||||
text = "Print"
|
||||
elif type == 'duplicate':
|
||||
clazz = "btn-info"
|
||||
icon = "fa-copy"
|
||||
text = "Duplicate"
|
||||
return {'target': url, 'id': pk, 'class': clazz, 'icon': icon, 'text': text}
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
<tbody id="asset_table_body">
|
||||
{% for item in object_list %}
|
||||
<tr class="table-{{ item.status.display_class|default:'' }} assetRow">
|
||||
<th scope="row"><a class="assetID" href="{% url 'asset_detail' item.asset_id %}">{{ item.asset_id }}</a></th>
|
||||
<td class="assetDesc"><span class="text-truncate d-inline-block">{{ item.description }}</span></td>
|
||||
<td class="assetCategory">{{ item.category }}</td>
|
||||
<td class="assetStatus">{{ item.status }}</td>
|
||||
<th scope="row" class="align-middle"><a class="assetID" href="{% url 'asset_detail' item.asset_id %}">{{ item.asset_id }}</a></th>
|
||||
<td class="assetDesc"><span class="text-truncate d-inline-block align-middle">{{ item.description }}</span></td>
|
||||
<td class="assetCategory align-middle">{{ item.category }}</td>
|
||||
<td class="assetStatus align-middle">{{ item.status }}</td>
|
||||
<td class="d-none d-sm-table-cell">
|
||||
{% if audit %}
|
||||
<a type="button" class="btn btn-info btn-sm modal-href" href="{% url 'asset_audit' item.asset_id %}"><i class="fas fa-certificate"></i> Audit</a>
|
||||
|
||||
1
templates/button.html
Normal file
1
templates/button.html
Normal file
@@ -0,0 +1 @@
|
||||
<a href="{% url target id %}" class="btn {{ class }}" target="_blank"><span class="fas {{ icon }}"></span> <span class="hidden-xs">{{ text }}</span></a>
|
||||
Reference in New Issue
Block a user