Merge pull request #33813 from iamejaaz/33743-1-list-view-shadow
fix(ListView): remove border if no scroll & refactor code
This commit is contained in:
commit
753dda1cb0
1 changed files with 34 additions and 16 deletions
|
|
@ -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 = "",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue