perf: Make request for filters_config once
Prior to this, a request was made on every filter change for a filters_config entry. The options would not change based on the List / filters context since no such data is shared with the API. Hence, it can be stored upon first request for re-use. Eg: Current usage in ERPNext - fiscal year operator's options don't change frequently.
This commit is contained in:
parent
e6460b2930
commit
c9504f3bfc
1 changed files with 14 additions and 7 deletions
|
|
@ -249,14 +249,21 @@ frappe.ui.Filter = class {
|
|||
const filter_value = this.filter_list.get_filter_value(fieldname);
|
||||
args[field_name] = filter_value;
|
||||
}
|
||||
frappe
|
||||
.xcall(this.filters_config[condition].get_field, args)
|
||||
.then(field => {
|
||||
df.fieldtype = field.fieldtype;
|
||||
df.options = field.options;
|
||||
df.fieldname = fieldname;
|
||||
this.make_field(df, cur.fieldtype);
|
||||
let setup_field = (field) => {
|
||||
df.fieldtype = field.fieldtype;
|
||||
df.options = field.options;
|
||||
df.fieldname = fieldname;
|
||||
this.make_field(df, cur.fieldtype);
|
||||
}
|
||||
if (this.filters_config[condition].data) {
|
||||
let field = this.filters_config[condition].data;
|
||||
setup_field(field);
|
||||
} else {
|
||||
frappe.xcall(this.filters_config[condition].get_field, args).then(field => {
|
||||
this.filters_config[condition].data = field;
|
||||
setup_field(field);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.make_field(df, cur.fieldtype);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue