瀏覽代碼

[fix] filter links must be like not equal (#3604)

version-14
Rushabh Mehta 8 年之前
committed by Makarand Bauskar
父節點
當前提交
95e02121df
共有 1 個檔案被更改,包括 22 行新增13 行删除
  1. +22
    -13
      frappe/public/js/frappe/ui/base_list.js

+ 22
- 13
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
])
]);
}
}
},


Loading…
取消
儲存