@@ -84,14 +84,8 @@ qx.Class.define("osparc.support.ConversationPage", {
8484            } ) ; 
8585          this . getChildControl ( "conversation-header-center-layout" ) . addAt ( control ,  0 ) ; 
8686          break ; 
87-         case  "conversation-extra-content" :
88-           control  =  new  qx . ui . basic . Label ( ) . set ( { 
89-             font : "text-12" , 
90-             textColor : "text-disabled" , 
91-             rich : true , 
92-             allowGrowX : true , 
93-             selectable : true , 
94-           } ) ; 
87+         case  "conversation-extra-layout" :
88+           control  =  new  qx . ui . container . Composite ( new  qx . ui . layout . VBox ( 2 ) ) ; 
9589          this . getChildControl ( "conversation-header-center-layout" ) . addAt ( control ,  1 ) ; 
9690          break ; 
9791        case  "open-project-button" :
@@ -105,6 +99,19 @@ qx.Class.define("osparc.support.ConversationPage", {
10599          control . addListener ( "execute" ,  ( )  =>  this . __openProjectDetails ( ) ) ; 
106100          this . getChildControl ( "conversation-header-layout" ) . addAt ( control ,  2 ) ; 
107101          break ; 
102+         case  "set-appointment-button" : { 
103+           control  =  new  qx . ui . form . Button ( ) . set ( { 
104+             maxWidth : 26 , 
105+             maxHeight : 24 , 
106+             padding : [ 0 ,  6 ] , 
107+             alignX : "center" , 
108+             alignY : "middle" , 
109+             icon : "@FontAwesome5Solid/clock/12" , 
110+           } ) ; 
111+           control . addListener ( "execute" ,  ( )  =>  this . __openAppointmentDetails ( ) ) ; 
112+           this . getChildControl ( "conversation-header-layout" ) . addAt ( control ,  3 ) ; 
113+           break ; 
114+         } 
108115        case  "conversation-options" : { 
109116          control  =  new  qx . ui . form . MenuButton ( ) . set ( { 
110117            maxWidth : 24 , 
@@ -123,7 +130,7 @@ qx.Class.define("osparc.support.ConversationPage", {
123130          } ) ; 
124131          renameButton . addListener ( "execute" ,  ( )  =>  this . __renameConversation ( ) ) ; 
125132          menu . add ( renameButton ) ; 
126-           this . getChildControl ( "conversation-header-layout" ) . addAt ( control ,  3 ) ; 
133+           this . getChildControl ( "conversation-header-layout" ) . addAt ( control ,  4 ) ; 
127134          break ; 
128135        } 
129136        case  "conversation-content" :
@@ -146,28 +153,65 @@ qx.Class.define("osparc.support.ConversationPage", {
146153        title . setValue ( this . tr ( "Ask a Question" ) ) ; 
147154      } 
148155
149-       const  extraContextLabel  =  this . getChildControl ( "conversation-extra-content " ) ; 
156+       const  extraContextLayout  =  this . getChildControl ( "conversation-extra-layout " ) ; 
150157      const  amISupporter  =  osparc . store . Products . getInstance ( ) . amIASupportUser ( ) ; 
151-       if  ( conversation  &&  amISupporter )  { 
152-         const  extraContext  =  conversation . getExtraContext ( ) ; 
153-         if  ( extraContext  &&  Object . keys ( extraContext ) . length )  { 
154-           let  extraContextText  =  `Ticket ID: ${ conversation . getConversationId ( ) }  ; 
155-           const  contextProjectId  =  conversation . getContextProjectId ( ) ; 
156-           if  ( contextProjectId )  { 
157-             extraContextText  +=  `<br>Project ID: ${ contextProjectId }  ; 
158+       if  ( conversation )  { 
159+         const  createExtraContextLabel  =  text  =>  { 
160+           return  new  qx . ui . basic . Label ( text ) . set ( { 
161+             font : "text-12" , 
162+             textColor : "text-disabled" , 
163+             rich : true , 
164+             allowGrowX : true , 
165+             selectable : true , 
166+           } ) ; 
167+         } ; 
168+         const  updateExtraContext  =  ( )  =>  { 
169+           extraContextLayout . removeAll ( ) ; 
170+           const  extraContext  =  conversation . getExtraContext ( ) ; 
171+           if  ( extraContext  &&  Object . keys ( extraContext ) . length )  { 
172+             const  ticketIdLabel  =  createExtraContextLabel ( `Ticket ID: ${ conversation . getConversationId ( ) }  ) ; 
173+             extraContextLayout . add ( ticketIdLabel ) ; 
174+             const  contextProjectId  =  conversation . getContextProjectId ( ) ; 
175+             if  ( contextProjectId  &&  amISupporter )  { 
176+               const  projectIdLabel  =  createExtraContextLabel ( `Project ID: ${ contextProjectId }  ) ; 
177+               extraContextLayout . add ( projectIdLabel ) ; 
178+             } 
179+             const  appointment  =  conversation . getAppointment ( ) ; 
180+             if  ( appointment )  { 
181+               const  appointmentLabel  =  createExtraContextLabel ( ) ; 
182+               let  appointmentText  =  "Appointment: " ; 
183+               if  ( appointment  ===  "requested" )  { 
184+                 // still pending 
185+                 appointmentText  +=  appointment ; 
186+               }  else  { 
187+                 // already set 
188+                 appointmentText  +=  osparc . utils . Utils . formatDateAndTime ( new  Date ( appointment ) ) ; 
189+                 appointmentLabel . set ( { 
190+                   cursor : "pointer" , 
191+                   toolTipText : osparc . utils . Utils . formatDateWithCityAndTZ ( new  Date ( appointment ) ) , 
192+                 } ) ; 
193+               } 
194+               appointmentLabel . setValue ( appointmentText ) ; 
195+               extraContextLayout . add ( appointmentLabel ) ; 
196+             } 
158197          } 
159-           extraContextLabel . setValue ( extraContextText ) ; 
160-         } 
161-         extraContextLabel . show ( ) ; 
162-       }  else  { 
163-         extraContextLabel . exclude ( ) ; 
198+         } ; 
199+         updateExtraContext ( ) ; 
200+         conversation . addListener ( "changeExtraContext" ,  ( )  =>  updateExtraContext ( ) ,  this ) ; 
164201      } 
165202
166-       const  openButton  =  this . getChildControl ( "open-project-button" ) ; 
203+       const  openProjectButton  =  this . getChildControl ( "open-project-button" ) ; 
167204      if  ( conversation  &&  conversation . getContextProjectId ( ) )  { 
168-         openButton . show ( ) ; 
205+         openProjectButton . show ( ) ; 
169206      }  else  { 
170-         openButton . exclude ( ) ; 
207+         openProjectButton . exclude ( ) ; 
208+       } 
209+ 
210+       const  setAppointmentButton  =  this . getChildControl ( "set-appointment-button" ) ; 
211+       if  ( conversation  &&  conversation . getAppointment ( )  &&  amISupporter )  { 
212+         setAppointmentButton . show ( ) ; 
213+       }  else  { 
214+         setAppointmentButton . exclude ( ) ; 
171215      } 
172216
173217      const  options  =  this . getChildControl ( "conversation-options" ) ; 
@@ -193,6 +237,17 @@ qx.Class.define("osparc.support.ConversationPage", {
193237      } 
194238    } , 
195239
240+     __openAppointmentDetails : function ( )  { 
241+       const  win  =  new  osparc . widget . DateTimeChooser ( ) ; 
242+       win . addListener ( "dateChanged" ,  e  =>  { 
243+         const  newValue  =  e . getData ( ) [ "newValue" ] ; 
244+         this . getConversation ( ) . setAppointment ( newValue ) 
245+           . catch ( err  =>  console . error ( err ) ) ; 
246+         win . close ( ) ; 
247+       } ,  this ) ; 
248+       win . open ( ) ; 
249+     } , 
250+ 
196251    __renameConversation : function ( )  { 
197252      let  oldName  =  this . getConversation ( ) . getName ( ) ; 
198253      if  ( oldName  ===  "null" )  { 
@@ -207,5 +262,19 @@ qx.Class.define("osparc.support.ConversationPage", {
207262      renamer . center ( ) ; 
208263      renamer . open ( ) ; 
209264    } , 
265+ 
266+     __getAddMessageField : function ( )  { 
267+       return  this . getChildControl ( "conversation-content" )  && 
268+         this . getChildControl ( "conversation-content" ) . getChildControl ( "add-message" ) ; 
269+     } , 
270+ 
271+     postMessage : function ( message )  { 
272+       const  addMessage  =  this . __getAddMessageField ( ) ; 
273+       if  ( addMessage  &&  addMessage . getChildControl ( "comment-field" ) )  { 
274+         addMessage . getChildControl ( "comment-field" ) . setText ( message ) ; 
275+         return  addMessage . addComment ( ) ; 
276+       } 
277+       return  Promise . reject ( ) ; 
278+     } , 
210279  } 
211280} ) ; 
0 commit comments