From acf814e49e5c3d534e1bbdc36a8f3345e8d02bf6 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Wed, 30 Sep 2020 09:08:25 +0100 Subject: [PATCH] Rework button tag --- RIGS/templates/event_checklist_form.html | 7 ++----- RIGS/templates/event_detail_buttons.html | 6 +++--- RIGS/templates/partials/hs_status.html | 4 ++-- RIGS/templatetags/filters.py | 4 +++- templates/button.html | 4 ++++ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/RIGS/templates/event_checklist_form.html b/RIGS/templates/event_checklist_form.html index 2b335f33..44fc7690 100644 --- a/RIGS/templates/event_checklist_form.html +++ b/RIGS/templates/event_checklist_form.html @@ -3,6 +3,7 @@ {% load static %} {% load help_text from filters %} {% load profile_by_index from filters %} +{% load button from filters %} {% block title %}{% if edit %}Edit{% else %}Create{% endif %} Event Checklist for Event N{{ event.pk|stringformat:"05d" }}{% endblock %} @@ -362,11 +363,7 @@
-
- -
+ {% button 'submit' %}
diff --git a/RIGS/templates/event_detail_buttons.html b/RIGS/templates/event_detail_buttons.html index 5ba44e50..f60a258a 100644 --- a/RIGS/templates/event_detail_buttons.html +++ b/RIGS/templates/event_detail_buttons.html @@ -1,10 +1,10 @@ {% load button from filters %}
- {% button 'event_update' event.pk 'edit' %} + {% button 'edit' 'event_update' event.pk %} {% if event.is_rig %} - {% button 'event_print' event.pk 'print' %} + {% button 'print' 'event_print' event.pk %} {% endif %} - {% button 'event_duplicate' event.pk 'duplicate' %} + {% button 'duplicate' 'event_duplicate' event.pk %} {% if event.is_rig %} {% if event.internal %} - {% button view object.pk 'view' %} - {% button edit object.pk 'edit' %} + {% button 'view' view object.pk %} + {% button 'edit' edit object.pk %}
{% if object.reviewed_by %} Reviewed by {{object.reviewed_by}} at {{object.reviewed_at}} diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index 429da50a..7f6b58ad 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -189,7 +189,7 @@ def linkornone(attr, namespace, autoescape=True): @register.inclusion_tag('button.html') -def button(url, pk, type, clazz=None, icon=None, text=None): +def button(type, url=None, pk=None, clazz=None, icon=None, text=None): if type == 'edit': clazz = "btn-warning" icon = "fa-edit" @@ -206,4 +206,6 @@ def button(url, pk, type, clazz=None, icon=None, text=None): clazz = "btn-primary" icon = "fa-eye" text = "View" + elif type == 'submit': + return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save'} return {'target': url, 'id': pk, 'class': clazz, 'icon': icon, 'text': text} diff --git a/templates/button.html b/templates/button.html index ab15ac11..47b8b8d8 100644 --- a/templates/button.html +++ b/templates/button.html @@ -1 +1,5 @@ +{% if submit %} + +{% else %} +{% endif %}