|
|
@@ -344,7 +344,8 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({ |
|
|
|
|
|
|
|
set_disp_area: function() { |
|
|
|
let value = this.get_input_value(); |
|
|
|
if(in_list(["Currency", "Int", "Float"], this.df.fieldtype) && (this.value === 0 || value === 0)) { |
|
|
|
if(in_list(["Currency", "Int", "Float"], this.df.fieldtype) |
|
|
|
&& (this.value === 0 || value === 0)) { |
|
|
|
// to set the 0 value in readonly for currency, int, float field |
|
|
|
value = 0; |
|
|
|
} else { |
|
|
@@ -1215,39 +1216,31 @@ frappe.ui.form.ControlAttachImage = frappe.ui.form.ControlAttach.extend({ |
|
|
|
frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({ |
|
|
|
html_element: "select", |
|
|
|
make_input: function() { |
|
|
|
var me = this; |
|
|
|
this._super(); |
|
|
|
this.set_options(); |
|
|
|
}, |
|
|
|
set_input: function(value) { |
|
|
|
set_formatted_input: function(value) { |
|
|
|
// refresh options first - (new ones??) |
|
|
|
this.set_options(value || ""); |
|
|
|
if(value==null) value = ''; |
|
|
|
this.set_options(value); |
|
|
|
|
|
|
|
var input_value = null; |
|
|
|
// set in the input element |
|
|
|
this._super(value); |
|
|
|
|
|
|
|
// check if the value to be set is selected |
|
|
|
var input_value = ''; |
|
|
|
if(this.$input) { |
|
|
|
var input_value = this.$input.val(); |
|
|
|
input_value = this.$input.val(); |
|
|
|
} |
|
|
|
|
|
|
|
// not a possible option, repair |
|
|
|
if(this.doctype && this.docname) { |
|
|
|
// model value is not an option, |
|
|
|
// set the default option (displayed) |
|
|
|
var model_value = frappe.model.get_value(this.doctype, this.docname, this.df.fieldname); |
|
|
|
if(model_value == null && (input_value || "") != (model_value || "")) { |
|
|
|
this.set_model_value(input_value); |
|
|
|
} else { |
|
|
|
this.last_value = value; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(value !== input_value) { |
|
|
|
this.set_value(input_value); |
|
|
|
} |
|
|
|
if(value && input_value && value !== input_value) { |
|
|
|
// trying to set a non-existant value |
|
|
|
// model value must be same as whatever the input is |
|
|
|
this.set_model_value(input_value); |
|
|
|
} |
|
|
|
|
|
|
|
this._super(value); |
|
|
|
|
|
|
|
}, |
|
|
|
set_options: function(value) { |
|
|
|
// reset options, if something new is set |
|
|
|
var options = this.df.options || []; |
|
|
|
if(typeof this.df.options==="string") { |
|
|
|
options = this.df.options.split("\n"); |
|
|
|