mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
search page now returns matching parts
- Searches 'name' and 'description' field - Uses the JSON API
This commit is contained in:
parent
fbf764e2ef
commit
ca7182bf6b
@ -2,14 +2,58 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>InvenTree Search</h3>
|
||||
<h3>Search Results</h3>
|
||||
|
||||
<p>
|
||||
Searched for: {{ query }}
|
||||
</p>
|
||||
{% include "search_form.html" with query_text=query %}
|
||||
|
||||
<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 %}
|
||||
|
||||
{% 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 %}
|
@ -12,13 +12,7 @@
|
||||
<li><a href="{% url 'company-index' %}">Companies</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<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">
|
||||
</div>
|
||||
<button type="submit" id='search-submit' class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
{% include "search_form.html" %}
|
||||
{% if user.is_authenticated %}
|
||||
<li class='dropdown'>
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user