feat(report view): Ability to export all of the filtered rows (#6071)
- Earlier only rows currently rendered were exportable - Also show paging information in the page footer
This commit is contained in:
parent
d2ce42fce4
commit
d635c5f97d
2 changed files with 61 additions and 30 deletions
|
|
@ -334,9 +334,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
}
|
||||
|
||||
render_count() {
|
||||
this.get_count_html()
|
||||
.then(html => {
|
||||
this.$result.find('.list-count').html(html);
|
||||
this.get_count_str()
|
||||
.then(str => {
|
||||
this.$result.find('.list-count').html(`<span>${str}</span>`);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -570,7 +570,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
return html;
|
||||
}
|
||||
|
||||
get_count_html() {
|
||||
get_count_str() {
|
||||
const current_count = this.data.length;
|
||||
|
||||
return frappe.call({
|
||||
|
|
@ -582,10 +582,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
fields: [`count(${frappe.model.get_full_column_name('name', this.doctype)}) as total_count`]
|
||||
}
|
||||
}).then(r => {
|
||||
const count = r.message.values[0][0] || current_count;
|
||||
const str = __('{0} of {1}', [current_count, count]);
|
||||
const html = `<span>${str}</span>`;
|
||||
return html;
|
||||
this.total_count = r.message.values[0][0] || current_count;
|
||||
const str = __('{0} of {1}', [current_count, this.total_count]);
|
||||
return str;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
|
||||
render(force) {
|
||||
if (this.data.length === 0) return;
|
||||
this.render_count();
|
||||
|
||||
if (this.chart) {
|
||||
this.refresh_charts();
|
||||
|
|
@ -91,6 +92,20 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
this.setup_datatable(this.data);
|
||||
}
|
||||
|
||||
render_count() {
|
||||
let $list_count = this.$paging_area.find('.list-count');
|
||||
if (!$list_count.length) {
|
||||
this.$paging_area.find('.btn-more').addClass('margin-left');
|
||||
$list_count = $('<span>')
|
||||
.addClass('text-muted text-medium list-count')
|
||||
.prependTo(this.$paging_area.find('.level-right'));
|
||||
}
|
||||
this.get_count_str()
|
||||
.then(str => {
|
||||
$list_count.text(str);
|
||||
});
|
||||
}
|
||||
|
||||
on_update(data) {
|
||||
if (this.doctype === data.doctype && data.name) {
|
||||
// flash row when doc is updated by some other user
|
||||
|
|
@ -998,33 +1013,50 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
const args = this.get_args();
|
||||
const selected_items = this.get_checked_items(true);
|
||||
|
||||
frappe.prompt({
|
||||
fieldtype:"Select", label: __("Select File Type"), fieldname:"file_format_type",
|
||||
options:"Excel\nCSV", default:"Excel", reqd: 1
|
||||
},
|
||||
(data) => {
|
||||
args.cmd = 'frappe.desk.reportview.export_query';
|
||||
args.file_format_type = data.file_format_type;
|
||||
const d = new frappe.ui.Dialog({
|
||||
title: __("Export Report: {0}",[__(this.doctype)]),
|
||||
fields: [
|
||||
{
|
||||
fieldtype: 'Select',
|
||||
label: __('Select File Type'),
|
||||
fieldname:'file_format_type',
|
||||
options: ['Excel', 'CSV'],
|
||||
default: 'Excel'
|
||||
},
|
||||
{
|
||||
fieldtype: 'Check',
|
||||
fieldname: 'export_all_rows',
|
||||
label: __('Export All {0} rows?', [(this.total_count + "").bold()])
|
||||
}
|
||||
],
|
||||
primary_action_label: __('Download'),
|
||||
primary_action: (data) => {
|
||||
args.cmd = 'frappe.desk.reportview.export_query';
|
||||
args.file_format_type = data.file_format_type;
|
||||
|
||||
if (args.file_format_type === 'CSV') {
|
||||
frappe.tools.downloadify(this.data, null, this.doctype);
|
||||
return;
|
||||
}
|
||||
if(this.add_totals_row) {
|
||||
args.add_totals_row = 1;
|
||||
}
|
||||
|
||||
if(this.add_totals_row) {
|
||||
args.add_totals_row = 1;
|
||||
}
|
||||
if(selected_items.length > 0) {
|
||||
args.selected_items = selected_items;
|
||||
}
|
||||
|
||||
if(selected_items.length > 0) {
|
||||
args.selected_items = selected_items;
|
||||
}
|
||||
if (!data.export_all_rows) {
|
||||
args.start = 0;
|
||||
args.page_length = this.data.length;
|
||||
} else {
|
||||
delete args.start;
|
||||
delete args.page_length;
|
||||
}
|
||||
|
||||
args.start = 0;
|
||||
args.page_length = this.data.length;
|
||||
open_url_post(frappe.request.url, args);
|
||||
|
||||
open_url_post(frappe.request.url, args);
|
||||
},
|
||||
__("Export Report: {0}",[__(this.doctype)]), __("Download"));
|
||||
d.hide();
|
||||
},
|
||||
});
|
||||
|
||||
d.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue