mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 11:05:41 +00:00
search page now returns matching parts
- Searches 'name' and 'description' field - Uses the JSON API
This commit is contained in:
@ -2,14 +2,58 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h3>InvenTree Search</h3>
|
<h3>Search Results</h3>
|
||||||
|
|
||||||
<p>
|
{% include "search_form.html" with query_text=query %}
|
||||||
Searched for: {{ query }}
|
|
||||||
</p>
|
<br><br>
|
||||||
|
<h3>Parts <span id='part-result-count'></span></h3>
|
||||||
|
<table class='table table-striped table-condensed' data-toolbar="#button-toolbar" id='part-results-table'>
|
||||||
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js_ready %}
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
$("#part-results-table").on('load-success.bs.table', function() {
|
||||||
|
var n = $("#part-results-table").bootstrapTable('getData').length;
|
||||||
|
$("#part-result-count").html("(found " + n + " results)");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#part-results-table").bootstrapTable({
|
||||||
|
sortable: true,
|
||||||
|
search: true,
|
||||||
|
pagination: true,
|
||||||
|
queryParams: function(p) {
|
||||||
|
return {
|
||||||
|
search: "{{ query }}",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'pk',
|
||||||
|
title: 'ID',
|
||||||
|
visible: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: 'Name',
|
||||||
|
sortable: true,
|
||||||
|
searchable: true,
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return renderLink(value, row.url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'description',
|
||||||
|
title: 'Description',
|
||||||
|
searchable: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
url: "{% url 'api-part-list' %}"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block js_load %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -12,13 +12,7 @@
|
|||||||
<li><a href="{% url 'company-index' %}">Companies</a></li>
|
<li><a href="{% url 'company-index' %}">Companies</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<form class="navbar-form navbar-left" action="{% url 'search' %}" method='post'>
|
{% include "search_form.html" %}
|
||||||
{% csrf_token %}
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="text" name='search' class="form-control" placeholder="Search">
|
|
||||||
</div>
|
|
||||||
<button type="submit" id='search-submit' class="btn btn-default">Submit</button>
|
|
||||||
</form>
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li class='dropdown'>
|
<li class='dropdown'>
|
||||||
<a class='dropdown-toggle' data-toggle='dropdown' href="#"><span class="glyphicon glyphicon-user"></span> <b>{{ user.get_username }}</b></a>
|
<a class='dropdown-toggle' data-toggle='dropdown' href="#"><span class="glyphicon glyphicon-user"></span> <b>{{ user.get_username }}</b></a>
|
||||||
|
9
InvenTree/templates/search_form.html
Normal file
9
InvenTree/templates/search_form.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<div>
|
||||||
|
<form class="navbar-form navbar-left" action="{% url 'search' %}" method='post'>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" name='search' class="form-control" placeholder="Search"{% if query_text %} value="{{ query }}"{% endif %}>
|
||||||
|
</div>
|
||||||
|
<button type="submit" id='search-submit' class="btn btn-default">Submit</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
Reference in New Issue
Block a user