diff --git a/cypress/integration/list_view_settings.js b/cypress/integration/list_view_settings.js index 898fe1dec4..ff9a30ce5c 100644 --- a/cypress/integration/list_view_settings.js +++ b/cypress/integration/list_view_settings.js @@ -15,11 +15,13 @@ context("List View Settings", () => { cy.clear_filters(); cy.wait(300); cy.get(".list-count").should("contain", "20 of"); + cy.get("[href='#icon-small-message']").should("be.visible"); cy.get(".menu-btn-group button").click(); cy.get(".dropdown-menu li").filter(":visible").contains("List Settings").click(); cy.get(".modal-dialog").should("contain", "DocType Settings"); cy.findByLabelText("Disable Count").check({ force: true }); + cy.findByLabelText("Disable Comment Count").check({ force: true }); cy.findByLabelText("Disable Sidebar Stats").check({ force: true }); cy.findByRole("button", { name: "Save" }).click(); @@ -27,11 +29,13 @@ context("List View Settings", () => { cy.get(".list-count").should("be.empty"); cy.get(".list-sidebar .list-tags").should("not.exist"); + cy.get("[href='#icon-small-message']").should("not.be.visible"); cy.get(".menu-btn-group button").click({ force: true }); cy.get(".dropdown-menu li").filter(":visible").contains("List Settings").click(); cy.get(".modal-dialog").should("contain", "DocType Settings"); cy.findByLabelText("Disable Count").uncheck({ force: true }); + cy.findByLabelText("Disable Comment Count").uncheck({ force: true }); cy.findByLabelText("Disable Sidebar Stats").uncheck({ force: true }); cy.findByRole("button", { name: "Save" }).click(); }); diff --git a/frappe/desk/doctype/list_view_settings/list_view_settings.json b/frappe/desk/doctype/list_view_settings/list_view_settings.json index 44761992f1..69ea379e61 100644 --- a/frappe/desk/doctype/list_view_settings/list_view_settings.json +++ b/frappe/desk/doctype/list_view_settings/list_view_settings.json @@ -7,6 +7,7 @@ "engine": "InnoDB", "field_order": [ "disable_count", + "disable_comment_count", "disable_sidebar_stats", "disable_auto_refresh", "total_fields", @@ -49,13 +50,20 @@ "hidden": 1, "label": "Fields", "read_only": 1 + }, + { + "default": "0", + "fieldname": "disable_comment_count", + "fieldtype": "Check", + "label": "Disable Comment Count" } ], "links": [], - "modified": "2020-05-12 18:27:15.568199", + "modified": "2023-02-14 14:46:43.764229", "modified_by": "Administrator", "module": "Desk", "name": "List View Settings", + "naming_rule": "Set by user", "owner": "Administrator", "permissions": [ { @@ -72,5 +80,6 @@ "read_only": 1, "sort_field": "modified", "sort_order": "DESC", + "states": [], "track_changes": 1 } \ No newline at end of file diff --git a/frappe/model/db_query.py b/frappe/model/db_query.py index 893d349d70..4287f43856 100644 --- a/frappe/model/db_query.py +++ b/frappe/model/db_query.py @@ -29,6 +29,7 @@ from frappe.utils import ( get_timespan_date_range, make_filter_tuple, ) +from frappe.utils.data import sbool LOCATE_PATTERN = re.compile(r"locate\([^,]+,\s*[`\"]?name[`\"]?\s*\)", flags=re.IGNORECASE) LOCATE_CAST_PATTERN = re.compile( @@ -196,7 +197,7 @@ class DatabaseQuery: result = self.build_and_run() - if with_comment_count and not as_list and self.doctype: + if sbool(with_comment_count) and not as_list and self.doctype: self.add_comment_count(result) if save_user_settings: diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 453b31236c..4b6b1e5bc1 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -504,9 +504,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { get_args() { const args = super.get_args(); - return Object.assign(args, { - with_comment_count: true, - }); + if (this.list_view_settings && !this.list_view_settings.disable_comment_count) { + args.with_comment_count = 1; + } else { + args.with_comment_count = 0; + } + + return args; } before_refresh() { @@ -896,10 +900,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { `; } - const comment_count = ` + let comment_count = null; + if (this.list_view_settings && !this.list_view_settings.disable_comment_count) { + comment_count = $(``); + $(comment_count).append(` ${frappe.utils.icon("small-message")} - ${doc._comment_count > 99 ? "99+" : doc._comment_count || 0} - `; + ${doc._comment_count > 99 ? "99+" : doc._comment_count || 0}`); + } html += `
${modified} - ${comment_count} + ${comment_count ? $(comment_count).prop("outerHTML") : ""}