feat: Show brand line in search results

This commit is contained in:
Hussain Nagaria
2021-05-05 13:47:43 +05:30
committed by marination
parent 9ee13ba86b
commit 34f3a6629f
6 changed files with 27 additions and 8 deletions

View File

@@ -2,4 +2,8 @@
height: 50px;
width: 50px;
object-fit: cover;
}
.brand-line {
color: gray;
}

View File

@@ -26,7 +26,6 @@
</div>
{% set show_categories = frappe.db.get_single_value('E Commerce Settings', 'show_categories_in_search_autocomplete') %}
{% if show_categories %}
<div id="categories" class="col-sm">
<h2>Categories</h2>
@@ -34,6 +33,11 @@
</ul>
</div>
{% endif %}
{% set show_brand_line = frappe.db.get_single_value('E Commerce Settings', 'show_brand_line') %}
{% if show_brand_line %}
<span id="show-brand-line"></span>
{% endif %}
</div>
{% endblock %}

View File

@@ -3,13 +3,14 @@ let loading = false;
const searchBox = document.getElementById("search-box");
const results = document.getElementById("results");
const categoryList = document.getElementById("category-suggestions");
const showBrandLine = document.getElementById("show-brand-line");
function populateResults(data) {
html = ""
for (let res of data.message) {
html += `<li class="list-group-item list-group-item-action">
<img class="item-thumb" src="${res.thumbnail || 'img/placeholder.png'}" />
<a href="/${res.route}">${res.web_item_name}</a>
<a href="/${res.route}">${res.web_item_name} <span class="brand-line">${showBrandLine && res.brand ? "by " + res.brand : ""}</span></a>
</li>`
}
results.innerHTML = html;