mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
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:
@@ -29,7 +29,7 @@ class AssetAuditForm(AssetForm):
|
||||
|
||||
|
||||
class AssetSearchForm(forms.Form):
|
||||
query = forms.CharField(required=False)
|
||||
q = forms.CharField(required=False)
|
||||
category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False)
|
||||
status = forms.ModelMultipleChoiceField(models.AssetStatus.objects.all(), required=False)
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
{% block content %}
|
||||
<h1>Asset List</h1>
|
||||
<form id="asset-search-form" method="GET" class="form py-2">
|
||||
<div class="row my-2">
|
||||
<form id="asset-search-form" method="GET" class="form">
|
||||
<div class="row py-2">
|
||||
<div class="input-group">
|
||||
{% render_field form.query|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' style="width: 250px"%}
|
||||
<label for="query" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||
{% render_field form.q|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' style="width: 250px"%}
|
||||
<label for="q" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||
<span class="input-group-append"><button type="submit" class="btn btn-primary" id="id_search">Search</button></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,5 +49,4 @@
|
||||
{% paginator %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -40,5 +40,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block titleelements_right %}
|
||||
{% include 'partials/search.html' %}
|
||||
{% include 'partials/navbar_user.html' %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -41,7 +41,7 @@ class AssetList(LoginRequiredMixin, generic.ListView):
|
||||
return self.model.objects.none()
|
||||
|
||||
# TODO Feedback to user when search fails
|
||||
query_string = form.cleaned_data['query'] or ""
|
||||
query_string = form.cleaned_data['q'] or ""
|
||||
if len(query_string) == 0:
|
||||
queryset = self.model.objects.all()
|
||||
elif len(query_string) >= 3:
|
||||
|
||||
Reference in New Issue
Block a user