@@ -28,18 +28,18 @@ qx.Class.define("osparc.support.ConversationPage", {
2828
2929 this . getChildControl ( "back-button" ) ;
3030
31- const conversation = this . getChildControl ( "conversation" ) ;
32- this . bind ( "conversationId " , conversation , "conversationId " ) ;
33- conversation . bind ( "conversationId " , this , "conversationId " ) ;
31+ const conversation = this . getChildControl ( "conversation-content " ) ;
32+ this . bind ( "conversation " , conversation , "conversation " ) ;
33+ conversation . bind ( "conversation " , this , "conversation " ) ;
3434 } ,
3535
3636 properties : {
37- conversationId : {
38- check : "String " ,
37+ conversation : {
38+ check : "osparc.data.model.Conversation " ,
3939 init : null ,
4040 nullable : true ,
41- event : "changeConversationId " ,
42- apply : "__applyConversationId " ,
41+ event : "changeConversation " ,
42+ apply : "__applyConversation " ,
4343 } ,
4444 } ,
4545
@@ -94,17 +94,28 @@ qx.Class.define("osparc.support.ConversationPage", {
9494 } ) ;
9595 this . getChildControl ( "conversation-header-center-layout" ) . addAt ( control , 1 ) ;
9696 break ;
97- case "conversation-options" :
97+ case "conversation-options" : {
9898 control = new qx . ui . form . MenuButton ( ) . set ( {
9999 maxWidth : 22 ,
100100 maxHeight : 22 ,
101101 alignX : "center" ,
102102 alignY : "middle" ,
103103 icon : "@FontAwesome5Solid/ellipsis-v/14" ,
104104 } ) ;
105+ const menu = new qx . ui . menu . Menu ( ) . set ( {
106+ position : "bottom-right" ,
107+ } ) ;
108+ control . setMenu ( menu ) ;
109+ const renameButton = new qx . ui . menu . Button ( ) . set ( {
110+ label : this . tr ( "Rename" ) ,
111+ icon : "@FontAwesome5Solid/i-cursor/10"
112+ } ) ;
113+ renameButton . addListener ( "execute" , ( ) => this . __renameConversation ( ) ) ;
114+ menu . add ( renameButton ) ;
105115 this . getChildControl ( "conversation-header-layout" ) . addAt ( control , 2 ) ;
106116 break ;
107- case "conversation" :
117+ }
118+ case "conversation-content" :
108119 control = new osparc . support . Conversation ( ) ;
109120 const scroll = new qx . ui . container . Scroll ( ) ;
110121 scroll . add ( control ) ;
@@ -116,31 +127,43 @@ qx.Class.define("osparc.support.ConversationPage", {
116127 return control || this . base ( arguments , id ) ;
117128 } ,
118129
119- __applyConversationId : function ( conversationId ) {
130+ __applyConversation : function ( conversation ) {
120131 const title = this . getChildControl ( "conversation-title" ) ;
121132 const options = this . getChildControl ( "conversation-options" ) ;
122- if ( conversationId ) {
123- osparc . store . ConversationsSupport . getInstance ( ) . getConversation ( conversationId )
124- . then ( conversation => {
125- conversation . bind ( "nameAlias" , title , "value" ) ;
126- const amISupporter = osparc . store . Products . getInstance ( ) . amIASupportUser ( ) ;
127- const extraContextLabel = this . getChildControl ( "conversation-extra-content" ) ;
128- extraContextLabel . setVisibility ( amISupporter ? "visible" : "excluded" ) ;
129- const extraContext = conversation . getExtraContext ( ) ;
130- if ( amISupporter && extraContext && Object . keys ( extraContext ) . length ) {
131- let extraContextText = `Support ID: ${ conversationId } ` ;
132- const contextProjectId = conversation . getContextProjectId ( ) ;
133- if ( contextProjectId ) {
134- extraContextText += `<br>Project ID: ${ contextProjectId } ` ;
135- }
136- extraContextLabel . setValue ( extraContextText ) ;
137- }
138- options . show ( ) ;
139- } ) ;
133+ if ( conversation ) {
134+ conversation . bind ( "nameAlias" , title , "value" ) ;
135+ const amISupporter = osparc . store . Products . getInstance ( ) . amIASupportUser ( ) ;
136+ const extraContextLabel = this . getChildControl ( "conversation-extra-content" ) ;
137+ extraContextLabel . setVisibility ( amISupporter ? "visible" : "excluded" ) ;
138+ const extraContext = conversation . getExtraContext ( ) ;
139+ if ( amISupporter && extraContext && Object . keys ( extraContext ) . length ) {
140+ let extraContextText = `Support ID: ${ conversation } ` ;
141+ const contextProjectId = conversation . getContextProjectId ( ) ;
142+ if ( contextProjectId ) {
143+ extraContextText += `<br>Project ID: ${ contextProjectId } ` ;
144+ }
145+ extraContextLabel . setValue ( extraContextText ) ;
146+ }
147+ options . show ( ) ;
140148 } else {
141149 title . setValue ( "" ) ;
142150 options . exclude ( ) ;
143151 }
144152 } ,
153+
154+ __renameConversation : function ( ) {
155+ let oldName = this . getConversation ( ) . getName ( ) ;
156+ if ( oldName === "null" ) {
157+ oldName = "" ;
158+ }
159+ const renamer = new osparc . widget . Renamer ( oldName ) ;
160+ renamer . addListener ( "labelChanged" , e => {
161+ renamer . close ( ) ;
162+ const newLabel = e . getData ( ) [ "newLabel" ] ;
163+ this . getConversation ( ) . setName ( newLabel ) ;
164+ } , this ) ;
165+ renamer . center ( ) ;
166+ renamer . open ( ) ;
167+ } ,
145168 }
146169} ) ;
0 commit comments