diff --git a/frappe/public/js/frappe/ui/base_list.js b/frappe/public/js/frappe/ui/base_list.js index 137ebfea83..b98402f95f 100644 --- a/frappe/public/js/frappe/ui/base_list.js +++ b/frappe/public/js/frappe/ui/base_list.js @@ -184,30 +184,37 @@ frappe.ui.BaseList = Class.extend({ return; } - if(this.meta) { + if (this.meta) { this.page.add_field({ - fieldtype:'Link', - options:this.doctype, - label:'ID', - fieldname:'name', + fieldtype: 'Data', + label: 'ID', + condition: 'like', + fieldname: 'name', onchange: () => { me.refresh(true); } }); this.meta.fields.forEach(function(df) { if(df.in_standard_filter && !frappe.model.no_value_type.includes(df.fieldtype)) { let options = df.options; + let condition = '='; + let fieldtype = df.fieldtype; + if (['Link', 'Text', 'Small Text', 'Text Editor', 'Data'].includes(fieldtype)) { + fieldtype = 'Data', + condition = 'like' + } if(df.fieldtype == "Select" && df.options) { - options = df.options.split("\n") - if(options.length > 0 && options[0] != ""){ + options = df.options.split("\n"); + if(options.length > 0 && options[0] != "") { options.unshift(""); - df.options = options.join("\n"); + options = options.join("\n"); } } me.page.add_field({ - fieldtype: df.fieldtype, + fieldtype: fieldtype, label: __(df.label), - options: df.options, + options: options, fieldname: df.fieldname, + condition: condition, onchange: () => {me.refresh(true);} }); } @@ -228,13 +235,15 @@ frappe.ui.BaseList = Class.extend({ let field = this.page.fields_dict[key]; let value = field.get_value(); if (value) { + if (field.df.condition==='like' && !value.includes('%')) { + value = '%' + value + '%'; + } filters.push([ me.doctype, field.df.fieldname, - (['Data', 'Text', 'Small Text', 'Text Editor'] - .includes(field.df.fieldtype) ? 'like' : '='), + field.df.condition || '=', value - ]) + ]); } } },