Browse Source

Merge pull request #15520 from frappe/mergify/bp/develop/pr-15477

version-14
Suraj Shetty 3 years ago
committed by GitHub
parent
commit
ce350e7481
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 10 deletions
  1. +15
    -10
      frappe/public/js/frappe/views/reports/query_report.js

+ 15
- 10
frappe/public/js/frappe/views/reports/query_report.js View File

@@ -105,15 +105,18 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
this.toggle_nothing_to_show(true);
return;
}
let route_options = {};
route_options = Object.assign(route_options, frappe.route_options);

if (this.report_name !== frappe.get_route()[1]) {
// different report
this.load_report();
this.load_report(route_options);
}
else if (frappe.has_route_options()) {
// filters passed through routes
// so refresh report again
this.refresh_report();
this.refresh_report(route_options);
} else {
// same report
// don't do anything to preserve state
@@ -121,7 +124,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
}
}

load_report() {
load_report(route_options) {
this.page.clear_inner_toolbar();
this.route = frappe.get_route();
this.page_name = frappe.get_route_str();
@@ -137,7 +140,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
() => this.get_report_settings(),
() => this.setup_progress_bar(),
() => this.setup_page_head(),
() => this.refresh_report(),
() => this.refresh_report(route_options),
() => this.add_chart_buttons_to_toolbar(true),
() => this.add_card_button_to_toolbar(true),
]);
@@ -343,13 +346,13 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
});
}

refresh_report() {
refresh_report(route_options) {
this.toggle_message(true);
this.toggle_report(false);

return frappe.run_serially([
() => this.setup_filters(),
() => this.set_route_filters(),
() => this.set_route_filters(route_options),
() => this.page.clear_custom_actions(),
() => this.report_settings.onload && this.report_settings.onload(this),
() => this.refresh()
@@ -525,15 +528,17 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
});
}

set_route_filters() {
if(frappe.route_options) {
const fields = Object.keys(frappe.route_options);
set_route_filters(route_options) {
if (!route_options) route_options = frappe.route_options;

if (route_options) {
const fields = Object.keys(route_options);

const filters_to_set = this.filters.filter(f => fields.includes(f.df.fieldname));

const promises = filters_to_set.map(f => {
return () => {
const value = frappe.route_options[f.df.fieldname];
const value = route_options[f.df.fieldname];
f.set_value(value);
};
});


Loading…
Cancel
Save