@@ -61,7 +61,8 @@ qx.Class.define("osparc.po.Announcements", {
6161 form . add ( title , this . tr ( "Title" ) ) ;
6262
6363 const description = new qx . ui . form . TextArea ( ) . set ( {
64- placeholder : this . tr ( "description" )
64+ placeholder : this . tr ( "description" ) ,
65+ maxHeight : 60
6566 } ) ;
6667 form . add ( description , this . tr ( "Description" ) ) ;
6768
@@ -94,14 +95,12 @@ qx.Class.define("osparc.po.Announcements", {
9495 form . add ( start , this . tr ( "Start" ) ) ;
9596
9697 const end = new qx . ui . form . DateField ( ) ;
97- start . setDateFormat ( dateFormat ) ;
98- start . setValue ( now ) ;
98+ end . setDateFormat ( dateFormat ) ;
99+ end . setValue ( now ) ;
99100 form . add ( end , this . tr ( "End" ) ) ;
100101
101102 const generateAnnouncementBtn = new osparc . ui . form . FetchButton ( this . tr ( "Generate" ) ) ;
102- generateAnnouncementBtn . set ( {
103- appearance : "form-button"
104- } ) ;
103+ generateAnnouncementBtn . set ( { appearance : "form-button" } ) ;
105104 generateAnnouncementBtn . addListener ( "execute" , ( ) => {
106105 const widgets = [ ] ;
107106 if ( widgetLogin . getValue ( ) ) {
@@ -113,12 +112,16 @@ qx.Class.define("osparc.po.Announcements", {
113112 if ( widgetUserMenu . getValue ( ) ) {
114113 widgets . push ( "user-menu" ) ;
115114 }
115+ if ( widgets . length === 0 ) {
116+ const msg = "Select at least one widget" ;
117+ osparc . FlashMessenger . getInstance ( ) . logAs ( msg , "WARNING" ) ;
118+ }
116119 const announcementData = {
117120 "id" : osparc . utils . Utils . uuidV4 ( ) ,
118- "products" : [ osparc . product . Utils . getProductName ( ) ] ,
119- "title" : title . getValue ( ) ,
120- "description" : description . getValue ( ) ,
121- "widgets" : JSON . stringify ( widgets ) ,
121+ "products" : "[" + osparc . product . Utils . getProductName ( ) + "]" ,
122+ "title" : title . getValue ( ) ? encodeURIComponent ( title . getValue ( ) ) : "" ,
123+ "description" : description . getValue ( ) ? encodeURIComponent ( description . getValue ( ) ) : "" ,
124+ "widgets" : "[" + widgets . join ( "" ) + "]" ,
122125 "start" : start . getValue ( ) ,
123126 "end" : end . getValue ( ) ,
124127 } ;
@@ -133,31 +136,22 @@ qx.Class.define("osparc.po.Announcements", {
133136 const vBox = this . getChildControl ( "announcement-container" ) ;
134137 vBox . removeAll ( ) ;
135138
136- const hBox = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) . set ( {
137- alignY : "middle"
138- } ) ) ;
139- vBox . add ( hBox ) ;
140-
141- const announcementField = new qx . ui . form . TextArea ( announcementData ) . set ( {
139+ const announcementField = new qx . ui . form . TextArea ( JSON . stringify ( announcementData ) ) . set ( {
142140 readOnly : true
143141 } ) ;
144- hBox . add ( announcementField ) ;
142+ vBox . add ( announcementField ) ;
145143
146- const copyAnnouncementBtn = new qx . ui . form . Button ( this . tr ( "Copy announcement" ) ) ;
147- copyAnnouncementBtn . set ( { appearance : "form-button-outlined" } ) ;
144+ const copyAnnouncementBtn = new qx . ui . form . Button ( this . tr ( "Copy announcement" ) ) . set ( {
145+ alignX : "left" ,
146+ allowGrowX : false ,
147+ } ) ;
148+ copyAnnouncementBtn . set ( { appearance : "form-button" } ) ;
148149 copyAnnouncementBtn . addListener ( "execute" , ( ) => {
149150 if ( osparc . utils . Utils . copyTextToClipboard ( announcementData ) ) {
150151 copyAnnouncementBtn . setIcon ( "@FontAwesome5Solid/check/12" ) ;
151152 }
152153 } ) ;
153- hBox . add ( copyAnnouncementBtn ) ;
154-
155- const announcementRespViewer = new osparc . ui . basic . JsonTreeWidget ( announcementData , "announcement-data" ) ;
156- const container = new qx . ui . container . Scroll ( ) ;
157- container . add ( announcementRespViewer ) ;
158- vBox . add ( container , {
159- flex : 1
160- } ) ;
154+ vBox . add ( copyAnnouncementBtn ) ;
161155 }
162156 }
163157} ) ;
0 commit comments