瀏覽代碼

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

version-14
Suraj Shetty 3 年之前
committed by GitHub
父節點
當前提交
ce350e7481
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 15 行新增10 行删除
  1. +15
    -10
      frappe/public/js/frappe/views/reports/query_report.js

+ 15
- 10
frappe/public/js/frappe/views/reports/query_report.js 查看文件

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


if (this.report_name !== frappe.get_route()[1]) { if (this.report_name !== frappe.get_route()[1]) {
// different report // different report
this.load_report();
this.load_report(route_options);
} }
else if (frappe.has_route_options()) { else if (frappe.has_route_options()) {
// filters passed through routes // filters passed through routes
// so refresh report again // so refresh report again
this.refresh_report();
this.refresh_report(route_options);
} else { } else {
// same report // same report
// don't do anything to preserve state // 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.page.clear_inner_toolbar();
this.route = frappe.get_route(); this.route = frappe.get_route();
this.page_name = frappe.get_route_str(); 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.get_report_settings(),
() => this.setup_progress_bar(), () => this.setup_progress_bar(),
() => this.setup_page_head(), () => this.setup_page_head(),
() => this.refresh_report(),
() => this.refresh_report(route_options),
() => this.add_chart_buttons_to_toolbar(true), () => this.add_chart_buttons_to_toolbar(true),
() => this.add_card_button_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_message(true);
this.toggle_report(false); this.toggle_report(false);


return frappe.run_serially([ return frappe.run_serially([
() => this.setup_filters(), () => this.setup_filters(),
() => this.set_route_filters(),
() => this.set_route_filters(route_options),
() => this.page.clear_custom_actions(), () => this.page.clear_custom_actions(),
() => this.report_settings.onload && this.report_settings.onload(this), () => this.report_settings.onload && this.report_settings.onload(this),
() => this.refresh() () => 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 filters_to_set = this.filters.filter(f => fields.includes(f.df.fieldname));


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


Loading…
取消
儲存