feat: empty states for favourites and search page

This commit is contained in:
Faris Ansari 2018-08-17 14:29:42 +05:30
parent aa46567439
commit c1fe1c45c7
2 changed files with 19 additions and 5 deletions

View File

@ -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(`
<div class="col-md-12">${__("You don't have any favourites yet.")}</div>
`)
}
on_item_remove(hub_item_code, $hub_card = '') {

View File

@ -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);
}