2323
2424qx . Class . define ( "osparc.widget.IntlTelInput" , {
2525 extend : qx . ui . core . Widget ,
26+ implement : [ qx . ui . form . IForm , qx . ui . form . IStringForm ] ,
27+ include : [ qx . ui . form . MForm , qx . ui . form . MModelProperty ] ,
2628
2729 construct : function ( ) {
2830 this . base ( arguments ) ;
2931
30- this . _setLayout ( new qx . ui . layout . HBox ( 5 ) ) ;
32+ this . _setLayout ( new qx . ui . layout . HBox ( ) ) ;
3133
3234 this . getContentElement ( ) . setStyles ( {
3335 "overflow" : "visible" // needed for countries dropdown menu
@@ -68,6 +70,16 @@ qx.Class.define("osparc.widget.IntlTelInput", {
6870 this . _add ( feedbackCheck ) ;
6971 } ,
7072
73+ properties : {
74+ // Form-compatible property
75+ value : {
76+ check : "String" ,
77+ nullable : true ,
78+ event : "changeValue" ,
79+ apply : "_applyValue"
80+ }
81+ } ,
82+
7183 statics : {
7284 updateStyle : function ( itiInput , checkIcon ) {
7385 const textColor = qx . theme . manager . Color . getInstance ( ) . resolve ( "text" ) ;
@@ -87,8 +99,25 @@ qx.Class.define("osparc.widget.IntlTelInput", {
8799 __itiInput : null ,
88100 __feedbackCheck : null ,
89101
90- getNumber : function ( ) {
91- return this . __itiInput ? this . __itiInput . getNumber ( ) : "" ;
102+ // IStringForm interface implementation
103+ getValue : function ( ) {
104+ return this . __itiInput ? this . __itiInput . getNumber ( ) : null ;
105+ } ,
106+
107+ setValue : function ( value ) {
108+ if ( this . __itiInput && value ) {
109+ // intlTelInput doesn't have a full setter for raw numbers
110+ this . __itiInput . setNumber ( value ) ;
111+ }
112+ this . _applyValue ( value ) ;
113+ } ,
114+
115+ resetValue : function ( ) {
116+ this . setValue ( null ) ;
117+ } ,
118+
119+ _applyValue : function ( value ) {
120+ this . fireDataEvent ( "changeValue" , value ) ;
92121 } ,
93122
94123 isValidNumber : function ( ) {
@@ -98,7 +127,7 @@ qx.Class.define("osparc.widget.IntlTelInput", {
98127 verifyPhoneNumber : function ( ) {
99128 const isValid = this . isValidNumber ( ) ;
100129 this . __feedbackCheck . set ( {
101- toolTipText : "E.164: " + this . getNumber ( ) ,
130+ toolTipText : "E.164: " + this . getValue ( ) ,
102131 source : isValid ? "@FontAwesome5Solid/check/16" : "@FontAwesome5Solid/exclamation-triangle/16" ,
103132 textColor : isValid ? "text" : "failed-red" ,
104133 alignY : "middle" ,
@@ -112,7 +141,7 @@ qx.Class.define("osparc.widget.IntlTelInput", {
112141 2 : this . tr ( "Number too short" ) ,
113142 3 : this . tr ( "Number too long" )
114143 } ;
115- const errorMsg = validationError in errorMap ? errorMap [ validationError ] : "Invalid number" ;
144+ const errorMsg = errorMap [ validationError ] || "Invalid number" ;
116145 this . __feedbackCheck . set ( {
117146 toolTipText : errorMsg + ". " + this . __feedbackCheck . getToolTipText ( )
118147 } ) ;
0 commit comments