From f4fbf5215ba32300a45097a3c9b6d9adcfd40f9f Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Fri, 27 Jul 2018 21:07:56 +0530 Subject: [PATCH] [hub][search] empty search and route fallback --- erpnext/public/js/hub/marketplace.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index a230c2ca08..7b2907a9e8 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -137,7 +137,7 @@ erpnext.hub.Marketplace = class Marketplace { this.subpages.favourites = new erpnext.hub.Favourites(this.$body); } - if (route[1] === 'search' && route[2] && !this.subpages.search) { + if (route[1] === 'search' && !this.subpages.search) { this.subpages.search = new erpnext.hub.SearchPage(this.$body); } @@ -298,9 +298,8 @@ erpnext.hub.SearchPage = class SearchPage extends SubPage { } refresh() { - this.keyword = frappe.get_route()[2]; + this.keyword = frappe.get_route()[2] || ''; this.$wrapper.find('input').val(this.keyword); - if (!this.keyword) return; this.get_items_by_keyword(this.keyword) .then(items => this.render(items)); @@ -312,7 +311,8 @@ erpnext.hub.SearchPage = class SearchPage extends SubPage { render(items) { this.$wrapper.find('.hub-card-container').remove(); - const html = get_item_card_container_html(items, __('Search results for "{0}"', [this.keyword])); + const title = this.keyword ? __('Search results for "{0}"', [this.keyword]) : ''; + const html = get_item_card_container_html(items, title); this.$wrapper.append(html); } } @@ -831,11 +831,14 @@ function get_empty_state(message, action) { function get_item_card_container_html(items, title='') { const items_html = (items || []).map(item => get_item_card_html(item)).join(''); + const title_html = title + ? `
+ ${title} +
` + : ''; const html = `
-
- ${title} -
+ ${title_html} ${items_html}
`;