@@ -168,15 +168,15 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
168168 if ( plusButtonConfig [ "categories" ] ) {
169169 this . __addCategories ( plusButtonConfig [ "categories" ] ) ;
170170 }
171- plusButtonConfig [ "resources" ] . forEach ( newStudyData => {
172- if ( newStudyData [ "showDisabled" ] ) {
173- this . __addDisabledButton ( newStudyData ) ;
174- } else if ( newStudyData [ "resourceType" ] === "study" ) {
175- this . __addEmptyStudyButton ( newStudyData ) ;
176- } else if ( newStudyData [ "resourceType" ] === "template" ) {
177- this . __addFromTemplateButton ( newStudyData , templates ) ;
178- } else if ( newStudyData [ "resourceType" ] === "service" ) {
179- this . __addFromServiceButton ( newStudyData ) ;
171+ plusButtonConfig [ "resources" ] . forEach ( buttonConfig => {
172+ if ( buttonConfig [ "showDisabled" ] ) {
173+ this . __addDisabledButton ( buttonConfig ) ;
174+ } else if ( buttonConfig [ "resourceType" ] === "study" ) {
175+ this . __addEmptyStudyButton ( buttonConfig ) ;
176+ } else if ( buttonConfig [ "resourceType" ] === "template" ) {
177+ this . __addFromTemplateButton ( buttonConfig , templates ) ;
178+ } else if ( buttonConfig [ "resourceType" ] === "service" ) {
179+ this . __addFromServiceButton ( buttonConfig ) ;
180180 }
181181 } ) ;
182182 } ) ;
@@ -241,55 +241,55 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
241241 }
242242 } ,
243243
244- __addDisabledButton : function ( newStudyData ) {
245- const menuButton = this . self ( ) . createMenuButton ( null , newStudyData [ "title" ] , newStudyData [ "reason" ] ) ;
246- osparc . utils . Utils . setIdToWidget ( menuButton , newStudyData [ "idToWidget" ] ) ;
244+ __addDisabledButton : function ( buttonConfig ) {
245+ const menuButton = this . self ( ) . createMenuButton ( null , buttonConfig [ "title" ] , buttonConfig [ "reason" ] ) ;
246+ osparc . utils . Utils . setIdToWidget ( menuButton , buttonConfig [ "idToWidget" ] ) ;
247247 menuButton . setEnabled ( false ) ;
248248
249- this . __addIcon ( menuButton , newStudyData ) ;
250- this . __addFromResourceButton ( menuButton , newStudyData [ "category" ] ) ;
249+ this . __addIcon ( menuButton , buttonConfig ) ;
250+ this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
251251 } ,
252252
253- __addEmptyStudyButton : function ( newStudyData ) {
254- const menuButton = this . self ( ) . createMenuButton ( null , newStudyData [ "title" ] ) ;
255- osparc . utils . Utils . setIdToWidget ( menuButton , newStudyData [ "idToWidget" ] ) ;
253+ __addEmptyStudyButton : function ( buttonConfig ) {
254+ const menuButton = this . self ( ) . createMenuButton ( null , buttonConfig [ "title" ] ) ;
255+ osparc . utils . Utils . setIdToWidget ( menuButton , buttonConfig [ "idToWidget" ] ) ;
256256
257257 menuButton . addListener ( "tap" , ( ) => {
258258 this . fireDataEvent ( "newEmptyStudyClicked" , {
259- newStudyLabel : newStudyData [ "newStudyLabel" ] ,
259+ newStudyLabel : buttonConfig [ "newStudyLabel" ] ,
260260 } ) ;
261261 } ) ;
262262
263- this . __addIcon ( menuButton , newStudyData ) ;
264- this . __addFromResourceButton ( menuButton , newStudyData [ "category" ] ) ;
263+ this . __addIcon ( menuButton , buttonConfig ) ;
264+ this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
265265 } ,
266266
267- __addFromTemplateButton : function ( newStudyData , templates ) {
268- const menuButton = this . self ( ) . createMenuButton ( null , newStudyData [ "title" ] ) ;
269- osparc . utils . Utils . setIdToWidget ( menuButton , newStudyData [ "idToWidget" ] ) ;
267+ __addFromTemplateButton : function ( buttonConfig , templates ) {
268+ const menuButton = this . self ( ) . createMenuButton ( null , buttonConfig [ "title" ] ) ;
269+ osparc . utils . Utils . setIdToWidget ( menuButton , buttonConfig [ "idToWidget" ] ) ;
270270 // disable it until found in templates store
271271 menuButton . setEnabled ( false ) ;
272272
273- let templateMetadata = templates . find ( t => t . name === newStudyData [ "expectedTemplateLabel" ] ) ;
273+ let templateMetadata = templates . find ( t => t . name === buttonConfig [ "expectedTemplateLabel" ] ) ;
274274 if ( templateMetadata ) {
275275 menuButton . setEnabled ( true ) ;
276276 menuButton . addListener ( "tap" , ( ) => {
277277 this . fireDataEvent ( "newStudyFromTemplateClicked" , {
278278 templateData : templateMetadata ,
279- newStudyLabel : newStudyData [ "newStudyLabel" ] ,
279+ newStudyLabel : buttonConfig [ "newStudyLabel" ] ,
280280 } ) ;
281281 } ) ;
282- this . __addIcon ( menuButton , newStudyData , templateMetadata ) ;
283- this . __addFromResourceButton ( menuButton , newStudyData [ "category" ] ) ;
282+ this . __addIcon ( menuButton , buttonConfig , templateMetadata ) ;
283+ this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
284284 }
285285 } ,
286286
287- __addFromServiceButton : function ( newStudyData ) {
287+ __addFromServiceButton : function ( buttonConfig ) {
288288 const addListenerToButton = ( menuButton , latestMetadata ) => {
289289 menuButton . addListener ( "tap" , ( ) => {
290290 this . fireDataEvent ( "newStudyFromServiceClicked" , {
291291 serviceMetadata : latestMetadata ,
292- newStudyLabel : newStudyData [ "newStudyLabel" ] ,
292+ newStudyLabel : buttonConfig [ "newStudyLabel" ] ,
293293 } ) ;
294294 } ) ;
295295
@@ -299,30 +299,38 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
299299 e . stopPropagation ( ) ;
300300 latestMetadata [ "resourceType" ] = "service" ;
301301 const resourceDetails = new osparc . dashboard . ResourceDetails ( latestMetadata ) ;
302- osparc . dashboard . ResourceDetails . popUpInWindow ( resourceDetails ) ;
302+ const win = osparc . dashboard . ResourceDetails . popUpInWindow ( resourceDetails ) ;
303+ resourceDetails . addListener ( "openService" , ev => {
304+ win . close ( ) ;
305+ const openServiceData = ev . getData ( ) ;
306+ this . fireDataEvent ( "newStudyFromServiceClicked" , {
307+ serviceMetadata : openServiceData ,
308+ newStudyLabel : buttonConfig [ "newStudyLabel" ] ,
309+ } ) ;
310+ } ) ;
303311 }
304312 const infoButton = new osparc . ui . basic . IconButton ( osparc . ui . hint . InfoHint . INFO_ICON + "/16" , cb ) ;
305313 // where the shortcut is supposed to go
306314 // eslint-disable-next-line no-underscore-dangle
307315 menuButton . _add ( infoButton , { column : 2 } ) ;
308316 } ;
309317
310- if ( "expectedKey" in newStudyData ) {
311- const menuButton = this . self ( ) . createMenuButton ( null , newStudyData [ "title" ] ) ;
312- osparc . utils . Utils . setIdToWidget ( menuButton , newStudyData [ "idToWidget" ] ) ;
318+ if ( "expectedKey" in buttonConfig ) {
319+ const menuButton = this . self ( ) . createMenuButton ( null , buttonConfig [ "title" ] ) ;
320+ osparc . utils . Utils . setIdToWidget ( menuButton , buttonConfig [ "idToWidget" ] ) ;
313321 // disable it until found in services store
314322 menuButton . setEnabled ( false ) ;
315323
316- const key = newStudyData [ "expectedKey" ] ;
324+ const key = buttonConfig [ "expectedKey" ] ;
317325 const latestMetadata = osparc . store . Services . getLatest ( key ) ;
318326 if ( ! latestMetadata ) {
319327 return ;
320328 }
321329 menuButton . setEnabled ( true ) ;
322- this . __addIcon ( menuButton , newStudyData , latestMetadata ) ;
323- this . __addFromResourceButton ( menuButton , newStudyData [ "category" ] ) ;
330+ this . __addIcon ( menuButton , buttonConfig , latestMetadata ) ;
331+ this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
324332 addListenerToButton ( menuButton , latestMetadata ) ;
325- } else if ( "myMostUsed" in newStudyData ) {
333+ } else if ( "myMostUsed" in buttonConfig ) {
326334 const excludeFrontend = true ;
327335 const excludeDeprecated = true
328336 osparc . store . Services . getServicesLatestList ( excludeFrontend , excludeDeprecated )
@@ -331,7 +339,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
331339 "sort" : "hits" ,
332340 "order" : "down"
333341 } ) ;
334- for ( let i = 0 ; i < newStudyData [ "myMostUsed" ] ; i ++ ) {
342+ for ( let i = 0 ; i < buttonConfig [ "myMostUsed" ] ; i ++ ) {
335343 const latestMetadata = servicesList [ i ] ;
336344 if ( latestMetadata && latestMetadata [ "hits" ] > 0 ) {
337345 const menuButton = new qx . ui . menu . Button ( ) . set ( {
@@ -340,7 +348,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
340348 allowGrowX : true ,
341349 } ) ;
342350 this . __addIcon ( menuButton , null , latestMetadata ) ;
343- this . __addFromResourceButton ( menuButton , newStudyData [ "category" ] ) ;
351+ this . __addFromResourceButton ( menuButton , buttonConfig [ "category" ] ) ;
344352 addListenerToButton ( menuButton , latestMetadata ) ;
345353 }
346354 }
0 commit comments