[fix] Parse formatted input in report filters
This commit is contained in:
parent
53b0e96857
commit
4a24e8d321
2 changed files with 20 additions and 15 deletions
|
|
@ -224,19 +224,21 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({
|
|||
} else {
|
||||
// inline
|
||||
var value = me.get_value();
|
||||
if(me.parse) {
|
||||
value = me.parse(value);
|
||||
var parsed = me.parse ? me.parse(value) : value;
|
||||
var set_input = function(before, after) {
|
||||
if(before !== after) {
|
||||
me.set_input(after);
|
||||
} else {
|
||||
me.set_mandatory && me.set_mandatory(before);
|
||||
}
|
||||
}
|
||||
if(me.validate) {
|
||||
me.validate(value, function(value1) {
|
||||
if(value !== value1) {
|
||||
me.set_input(value1)
|
||||
} else {
|
||||
me.set_mandatory && me.set_mandatory(value);
|
||||
}
|
||||
me.validate(parsed, function(validated) {
|
||||
set_input(value, validated);
|
||||
});
|
||||
} else {
|
||||
me.set_mandatory && me.set_mandatory(value);
|
||||
set_input(value, parsed);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -375,14 +377,17 @@ frappe.ui.form.ControlInt = frappe.ui.form.ControlData.extend({
|
|||
return false;
|
||||
})
|
||||
},
|
||||
parse: function(value) {
|
||||
return cint(value, null);
|
||||
},
|
||||
validate: function(value, callback) {
|
||||
return callback(cint(value, null));
|
||||
return callback(value);
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.ControlFloat = frappe.ui.form.ControlInt.extend({
|
||||
validate: function(value, callback) {
|
||||
return callback(isNaN(parseFloat(value)) ? null : flt(value));
|
||||
parse: function(value) {
|
||||
return isNaN(parseFloat(value)) ? null : flt(value);
|
||||
},
|
||||
format_for_input: function(value) {
|
||||
var number_format;
|
||||
|
|
|
|||
|
|
@ -365,12 +365,12 @@ frappe.ui.Filter = Class.extend({
|
|||
|
||||
if(this.field.df.fieldname==="docstatus") {
|
||||
value = {0:"Draft", 1:"Submitted", 2:"Cancelled"}[value] || value;
|
||||
}
|
||||
|
||||
if(this.field.df.original_type==="Check") {
|
||||
} else if(this.field.df.original_type==="Check") {
|
||||
value = {0:"No", 1:"Yes"}[cint(value)];
|
||||
} else if (in_list(["Date", "Datetime"], this.field.df.fieldtype)) {
|
||||
value = frappe.datetime.str_to_user(value);
|
||||
} else {
|
||||
value = this.field.get_value();
|
||||
}
|
||||
|
||||
this.$btn_group.find(".toggle-filter")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue