From c1fe1c45c7544ac14a4326d3db2515c21ecd9591 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 17 Aug 2018 14:29:42 +0530 Subject: [PATCH] feat: empty states for favourites and search page --- erpnext/public/js/hub/pages/favourites.js | 15 ++++++++++++--- erpnext/public/js/hub/pages/search.js | 9 +++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/hub/pages/favourites.js b/erpnext/public/js/hub/pages/favourites.js index 6c2fd65580..6f2c67c01e 100644 --- a/erpnext/public/js/hub/pages/favourites.js +++ b/erpnext/public/js/hub/pages/favourites.js @@ -32,11 +32,20 @@ erpnext.hub.Favourites = class Favourites extends SubPage { } render(items) { - this.$wrapper.find('.hub-card-container').empty(); + this.$wrapper.find('.hub-items-container').empty(); const html = get_item_card_container_html(items, __('Favourites')); - this.$wrapper.append(html); - + this.$wrapper.html(html); this.$wrapper.find('.hub-card').addClass('closable'); + + if (!items.length) { + this.render_empty_state(); + } + } + + render_empty_state() { + this.$wrapper.find('.hub-items-container').append(` +
${__("You don't have any favourites yet.")}
+ `) } on_item_remove(hub_item_code, $hub_card = '') { diff --git a/erpnext/public/js/hub/pages/search.js b/erpnext/public/js/hub/pages/search.js index f3dd6fb0c5..1cdacb6db6 100644 --- a/erpnext/public/js/hub/pages/search.js +++ b/erpnext/public/js/hub/pages/search.js @@ -27,8 +27,13 @@ erpnext.hub.SearchPage = class SearchPage extends SubPage { } render(items) { - this.$wrapper.find('.hub-card-container').remove(); - const title = this.keyword ? __('Search results for "{0}"', [this.keyword]) : ''; + this.$wrapper.find('.hub-items-container').remove(); + const title = !items.length + ? __('No results found') + : this.keyword + ? __('Search results for "{0}"', [this.keyword]) + : ''; + const html = get_item_card_container_html(items, title); this.$wrapper.append(html); }