diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index d042f65a67..955d648a4a 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -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; diff --git a/frappe/public/js/frappe/ui/filters.js b/frappe/public/js/frappe/ui/filters.js index 7f667a3026..1973e93f14 100644 --- a/frappe/public/js/frappe/ui/filters.js +++ b/frappe/public/js/frappe/ui/filters.js @@ -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")