diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index e5302351e..98df1211f 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -86,41 +86,7 @@ function newPlottersManager () { /* Listen to the event of change of status */ productsPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onProductCardStatusChanged) - initializeProductPlotters(onProductPlottersInitialized) - - function onProductPlottersInitialized (err) { - try { - switch (err.result) { - case GLOBAL.DEFAULT_OK_RESPONSE.result: { - initializationReady = true - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - break - } - - case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - - default: { - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onProductPlottersInitialized -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - } - } - - function initializeProductPlotters (callBack) { - try { - /* Lets get all the cards that needs to be loaded. */ + /* Lets get all the cards that needs to be loaded. */ let initializationCounter = 0 let loadingProductCards = productsPanel.getLoadingProductCards() @@ -128,11 +94,11 @@ function newPlottersManager () { let failCounter = 0 if (loadingProductCards.length === 0) { - callBack(GLOBAL.DEFAULT_OK_RESPONSE) + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) return } for (let i = 0; i < loadingProductCards.length; i++) { - /* For each one, we will initialize the associated plotter. */ + /* For each one, we will initialize the associated plotter. */ initializeProductPlotter(loadingProductCards[i], onProductPlotterInitialized) function onProductPlotterInitialized (err) { @@ -153,19 +119,19 @@ function newPlottersManager () { } } if (initializationCounter === loadingProductCards.length) { - // This was the last one. - /* If less than 50% of plotters are initialized then we return FAIL. */ + // This was the last one. + /* If less than 50% of plotters are initialized then we return FAIL. */ if (okCounter >= 1) { - callBack(GLOBAL.DEFAULT_OK_RESPONSE) + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } else { - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initializeProductPlotters -> err = ' + err.stack) } - callBack(GLOBAL.DEFAULT_FAIL_RESPONSE) + if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } @@ -238,7 +204,7 @@ function newPlottersManager () { profile: undefined, notes: undefined } - /* Let the Plotter listen to the event of Cursor Files loaded, so that it can reack recalculating if needed. */ + /* Let the Plotter listen to the event of Cursor Files loaded, so that it can react recalculating if needed. */ storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded) /* Lets load now this plotter panels. */ productPlotter.panels = [] @@ -261,27 +227,7 @@ function newPlottersManager () { } productPlotter.panels.push(plotterPanelHandle) } - /* Create The Profie Picture FloatingObject */ - if (productPlotter.plotter.payload !== undefined) { - let imageId = pProductCard.bot.devTeam + '.' + pProductCard.bot.profilePicture - productPlotter.plotter.payload.profile.subTitle = pProductCard.product.shortDisplayName - productPlotter.plotter.payload.profile.title = pProductCard.bot.displayName - productPlotter.plotter.payload.profile.imageId = imageId - productPlotter.plotter.payload.profile.botAvatar = pProductCard.bot.avatar - canvas.floatingSpace.profileBalls.createNewProfileBall(productPlotter.plotter.payload, onProfileBallCreated) - function onProfileBallCreated (err, pProfileHandle) { - productPlotter.profile = pProfileHandle - /* There is no policy yet of what to do if this fails. */ - } - /* Create the Text Notes */ - canvas.floatingSpace.noteSets.createNoteSet(productPlotter.plotter.payload, productPlotter.plotter.container.eventHandler, onNoteSetCreated) - function onNoteSetCreated (err, pNoteSetHandle) { - productPlotter.noteSet = pNoteSetHandle - /* There is no policy yet of what to do if this fails. */ - } - } - /* Add the new Active Protter to the Array */ productPlotters.push(productPlotter) callBack(GLOBAL.DEFAULT_OK_RESPONSE) } catch (err) { @@ -320,11 +266,6 @@ function newPlottersManager () { /* If the plotter of this card is not on our Active Plotters list, then we remove it. */ for (let i = 0; i < productPlotters.length; i++) { if (productPlotters[i].productCard.code === pProductCard.code) { - if (productPlotters[i].profile !== undefined) { - canvas.floatingSpace.profileBalls.destroyProfileBall(productPlotters[i].profile) - } - /* Destroyd the Note Set */ - canvas.floatingSpace.noteSets.destroyNoteSet(productPlotters[i].noteSet) /* Then the panels. */ for (let j = 0; j < productPlotters[i].panels.length; j++) { canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j])