Better approach to generic list templates + other deduplication

This commit is contained in:
2020-10-08 22:54:30 +01:00
parent af7d3c4070
commit 3903481b3d
33 changed files with 252 additions and 309 deletions

View File

@@ -0,0 +1,7 @@
{% if submit %}
<button type="submit" class="btn {{ class }}" title="{{ text }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></button>
{% elif pk %}
<a href="{% url target pk %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
{% else %}
<a href="{% url target %}" class="btn {{ class }}" {% if id %}id="{{id}}"{%endif%} {% if style %}style="{{style}}"{%endif%}><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
{% endif %}

View File

@@ -1,67 +0,0 @@
{% load url_replace from filters %}
{% load orderby from filters %}
{% load paginator from filters %}
{% load linkornone from filters %}
<div class="row justify-content-end">
<form class="form-inline">
{% csrf_token %}
<div class="input-group">
<input type="search" name="q" placeholder="Search" value="{{ request.GET.q }}"
class="form-control"/>
<span class="input-group-append"><button type="submit" class="btn btn-info" id="id_search">Search</button></span>
</div>
</form>
</div>
<div class="row justify-content-end py-3">
<a href="{% url create %}" class="btn btn-primary">New <span
class="fas fa-plus"></span></a>
</div>
<div class="row">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Name<a href="?{% orderby request 'orderBy' 'name' %}"><span class="caret"></span></a></td>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">Notes</th>
{% if union_account %} {#TODO#}
<th scope="col">Union Account</th>
{% endif %}
<th scope="col">Quick Links</th>
</tr>
</thead>
<tbody>
{% for object in object_list %}
<tr id="row_item">
<th scope="row" class="align-middle" id="cell_name">{{ object.name }}</th>
<td class="align-middle">{{ object.email|linkornone:'mailto' }}</td>
<td class="align-middle">{{ object.phone|linkornone:'tel' }}</td>
<td class="align-middle">{{ object.notes|yesno|capfirst }}</td>
{% if union_account %}
<td>{{ object.union_account|yesno|capfirst }}</td>
{% endif %}
<td>
<div class="btn-group d-flex" role="group">
<a href="{% url detail object.pk %}" class="btn btn-primary btn-sm modal-href">
<i class="fas fa-eye"></i> View
</a>
<a href="{% url edit object.pk %}" class="btn btn-warning btn-sm"><i
class="fas fa-edit"></i> Edit</a>
</div>
</td>
</tr>
{% empty %}
<tr class="table-warning">
<td colspan="6" class="text-center">Nothing found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% if is_paginated %}
<div class="row justify-content-center">
{% paginator %}
</div>
{% endif %}

View File

@@ -1,10 +1,10 @@
{% if user.is_authenticated %}
<form id="searchForm" class="form-inline flex-nowrap mx-md-3" role="form" method="GET" action="{% url 'event_archive' %}">
<form id="searchForm" class="form-inline flex-nowrap mx-md-3 px-2 border border-light rounded" role="form" method="GET" action="{% url 'event_archive' %}">
<div class="input-group input-group-sm flex-nowrap">
<div class="input-group-prepend">
<input id="id_search_input" type="search" name="q" class="form-control form-control-sm" placeholder="Search..." value="{{ request.GET.q }}" />
</div>
<select id="search-options" class="custom-select form-control w-25" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px;">
<select id="search-options" class="custom-select form-control" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px; width: 20ch;">
<option selected data-action="{% url 'event_archive' %}" href="#">Events</option>
<option data-action="{% url 'person_list' %}" href="#">People</option>
<option data-action="{% url 'organisation_list' %}" href="#">Organisations</option>
@@ -17,7 +17,7 @@
</select>
</div>
<button class="btn btn-info form-control form-control-sm btn-sm w-25" style="border-top-left-radius: 0px;border-bottom-left-radius: 0px;"><span class="fas fa-search"></span><span class="sr-only"> Search</span></button>
<a href="{% url 'search_help' %}" class="nav-link modal-href btn-sm ml-2"><span class="fas fa-question-circle"></span></a>
<a href="{% url 'search_help' %}" class="nav-link modal-href ml-2"><span class="fas fa-question-circle"></span></a>
</form>
{% endif %}