@@ -117,12 +117,12 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
117117 readOnly : true
118118 } ) ;
119119
120- const form = this . __userProfileForm = new qx . ui . form . Form ( ) ;
121- form . add ( username , "Username" , null , "username" ) ;
122- form . add ( firstName , "First Name" , null , "firstName" ) ;
123- form . add ( lastName , "Last Name" , null , "lastName" ) ;
124- form . add ( email , "Email" , null , "email" ) ;
125- const singleWithIcon = this . __userProfileRenderer = new osparc . ui . form . renderer . SingleWithIcon ( form ) ;
120+ const profileForm = this . __userProfileForm = new qx . ui . form . Form ( ) ;
121+ profileForm . add ( username , "Username" , null , "username" ) ;
122+ profileForm . add ( firstName , "First Name" , null , "firstName" ) ;
123+ profileForm . add ( lastName , "Last Name" , null , "lastName" ) ;
124+ profileForm . add ( email , "Email" , null , "email" ) ;
125+ const singleWithIcon = this . __userProfileRenderer = new osparc . ui . form . renderer . SingleWithIcon ( profileForm ) ;
126126 box . add ( singleWithIcon ) ;
127127
128128 const expirationLayout = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 5 ) ) . set ( {
@@ -180,14 +180,16 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
180180 namesValidator . add ( firstName , qx . util . Validate . regExp ( / [ ^ \. \d ] + / ) , this . tr ( "Avoid dots or numbers in text" ) ) ;
181181 namesValidator . add ( lastName , qx . util . Validate . regExp ( / ^ $ | [ ^ \. \d ] + / ) , this . tr ( "Avoid dots or numbers in text" ) ) ; // allow also empty last name
182182
183- const updateBtn = new qx . ui . form . Button ( "Update Profile" ) . set ( {
183+ const updateProfileBtn = new qx . ui . form . Button ( ) . set ( {
184+ label : this . tr ( "Update Profile" ) ,
184185 appearance : "form-button" ,
185186 alignX : "right" ,
186- allowGrowX : false
187+ allowGrowX : false ,
188+ enabled : false ,
187189 } ) ;
188- box . add ( updateBtn ) ;
190+ box . add ( updateProfileBtn ) ;
189191
190- updateBtn . addListener ( "execute" , ( ) => {
192+ updateProfileBtn . addListener ( "execute" , ( ) => {
191193 if ( ! osparc . data . Permissions . getInstance ( ) . canDo ( "user.user.update" , true ) ) {
192194 this . __resetUserData ( ) ;
193195 return ;
@@ -229,13 +231,13 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
229231
230232 __createPrivacySection : function ( ) {
231233 // binding to a model
232- const raw = {
234+ const defaultModel = {
233235 "hideUsername" : false ,
234236 "hideFullname" : true ,
235237 "hideEmail" : true ,
236238 } ;
237239
238- const privacyModel = this . __userPrivacyModel = qx . data . marshal . Json . createModel ( raw ) ;
240+ const privacyModel = this . __userPrivacyModel = qx . data . marshal . Json . createModel ( defaultModel , true ) ;
239241
240242 const box = osparc . ui . window . TabbedView . createSectionBox ( this . tr ( "Privacy" ) ) ;
241243 box . set ( {
@@ -247,30 +249,36 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
247249 box . add ( label ) ;
248250
249251 const hideUsername = new qx . ui . form . CheckBox ( ) . set ( {
250- value : false
252+ value : defaultModel . hideUsername
251253 } ) ;
252254 const hideFullname = new qx . ui . form . CheckBox ( ) . set ( {
253- value : true
255+ value : defaultModel . hideFullname
254256 } ) ;
255257 const hideEmail = new qx . ui . form . CheckBox ( ) . set ( {
256- value : true
258+ value : defaultModel . hideEmail
257259 } ) ;
258260
259- const form = new qx . ui . form . Form ( ) ;
260- form . add ( hideUsername , "Hide Username" , null , "hideUsername" ) ;
261- form . add ( hideFullname , "Hide Full Name" , null , "hideFullname" ) ;
262- form . add ( hideEmail , "Hide Email" , null , "hideEmail" ) ;
263- box . add ( new qx . ui . form . renderer . Single ( form ) ) ;
261+ const privacyForm = new qx . ui . form . Form ( ) ;
262+ privacyForm . add ( hideUsername , "Hide Username" , null , "hideUsername" ) ;
263+ privacyForm . add ( hideFullname , "Hide Full Name" , null , "hideFullname" ) ;
264+ privacyForm . add ( hideEmail , "Hide Email" , null , "hideEmail" ) ;
265+ box . add ( new qx . ui . form . renderer . Single ( privacyForm ) ) ;
264266
265- const controller = new qx . data . controller . Object ( privacyModel ) ;
266- controller . addTarget ( hideUsername , "value" , "hideUsername" , true ) ;
267- controller . addTarget ( hideFullname , "value" , "hideFullname" , true ) ;
268- controller . addTarget ( hideEmail , "value" , "hideEmail" , true ) ;
267+ const privacyModelCtrl = new qx . data . controller . Object ( privacyModel ) ;
268+ privacyModelCtrl . addTarget ( hideUsername , "value" , "hideUsername" , true ) ;
269+ privacyModelCtrl . addTarget ( hideFullname , "value" , "hideFullname" , true ) ;
270+ privacyModelCtrl . addTarget ( hideEmail , "value" , "hideEmail" , true ) ;
269271
270- const privacyBtn = new qx . ui . form . Button ( "Update Privacy" ) . set ( {
272+ privacyModelCtrl . addListener ( "changeTarget" , ( ) => {
273+ console . log ( "form changeModel" ) ;
274+ } ) ;
275+
276+ const privacyBtn = new qx . ui . form . Button ( ) . set ( {
277+ label : this . tr ( "Update Privacy" ) ,
271278 appearance : "form-button" ,
272279 alignX : "right" ,
273- allowGrowX : false
280+ allowGrowX : false ,
281+ enabled : false ,
274282 } ) ;
275283 box . add ( privacyBtn ) ;
276284 privacyBtn . addListener ( "execute" , ( ) => {
@@ -334,15 +342,15 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
334342 hideFullname ,
335343 hideEmail ,
336344 ]
337- const evaluateWarningMessage = ( ) => {
345+ const valuesChanged = ( ) => {
338346 if ( privacyFields . every ( privacyField => privacyField . getValue ( ) ) ) {
339347 optOutMessage . show ( ) ;
340348 } else {
341349 optOutMessage . exclude ( ) ;
342350 }
343351 } ;
344- evaluateWarningMessage ( ) ;
345- privacyFields . forEach ( privacyField => privacyField . addListener ( "changeValue" , ( ) => evaluateWarningMessage ( ) ) ) ;
352+ valuesChanged ( ) ;
353+ privacyFields . forEach ( privacyField => privacyField . addListener ( "changeValue" , ( ) => valuesChanged ( ) ) ) ;
346354
347355 return box ;
348356 } ,
0 commit comments