feat: empty states for favourites and search page
This commit is contained in:
		
							parent
							
								
									aa46567439
								
							
						
					
					
						commit
						c1fe1c45c7
					
				| @ -32,11 +32,20 @@ erpnext.hub.Favourites = class Favourites extends SubPage { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	render(items) { | 	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')); | 		const html = get_item_card_container_html(items, __('Favourites')); | ||||||
| 		this.$wrapper.append(html); | 		this.$wrapper.html(html); | ||||||
| 
 |  | ||||||
| 		this.$wrapper.find('.hub-card').addClass('closable'); | 		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 = '') { | 	on_item_remove(hub_item_code, $hub_card = '') { | ||||||
|  | |||||||
| @ -27,8 +27,13 @@ erpnext.hub.SearchPage = class SearchPage extends SubPage { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	render(items) { | 	render(items) { | ||||||
| 		this.$wrapper.find('.hub-card-container').remove(); | 		this.$wrapper.find('.hub-items-container').remove(); | ||||||
| 		const title = this.keyword ? __('Search results for "{0}"', [this.keyword]) : ''; | 		const title = !items.length | ||||||
|  | 			? __('No results found') | ||||||
|  | 			: this.keyword | ||||||
|  | 				? __('Search results for "{0}"', [this.keyword]) | ||||||
|  | 				: ''; | ||||||
|  | 
 | ||||||
| 		const html = get_item_card_container_html(items, title); | 		const html = get_item_card_container_html(items, title); | ||||||
| 		this.$wrapper.append(html); | 		this.$wrapper.append(html); | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user