@@ -20,31 +20,34 @@ qx.Class.define("osparc.conversation.MessageUI", {
2020 extend : qx . ui . core . Widget ,
2121
2222 /**
23- * @param comment {Object} comment
23+ * @param message {Object} message
2424 */
25- construct : function ( comment ) {
25+ construct : function ( message ) {
2626 this . base ( arguments ) ;
2727
28- this . __comment = comment ;
28+ this . __message = message ;
2929
30- const isMyComment = this . __isMyComment ( ) ;
30+ const isMyMessage = this . self ( ) . isMyMessage ( this . __message ) ;
3131 const layout = new qx . ui . layout . Grid ( 12 , 4 ) ;
32- layout . setColumnFlex ( 1 , 1 ) ; // comment
33- layout . setColumnFlex ( isMyComment ? 0 : 2 , 3 ) ; // spacer
32+ layout . setColumnFlex ( 1 , 1 ) ; // content
33+ layout . setColumnFlex ( isMyMessage ? 0 : 2 , 3 ) ; // spacer
3434 this . _setLayout ( layout ) ;
3535 this . setPadding ( 5 ) ;
3636
3737 this . __buildLayout ( ) ;
3838 } ,
3939
40- members : {
41- __comment : null ,
40+ statics : {
41+ isMyMessage : function ( message ) {
42+ return message && osparc . auth . Data . getInstance ( ) . getGroupId ( ) === message [ "userGroupId" ] ;
43+ }
44+ } ,
4245
43- __isMyComment : function ( ) {
44- return this . __comment && osparc . auth . Data . getInstance ( ) . getGroupId ( ) === this . __comment [ "userGroupId" ] ;
45- } ,
46+ members : {
47+ __message : null ,
4648
4749 _createChildControlImpl : function ( id ) {
50+ const isMyMessage = this . self ( ) . isMyMessage ( this . __message ) ;
4851 let control ;
4952 switch ( id ) {
5053 case "thumbnail" :
@@ -53,17 +56,17 @@ qx.Class.define("osparc.conversation.MessageUI", {
5356 maxWidth : 32 ,
5457 maxHeight : 32 ,
5558 decorator : "rounded" ,
56- marginTop : 2 ,
59+ marginTop : 4 ,
5760 } ) ;
5861 this . _add ( control , {
5962 row : 0 ,
60- column : this . __isMyComment ( ) ? 2 : 0 ,
63+ column : isMyMessage ? 2 : 0 ,
6164 rowSpan : 2 ,
6265 } ) ;
6366 break ;
6467 case "header-layout" :
6568 control = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 5 ) . set ( {
66- alignX : this . __isMyComment ( ) ? "right" : "left"
69+ alignX : isMyMessage ? "right" : "left"
6770 } ) ) ;
6871 control . addAt ( new qx . ui . basic . Label ( "-" ) , 1 ) ;
6972 this . _add ( control , {
@@ -75,15 +78,15 @@ qx.Class.define("osparc.conversation.MessageUI", {
7578 control = new qx . ui . basic . Label ( ) . set ( {
7679 font : "text-12"
7780 } ) ;
78- this . getChildControl ( "header-layout" ) . addAt ( control , this . __isMyComment ( ) ? 2 : 0 ) ;
81+ this . getChildControl ( "header-layout" ) . addAt ( control , isMyMessage ? 2 : 0 ) ;
7982 break ;
8083 case "last-updated" :
8184 control = new qx . ui . basic . Label ( ) . set ( {
8285 font : "text-12"
8386 } ) ;
84- this . getChildControl ( "header-layout" ) . addAt ( control , this . __isMyComment ( ) ? 0 : 2 ) ;
87+ this . getChildControl ( "header-layout" ) . addAt ( control , isMyMessage ? 0 : 2 ) ;
8588 break ;
86- case "comment -content" :
89+ case "message -content" :
8790 control = new osparc . ui . markdown . Markdown ( ) . set ( {
8891 decorator : "rounded" ,
8992 noMargin : true ,
@@ -92,7 +95,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
9295 allowGrowX : true ,
9396 } ) ;
9497 control . getContentElement ( ) . setStyles ( {
95- "text-align" : this . __isMyComment ( ) ? "right" : "left" ,
98+ "text-align" : isMyMessage ? "right" : "left" ,
9699 } ) ;
97100 this . _add ( control , {
98101 row : 1 ,
@@ -103,7 +106,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
103106 control = new qx . ui . core . Spacer ( ) ;
104107 this . _add ( control , {
105108 row : 1 ,
106- column : this . __isMyComment ( ) ? 0 : 2 ,
109+ column : isMyMessage ? 0 : 2 ,
107110 } ) ;
108111 break ;
109112 }
@@ -116,31 +119,31 @@ qx.Class.define("osparc.conversation.MessageUI", {
116119
117120 const userName = this . getChildControl ( "user-name" ) ;
118121
119- const date = new Date ( this . __comment [ "modified" ] ) ;
122+ const date = new Date ( this . __message [ "modified" ] ) ;
120123 const date2 = osparc . utils . Utils . formatDateAndTime ( date ) ;
121124 const lastUpdate = this . getChildControl ( "last-updated" ) ;
122125 lastUpdate . setValue ( date2 ) ;
123126
124- const commentContent = this . getChildControl ( "comment -content" ) ;
125- if ( this . __comment [ "type" ] === "NOTIFICATION" ) {
126- const userGroupId = parseInt ( this . __comment [ "content" ] ) ;
127- commentContent . setValue ( "🔔 " + this . tr ( "Notified" ) + ": " ) ;
127+ const messageContent = this . getChildControl ( "message -content" ) ;
128+ if ( this . __message [ "type" ] === "NOTIFICATION" ) {
129+ const userGroupId = parseInt ( this . __message [ "content" ] ) ;
130+ messageContent . setValue ( "🔔 " + this . tr ( "Notified" ) + ": " ) ;
128131 osparc . store . Users . getInstance ( ) . getUser ( userGroupId )
129132 . then ( user => {
130133 if ( user ) {
131- commentContent . setValue ( commentContent . getValue ( ) + user . getLabel ( ) ) ;
134+ messageContent . setValue ( messageContent . getValue ( ) + user . getLabel ( ) ) ;
132135 } else {
133- commentContent . setValue ( commentContent . getValue ( ) + userGroupId ) ;
136+ messageContent . setValue ( messageContent . getValue ( ) + userGroupId ) ;
134137 }
135138 } )
136139 . catch ( ( ) => {
137- commentContent . setValue ( commentContent . getValue ( ) + userGroupId ) ;
140+ messageContent . setValue ( messageContent . getValue ( ) + userGroupId ) ;
138141 } ) ;
139- } else if ( this . __comment [ "type" ] === "MESSAGE" ) {
140- commentContent . setValue ( this . __comment [ "content" ] ) ;
142+ } else if ( this . __message [ "type" ] === "MESSAGE" ) {
143+ messageContent . setValue ( this . __message [ "content" ] ) ;
141144 }
142145
143- osparc . store . Users . getInstance ( ) . getUser ( this . __comment [ "userGroupId" ] )
146+ osparc . store . Users . getInstance ( ) . getUser ( this . __message [ "userGroupId" ] )
144147 . then ( user => {
145148 if ( user ) {
146149 thumbnail . setSource ( user . getThumbnail ( ) ) ;
0 commit comments