From 19d2dea8f96416cbccaf3352b0da76f19486d34c Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 26 Mar 2024 17:02:54 +0800 Subject: [PATCH] Fix #8115 - thousand seperator --- Roo/form/NumberField.js | 9 ++++++++- docs/src/Roo_bootstrap_form_DateField.js.html | 6 +++--- docs/src/Roo_form_DateField.js.html | 2 +- roojs-all.js | 8 ++++---- roojs-bootstrap-debug.js | 6 +++--- roojs-debug.js | 9 ++++++++- roojs-ui-debug.js | 9 ++++++++- roojs-ui.js | 8 ++++---- 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/Roo/form/NumberField.js b/Roo/form/NumberField.js index 0ca2fcada5..9d7cb1ddc4 100644 --- a/Roo/form/NumberField.js +++ b/Roo/form/NumberField.js @@ -35,6 +35,10 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField, { * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.') */ decimalSeparator : ".", + /** + * @cfg {String} thousandSeparator Character(s) to allow as the thousand separator (defaults to '') - set to ',' for example + */ + thousandSeparator : "", /** * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2) */ @@ -119,7 +123,7 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField, { // private parseValue : function(value){ - value = parseFloat(String(value).replace(this.decimalSeparator, ".")); + value = parseFloat(String(value).replace(this.decimalSeparator, ".").replace(this.thousandSeparator, '')); return isNaN(value) ? '' : value; }, @@ -134,6 +138,9 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField, { setValue : function(v){ v = this.fixPrecision(v); + if(this.thousandSeparator != ''){ + v = Roo.util.Format.number(v, this.decimalPrecision, this.thousandSeparator); + } Roo.form.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator)); }, diff --git a/docs/src/Roo_bootstrap_form_DateField.js.html b/docs/src/Roo_bootstrap_form_DateField.js.html index 612c10361f..d495c3a544 100644 --- a/docs/src/Roo_bootstrap_form_DateField.js.html +++ b/docs/src/Roo_bootstrap_form_DateField.js.html @@ -564,9 +564,9 @@ showPopup : function() { if(this.readOnly) { - return; - } - this.picker().show(); + return; + } + this.picker().show(); this.update(); this.place(); diff --git a/docs/src/Roo_form_DateField.js.html b/docs/src/Roo_form_DateField.js.html index 7fe3e9044c..dccfb17209 100644 --- a/docs/src/Roo_form_DateField.js.html +++ b/docs/src/Roo_form_DateField.js.html @@ -341,7 +341,7 @@ dateField.setValue('2006-5-4'); // private // Implements the default empty TriggerField.onTriggerClick function to display the DatePicker onTriggerClick : function(){ - if(this.disabled){ + if(this.disabled || this.readOnly){ return; } if(this.menu == null){ diff --git a/roojs-all.js b/roojs-all.js index 83244c885e..8b3080839e 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1821,13 +1821,13 @@ Roo.form.TextArea=function(A){Roo.form.TextArea.superclass.constructor.call(this }var el=this.el;var v=el.dom.value;var ts=this.textSizeEl;ts.innerHTML='';ts.appendChild(document.createTextNode(v));v=ts.innerHTML;Roo.fly(ts).setWidth(this.el.getWidth());if(v.length<1){v="  ";}else{if(Roo.isIE){v=v.replace(/\n/g,'

 

'); }v+=" \n ";}ts.innerHTML=v;var h=Math.min(this.growMax,Math.max(ts.offsetHeight,this.growMin));if(h!=this.lastHeight){this.lastHeight=h;this.el.setHeight(h);this.fireEvent("autosize",this,h);}}}); // Roo/form/NumberField.js -Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",decimalPrecision:2,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",initEvents:function(){Roo.form.NumberField.superclass.initEvents.call(this); +Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",thousandSeparator:"",decimalPrecision:2,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",initEvents:function(){Roo.form.NumberField.superclass.initEvents.call(this); var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return;}var c=e.getCharCode(); if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.el.on("keypress",B,this);},validateValue:function(A){if(!Roo.form.NumberField.superclass.validateValue.call(this,A)){return false;}if(A.length<1){return true;}var B=this.parseValue(A);if(isNaN(B)){this.markInvalid(String.format(this.nanText,A)); return false;}if(Bthis.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));return false;}return true;},getValue:function(){return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this))); -},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,"."));return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;}return parseFloat(A).toFixed(this.decimalPrecision); -},setValue:function(v){v=this.fixPrecision(v);Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator));},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue()); -if(v){this.setValue(v);}}}); +},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,".").replace(this.thousandSeparator,''));return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;} +return parseFloat(A).toFixed(this.decimalPrecision);},setValue:function(v){v=this.fixPrecision(v);if(this.thousandSeparator!=''){v=Roo.util.Format.number(v,this.decimalPrecision,this.thousandSeparator);}Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator)); +},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue());if(v){this.setValue(v);}}}); // Roo/form/DateField.js Roo.form.DateField=function(A){Roo.form.DateField.superclass.constructor.call(this,A);this.addEvents({'select':true});if(typeof this.minValue=="string"){this.minValue=this.parseDate(this.minValue);}if(typeof this.maxValue=="string"){this.maxValue=this.parseDate(this.maxValue); }this.ddMatch=null;if(this.disabledDates){var dd=this.disabledDates;var re="(?:";for(var i=0;i 

'); }v+=" \n ";}ts.innerHTML=v;var h=Math.min(this.growMax,Math.max(ts.offsetHeight,this.growMin));if(h!=this.lastHeight){this.lastHeight=h;this.el.setHeight(h);this.fireEvent("autosize",this,h);}}}); // Roo/form/NumberField.js -Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",decimalPrecision:2,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",initEvents:function(){Roo.form.NumberField.superclass.initEvents.call(this); +Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",thousandSeparator:"",decimalPrecision:2,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",initEvents:function(){Roo.form.NumberField.superclass.initEvents.call(this); var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return;}var c=e.getCharCode(); if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.el.on("keypress",B,this);},validateValue:function(A){if(!Roo.form.NumberField.superclass.validateValue.call(this,A)){return false;}if(A.length<1){return true;}var B=this.parseValue(A);if(isNaN(B)){this.markInvalid(String.format(this.nanText,A)); return false;}if(Bthis.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));return false;}return true;},getValue:function(){return this.fixPrecision(this.parseValue(Roo.form.NumberField.superclass.getValue.call(this))); -},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,"."));return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;}return parseFloat(A).toFixed(this.decimalPrecision); -},setValue:function(v){v=this.fixPrecision(v);Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator));},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue()); -if(v){this.setValue(v);}}}); +},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,".").replace(this.thousandSeparator,''));return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;} +return parseFloat(A).toFixed(this.decimalPrecision);},setValue:function(v){v=this.fixPrecision(v);if(this.thousandSeparator!=''){v=Roo.util.Format.number(v,this.decimalPrecision,this.thousandSeparator);}Roo.form.NumberField.superclass.setValue.call(this,String(v).replace(".",this.decimalSeparator)); +},decimalPrecisionFcn:function(v){return Math.floor(v);},beforeBlur:function(){var v=this.parseValue(this.getRawValue());if(v){this.setValue(v);}}}); // Roo/form/DateField.js Roo.form.DateField=function(A){Roo.form.DateField.superclass.constructor.call(this,A);this.addEvents({'select':true});if(typeof this.minValue=="string"){this.minValue=this.parseDate(this.minValue);}if(typeof this.maxValue=="string"){this.maxValue=this.parseDate(this.maxValue); }this.ddMatch=null;if(this.disabledDates){var dd=this.disabledDates;var re="(?:";for(var i=0;i