Merge pull request #32902 from sagarvora/fix-report
This commit is contained in:
commit
812c5c9855
1 changed files with 15 additions and 20 deletions
|
|
@ -114,7 +114,6 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
frappe.realtime.on("report_generated", (data) => {
|
||||
this.toggle_primary_button_disabled(false);
|
||||
if (data.report_name) {
|
||||
this.prepared_report_action = "Rebuild";
|
||||
// If generated report and currently active Prepared Report has same fiters
|
||||
// then refresh the Prepared Report
|
||||
// Otherwise show alert with the link to the Prepared Report
|
||||
|
|
@ -168,7 +167,6 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
this.show_save = false;
|
||||
this.menu_items = this.get_menu_items();
|
||||
this.datatable = null;
|
||||
this.prepared_report_action = "New";
|
||||
|
||||
frappe.run_serially([
|
||||
() => this.get_report_doc(),
|
||||
|
|
@ -402,9 +400,11 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
|
||||
return frappe.run_serially([
|
||||
() => this.setup_filters(),
|
||||
() => (this._no_refresh = true),
|
||||
() => this.set_route_filters(route_options),
|
||||
() => this.page.clear_custom_actions(),
|
||||
() => this.report_settings.onload && this.report_settings.onload(this),
|
||||
() => (this._no_refresh = false),
|
||||
() => this.refresh(),
|
||||
]);
|
||||
}
|
||||
|
|
@ -565,12 +565,8 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
|
||||
if (f.on_change) {
|
||||
f.on_change(this);
|
||||
} else {
|
||||
if (this.prepared_report) {
|
||||
this.reset_report_view();
|
||||
} else if (!this._no_refresh) {
|
||||
this.refresh(true);
|
||||
}
|
||||
} else if (!this._no_refresh) {
|
||||
this.refresh(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -669,13 +665,13 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
this.prepared_report_name = route_options.prepared_report_name;
|
||||
|
||||
const promises = filters_to_set.map((f) => {
|
||||
return () => {
|
||||
return async () => {
|
||||
let value = route_options[f.df.fieldname];
|
||||
if (typeof value === "string" && value[0] === "[") {
|
||||
// multiselect array
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
f.set_value(value);
|
||||
await f.set_value(value);
|
||||
};
|
||||
});
|
||||
promises.push(() => {
|
||||
|
|
@ -695,7 +691,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
refresh(have_filters_changed) {
|
||||
this.toggle_message(true);
|
||||
this.toggle_report(false);
|
||||
let filters = this.get_filter_values(true);
|
||||
let filters = this.get_filter_values(!this.prepared_report_name);
|
||||
|
||||
// for custom reports,
|
||||
// are_default_filters is true if the filters haven't been modified and for all filters,
|
||||
|
|
@ -756,7 +752,6 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
// If query_string contains prepared_report_name then set filters
|
||||
// to match the mentioned prepared report doc and disable editing
|
||||
if (this.prepared_report_name) {
|
||||
this.prepared_report_action = "Edit";
|
||||
const filters_from_report = JSON.parse(data.doc.filters);
|
||||
Object.values(this.filters).forEach(function (field) {
|
||||
if (filters_from_report[field.fieldname]) {
|
||||
|
|
@ -893,7 +888,14 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
},
|
||||
};
|
||||
|
||||
let primary_action = this.primary_action_map[this.prepared_report_action];
|
||||
let prepared_report_action = "New";
|
||||
if (this.prepared_report_name) {
|
||||
prepared_report_action = "Edit";
|
||||
} else if (doc) {
|
||||
prepared_report_action = "Rebuild";
|
||||
}
|
||||
|
||||
let primary_action = this.primary_action_map[prepared_report_action];
|
||||
|
||||
if (!this.primary_button || this.primary_button.text() !== primary_action.label) {
|
||||
this.primary_button = this.page.set_primary_action(
|
||||
|
|
@ -2120,12 +2122,6 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
</div>`;
|
||||
}
|
||||
|
||||
reset_report_view() {
|
||||
this.hide_status();
|
||||
this.toggle_nothing_to_show(true);
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
toggle_nothing_to_show(flag) {
|
||||
let message =
|
||||
this.prepared_report && !this.prepared_report_document
|
||||
|
|
@ -2137,7 +2133,6 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
this.toggle_message(flag, message);
|
||||
|
||||
if (flag && this.prepared_report) {
|
||||
this.prepared_report_action = "New";
|
||||
if (!this.primary_button.is(":visible")) {
|
||||
this.add_prepared_report_buttons();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue