refactor: avoid duplicate render_count for report view
Only difference is element
This commit is contained in:
parent
1fa7cc7816
commit
698ef95ca1
4 changed files with 23 additions and 23 deletions
|
|
@ -37,6 +37,6 @@ context("List Paging", () => {
|
|||
cy.get(".list-paging-area .list-count").should("contain.text", "500 of");
|
||||
cy.get(".list-paging-area .btn-more").click();
|
||||
|
||||
cy.get(".list-paging-area .list-count").should("contain.text", "1000 of");
|
||||
cy.get(".list-paging-area .list-count").should("contain.text", "1,000 of");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -501,9 +501,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
|
||||
freeze() {
|
||||
if (this.list_view_settings && !this.list_view_settings.disable_count) {
|
||||
this.$result
|
||||
.find(".list-count")
|
||||
.html(`<span>${__("Refreshing", null, "Document count in list view")}...</span>`);
|
||||
this.get_count_element().html(
|
||||
`<span>${__("Refreshing", null, "Document count in list view")}...</span>`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -619,22 +619,22 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
render_count() {
|
||||
if (this.list_view_settings.disable_count) return;
|
||||
|
||||
this.get_count_str().then((str) => {
|
||||
let me = this;
|
||||
let count_element = this.$result.find(".list-count");
|
||||
count_element.html(`<span>${str}</span>`);
|
||||
let me = this;
|
||||
let $count = this.get_count_element();
|
||||
this.get_count_str().then((count) => {
|
||||
$count.html(`<span>${count}</span>`);
|
||||
if (this.count_upper_bound) {
|
||||
count_element.attr(
|
||||
$count.attr(
|
||||
"title",
|
||||
__(
|
||||
"The count shown is an estimated count. Click here to see the accurate count."
|
||||
)
|
||||
);
|
||||
count_element.tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" });
|
||||
count_element.on("click", () => {
|
||||
$count.tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" });
|
||||
$count.on("click", () => {
|
||||
me.count_upper_bound = 0;
|
||||
count_element.off("click");
|
||||
count_element.tooltip("disable");
|
||||
$count.off("click");
|
||||
$count.tooltip("disable");
|
||||
me.freeze();
|
||||
me.render_count();
|
||||
});
|
||||
|
|
@ -642,6 +642,10 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
});
|
||||
}
|
||||
|
||||
get_count_element() {
|
||||
return this.$result.find(".list-count");
|
||||
}
|
||||
|
||||
get_header_html() {
|
||||
if (!this.columns) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ frappe.views.FileView = class FileView extends frappe.views.ListView {
|
|||
} else {
|
||||
super.render();
|
||||
this.render_header();
|
||||
this.render_count();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,19 +220,14 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
this.setup_datatable(this.data);
|
||||
}
|
||||
|
||||
render_count() {
|
||||
if (this.list_view_settings?.disable_count) {
|
||||
return;
|
||||
}
|
||||
let $list_count = this.$paging_area.find(".list-count");
|
||||
if (!$list_count.length) {
|
||||
$list_count = $("<span>")
|
||||
get_count_element() {
|
||||
let $count = this.$paging_area.find(".list-count");
|
||||
if (!$count.length) {
|
||||
$count = $("<span>")
|
||||
.addClass("text-muted list-count")
|
||||
.prependTo(this.$paging_area.find(".level-right"));
|
||||
}
|
||||
this.get_count_str().then((str) => {
|
||||
$list_count.text(str);
|
||||
});
|
||||
return $count;
|
||||
}
|
||||
|
||||
on_update(data) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue