From e25b69a660a6ce82e78af7d90c0c63f7c54111d6 Mon Sep 17 00:00:00 2001 From: Ejaaz Khan Date: Wed, 27 Aug 2025 09:51:55 +0530 Subject: [PATCH] fix(ListView): remove border if no scroll & refactor code --- frappe/public/js/frappe/list/list_view.js | 50 +++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index bfb1e59173..8d77515c96 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -635,13 +635,11 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { // clear rows this.$result.find(".list-row-container").remove(); this.parent.page.main.parent().addClass("list-view"); - if (this.list_view_settings?.disable_scrolling && !frappe.is_mobile()) { - this.parent.page.main.parent().addClass("disable-scrolling"); - } this.render_header(); let has_assignto = false; + let assign_to_count = 0; let assign_to_length = 0; if (this.data.length > 0) { // append rows @@ -650,11 +648,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { doc._idx = idx++; this.$result.append(this.get_list_row_html(doc)); if (doc._assign) { - assign_to_length = Math.max( - assign_to_length, - JSON.parse(doc._assign)?.length > this.max_number_of_avatars + assign_to_length = JSON.parse(doc._assign)?.length; + + assign_to_count = Math.max( + assign_to_count, + assign_to_length > this.max_number_of_avatars ? this.max_number_of_avatars - : JSON.parse(doc._assign)?.length + : assign_to_length ); if (!has_assignto) { @@ -664,15 +664,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { } } this.apply_column_widths(); - - // add class to result to indetify that it has assignto - if (has_assignto) { - this.$result.addClass(["has-assign-to", `assign-to-length-${assign_to_length}`]); - this.$result.removeClass("no-assign-to"); - } else { - this.$result.removeClass("has-assign-to"); - this.$result.addClass("no-assign-to"); - } + this.update_listview_classes(has_assignto, assign_to_count); } render_count() { @@ -1032,6 +1024,32 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { }); } + update_listview_classes(has_assignto, assign_to_count) { + // add class to result to indetify that it has assignto + if (has_assignto) { + this.$result.addClass(["has-assign-to", `assign-to-length-${assign_to_count}`]); + this.$result.removeClass("no-assign-to"); + } else { + this.$result.removeClass("has-assign-to"); + this.$result.addClass("no-assign-to"); + } + + // disable scrolling + if (this.list_view_settings?.disable_scrolling && !frappe.is_mobile()) { + this.parent.page.main.parent().addClass("disable-scrolling"); + } + + // if no scroll then remove borders + let list_row = this.$result.find(".list-row-container .list-row").first(); + let result_container_width = this.$result.width(); + let left_width = list_row.find(".level-left").width(); + let right_width = list_row.find(".level-right").width(); + + if (result_container_width - right_width > left_width) { + this.$result.find(".list-row-container .list-row .level-right").addClass("border-0"); + } + } + get_tags_html(user_tags, limit, colored = false) { let get_tag_html = (tag) => { let color = "",