feat: add eval support for link field filters
This commit is contained in:
parent
3769eff5b6
commit
e152fa579d
2 changed files with 8 additions and 6 deletions
|
|
@ -97,6 +97,7 @@ function make_dialog(frm) {
|
|||
});
|
||||
|
||||
props.field.df.link_filters = JSON.stringify(filters);
|
||||
store.form.selected_field = props.field.df;
|
||||
frm.dialog.hide();
|
||||
},
|
||||
primary_action_label: __("Apply"),
|
||||
|
|
@ -133,11 +134,6 @@ function make_dialog(frm) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Setting selected field in store because when we click on the dialog the selected field is set to null
|
||||
frm.dialog.$wrapper.on("click", () => {
|
||||
store.form.selected_field = props.field.df;
|
||||
});
|
||||
}
|
||||
|
||||
function make_filter_area(frm, doctype) {
|
||||
|
|
|
|||
|
|
@ -292,13 +292,19 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
for (const d of data) {
|
||||
for (const condition of d) {
|
||||
let [doctype, field, operator, value] = condition;
|
||||
if (value.includes("eval")) {
|
||||
// if condition type of 'like' is used then remove % from value
|
||||
value = value.replace(/%/g, "");
|
||||
// get the value to calculate
|
||||
value = value.split("eval:")[1];
|
||||
value = frappe.utils.eval(value, { doc: this.doc, frappe });
|
||||
}
|
||||
doctype = doctype.fieldname;
|
||||
if (!parsed_data[doctype]) {
|
||||
parsed_data[doctype] = {
|
||||
filters: {},
|
||||
};
|
||||
}
|
||||
|
||||
if (!parsed_data[doctype].filters[field]) {
|
||||
parsed_data[doctype].filters[field] = [operator, value];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue