diff --git a/frappe/public/js/frappe/web_form/web_form_list.js b/frappe/public/js/frappe/web_form/web_form_list.js index 272c65cf69..076f2f266d 100644 --- a/frappe/public/js/frappe/web_form/web_form_list.js +++ b/frappe/public/js/frappe/web_form/web_form_list.js @@ -16,7 +16,8 @@ export default class WebFormList { if (this.table) { Array.from(this.table.tBodies).forEach(tbody => tbody.remove()); let check = document.getElementById('select-all'); - check.checked = false; + if (check) + check.checked = false; } this.rows = []; this.page_length = 20; @@ -131,9 +132,39 @@ export default class WebFormList { this.make_table_head(); } - this.append_rows(this.data); - - this.wrapper.appendChild(this.table); + if (this.data.length) { + this.append_rows(this.data); + this.wrapper.appendChild(this.table); + } else { + let new_button = ""; + let empty_state = document.createElement("div"); + empty_state.classList.add("no-result", "text-muted", "flex", "justify-center", "align-center"); + + frappe.has_permission(this.doctype, "", "create", () => { + new_button = ` +
+ `; + + empty_state.innerHTML = ` +${__("No {0} found", [__(this.doctype)])}
+ ${new_button} +