FEAT: Improve 'omni'search

- Partialised template
- Added to assets header
- Added ability to search assets/suppliers
- Improved selection logic
- Have it display current query
This commit is contained in:
2020-06-19 11:01:19 +01:00
parent e4e8823a1a
commit 84618deac0
12 changed files with 78 additions and 55 deletions

View File

@@ -53,28 +53,11 @@
{% if perms.RIGS.view_venue %}
<li class="nav-item"><a class="nav-link" href="{% url 'venue_list' %}">Venues</a></li>
{% endif %}
<form id="searchForm" class="form-inline flex-nowrap mx-3" role="form" method="GET">
<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..." />
</div>
<select id="search-options" class="custom-select form-control">
<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>
<option data-action="{% url 'venue_list' %}" href="#">Venues</option>
{% if perms.RIGS.view_invoice %}
<option data-action="{% url 'invoice_archive' %}" href="#">Invoices</option>
{% endif %}
</select>
</div>
<button class="btn btn-primary form-control form-control-sm btn-sm">Search</button>
<a href="{% url 'search_help' %}" class="nav-link modal-href btn-sm"><span class="fas fa-question-circle"></span></a>
</form>
{% endif %}
{% endblock %}
{% block titleelements_right %}
{% include 'partials/search.html' %}
{% include 'partials/navbar_user.html' %}
{% endblock %}
@@ -86,17 +69,4 @@
$('[data-toggle="tooltip"]').tooltip();
})
</script>
<script>
$(document).ready(function(){
$('#search-options option').click(function(){
$('#searchForm').attr('action', $(this).data('action')).submit();
});
$('#id_search_input').keypress(function (e) {
if (e.which == 13) {
$('#searchForm').attr('action', $('#search-options option').first().data('action')).submit();
return false;
}
});
});
</script>
{% endblock %}

View File

@@ -1,61 +0,0 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
{% block title %}Search Help{% endblock %}
{% block content %}
<div class="row">
{% if not request.is_ajax %}
<div class="col-sm-12">
<h1>Search Help</h1>
</div>
{% endif %}
<div class="col-sm-12">
<div class="card card-default">
<div class="card-header">
<h3 class="card-title">Searching Events</h3>
</div>
<div class="card-body">
<p>
Searches for entire query in:
<span class="badge badge-dark">name</span>
<span class="badge badge-dark">description</span> and
<span class="badge badge-dark">notes</span>
</p>
<p>You can search for an event by <span class="badge badge-dark">event_id</span> by entering an integer, or using the format <code>N01234</code></p>
<p>On the search results page you can also specify the date range for the <span class="badge badge-dark">start_date</span> of the event</p>
<p>Events are sorted in reverse <span class="badge badge-dark">start_date</span> order (most recent events at the top)</p>
</div>
<div class="card-header">
<h3 class="card-title">Searching People/Organisations/Venues</h3>
</div>
<div class="card-body">
<p>
Searches for entire search phrase in:
<span class="badge badge-dark">name</span>
<span class="badge badge-dark">email</span>
<span class="badge badge-dark">address</span>
<span class="badge badge-dark">notes</span> and
<span class="badge badge-dark">phone</span>
</p>
<p>You can search for an entry by <span class="badge badge-dark">id</span> by entering an integer</p>
<p>Entries are sorted in alphabetical order by <span class="badge badge-dark">name</span></p>
</div>
{% if perms.RIGS.view_invoice %}
<div class="card-header">
<h3 class="card-title">Searching Invoices</h3>
</div>
<div class="card-body">
<p>
Searches for entire search phrase in:
<span class="badge badge-dark">event__name</span>
</p>
<p>You can search for an event's invoice by entering the <span class="badge badge-dark">event_id</span> using the format <code>N01234</code></p>
<p>You can search for an invoice by <span class="badge badge-dark">invoice_id</span> using the format <code>#01234</code></p>
<p>Entering a raw integer will search by both <span class="badge badge-dark">invoice_id</span> and <span class="badge badge-dark">event_id</span></p>
<p>Entries are sorted in reverse <span class="badge badge-dark">invoice_date</span> order</p>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}

View File

@@ -13,7 +13,6 @@ urlpatterns = [
path('', login_required(views.Index.as_view()), name='index'),
path('closemodal/', views.CloseModal.as_view(), name='closemodal'),
path('search_help/', views.SearchHelp.as_view(), name='search_help'),
# People
path('people/', permission_required_with_403('RIGS.view_person')(views.PersonList.as_view()),

View File

@@ -41,10 +41,6 @@ class Index(generic.TemplateView):
return context
class SearchHelp(generic.TemplateView):
template_name = 'search_help.html'
"""
Called from a modal window (e.g. when an item is submitted to an event/invoice).
May optionally also include some javascript in a success message to cause a load of