@@ -44,13 +44,6 @@ qx.Class.define("osparc.data.model.User", {
4444 } else if ( userData [ "lastName" ] ) {
4545 lastName = userData [ "lastName" ] ;
4646 }
47- let description = [ firstName , lastName ] . join ( " " ) . trim ( ) ; // the null values will be replaced by empty strings
48- if ( email ) {
49- if ( description ) {
50- description += " - "
51- }
52- description += email ;
53- }
5447
5548 this . set ( {
5649 userId,
@@ -60,6 +53,16 @@ qx.Class.define("osparc.data.model.User", {
6053 lastName,
6154 email,
6255 phoneNumber : userData [ "phone" ] || null ,
56+ } ) ;
57+
58+ let description = this . getFullName ( ) ;
59+ if ( email ) {
60+ if ( description ) {
61+ description += " - "
62+ }
63+ description += email ;
64+ }
65+ this . set ( {
6366 label : userData [ "userName" ] || description ,
6467 description,
6568 } ) ;
@@ -196,9 +199,30 @@ qx.Class.define("osparc.data.model.User", {
196199 } ,
197200 } ,
198201
202+ statics : {
203+ concatFullName : function ( firstName , lastName ) {
204+ return [ firstName , lastName ] . filter ( Boolean ) . join ( " " ) ;
205+ } ,
206+
207+ userDataToDescription : function ( firstName , lastName , email ) {
208+ let description = this . concatFullName ( firstName , lastName ) ;
209+ if ( email ) {
210+ if ( description ) {
211+ description += " - "
212+ }
213+ description += email ;
214+ }
215+ return description ;
216+ } ,
217+ } ,
218+
199219 members : {
200220 createThumbnail : function ( size ) {
201221 return osparc . utils . Avatar . emailToThumbnail ( this . getEmail ( ) , this . getUsername ( ) , size ) ;
202222 } ,
223+
224+ getFullName : function ( ) {
225+ return this . self ( ) . concatFullName ( this . getFirstName ( ) , this . getLastName ( ) ) ;
226+ } ,
203227 } ,
204228} ) ;
0 commit comments