mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
feat: Add basic autocomplete using redisearch
This commit is contained in:
committed by
marination
parent
71f4b98d0c
commit
0c47f3a876
14
erpnext/www/all-products/search.html
Normal file
14
erpnext/www/all-products/search.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{% extends "templates/web.html" %}
|
||||
|
||||
|
||||
{% block title %}{{ _('Search') }}{% endblock %}
|
||||
{% block header %}
|
||||
<div class="mb-6">{{ _('Search Products') }}</div>
|
||||
{% endblock header %}
|
||||
|
||||
{% block page_content %}
|
||||
<input type="text" name="query" id="search-box">
|
||||
<ul id="results">
|
||||
|
||||
</ul>
|
||||
{% endblock %}
|
||||
25
erpnext/www/all-products/search.js
Normal file
25
erpnext/www/all-products/search.js
Normal file
@@ -0,0 +1,25 @@
|
||||
console.log("search.js loaded");
|
||||
|
||||
const search_box = document.getElementById("search-box");
|
||||
const results = document.getElementById("results");
|
||||
|
||||
function populateResults(data) {
|
||||
html = ""
|
||||
for (let res of data.message) {
|
||||
html += `<li>${res}</li>`
|
||||
}
|
||||
console.log(html);
|
||||
results.innerHTML = html;
|
||||
}
|
||||
|
||||
search_box.addEventListener("input", (e) => {
|
||||
frappe.call({
|
||||
method: "erpnext.templates.pages.product_search.search",
|
||||
args: {
|
||||
query: e.target.value
|
||||
},
|
||||
callback: (data) => {
|
||||
populateResults(data);
|
||||
}
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user