mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 00:12:15 +00:00
Better approach to generic list templates + other deduplication
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
|
||||
lang="{% firstof LANGUAGE_CODE 'en' %}">
|
||||
<head>
|
||||
<title>{% block title %}{% endblock %} | Rig Information Gathering System</title>
|
||||
<title>{{page_title}}{% block title %}{% endblock %} | Rig Information Gathering System</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@@ -70,7 +70,7 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% if page_title %}<h2>{{page_title}}</h2>{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{% if submit %}
|
||||
<button type="submit" class="btn {{ class }}" title="{{ text }}"><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></button>
|
||||
{% elif id %}
|
||||
<a href="{% url target id %}" class="btn {{ class }}"><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
|
||||
{% else %}
|
||||
<a href="{% url target %}" class="btn {{ class }}"><span class="fas {{ icon }}"></span> <span class="d-none d-sm-inline">{{ text }}</span></a>
|
||||
{% endif %}
|
||||
70
templates/generic_list.html
Normal file
70
templates/generic_list.html
Normal file
@@ -0,0 +1,70 @@
|
||||
{% extends override|default:"base_rigs.html" %}
|
||||
{% load url_replace from filters %}
|
||||
{% load orderby from filters %}
|
||||
{% load paginator from filters %}
|
||||
{% load linkornone from filters %}
|
||||
{% load button from filters %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
<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 'search' id="id_search" %}</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row py-3">
|
||||
<div class="col text-right">
|
||||
{% button 'new' url=create %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<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">
|
||||
{% button 'view' url=detail pk=object.pk clazz="btn-sm modal-href" %}
|
||||
{% button 'edit' url=edit pk=object.pk clazz="btn-sm modal-href" %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr class="table-warning">
|
||||
<td colspan="6" class="text-center">Nothing found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% paginator %}
|
||||
{% endblock%}
|
||||
@@ -31,7 +31,7 @@
|
||||
<h4 class="card-header">Quick Links</h4>
|
||||
<div class="list-group list-group-flush">
|
||||
<a class="list-group-item list-group-item-action" href="https://forum.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><i class="fas fa-comment-alt"></i> TEC Forum</a>
|
||||
<a class="list-group-item list-group-item-action" href="//members.nottinghamtec.co.uk/wiki" target="_blank" rel="noopener noreferrer"><i class="fas fa-pen-square"></i> TEC Wiki</a>
|
||||
<a class="list-group-item list-group-item-action" href="//wiki.nottinghamtec.co.uk" target="_blank" rel="noopener noreferrer"><i class="fas fa-pen-square"></i> TEC Wiki</a>
|
||||
{% if perms.RIGS.view_event %}
|
||||
<a class="list-group-item list-group-item-action" href="//members.nottinghamtec.co.uk/price" target="_blank"><i class="fas fa-pound-sign"></i> Price List</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
{% load url_replace from filters %}
|
||||
{% if is_paginated %}
|
||||
{% load url_replace from filters %}
|
||||
<div class="row justify-content-center pt-3">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
{% if has_previous %}
|
||||
<li class="page-item"><a class="page-link" href="?{% url_replace request 'page' previous %}">‹‹</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<ul class="pagination">
|
||||
{% if has_previous %}
|
||||
<li class="page-item"><a class="page-link" href="?{% url_replace request 'page' previous %}">‹‹</a></li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link" aria-hidden="true">‹‹</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if show_first %}
|
||||
<li class="page-item"><a class="page-link" href="?{% url_replace request 'page' first %}" class="prev">{{ first }}</a></li>
|
||||
@@ -37,4 +38,5 @@
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
7
templates/partials/button.html
Normal file
7
templates/partials/button.html
Normal 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 %}
|
||||
@@ -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 %}
|
||||
@@ -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 %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user