diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index b82286a5f0c..ceaee03b3ac 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -746,7 +746,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { break; case "tis": case "tiplite": - this.__addTIPPlusButtons(); + this.__addTIPPlusButton(); break; case "s4l": case "s4lacad": @@ -770,24 +770,27 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { this._resourcesContainer.addNonResourceCard(newStudyBtn); }, - __addTIPPlusButtons: function() { - osparc.data.Resources.get("templates") - .then(templates => { - if (templates) { - osparc.utils.Utils.fetchJSON("/resource/osparc/new_studies.json") - .then(newStudiesData => { - const product = osparc.product.Utils.getProductName() - if (product in newStudiesData) { - const mode = this._resourcesContainer.getMode(); - const title = this.tr("New Plan"); - const newStudyBtn = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title) : new osparc.dashboard.ListButtonNew(title); - newStudyBtn.setCardKey("new-study"); - newStudyBtn.subscribeToFilterGroup("searchBarFilter"); - osparc.utils.Utils.setIdToWidget(newStudyBtn, "newStudyBtn"); - this._resourcesContainer.addNonResourceCard(newStudyBtn); - newStudyBtn.addListener("execute", () => { - newStudyBtn.setValue(false); + __addTIPPlusButton: function() { + const mode = this._resourcesContainer.getMode(); + const title = this.tr("New Plan"); + const newStudyBtn = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title) : new osparc.dashboard.ListButtonNew(title); + newStudyBtn.setCardKey("new-study"); + newStudyBtn.subscribeToFilterGroup("searchBarFilter"); + osparc.utils.Utils.setIdToWidget(newStudyBtn, "newStudyBtn"); + this._resourcesContainer.addNonResourceCard(newStudyBtn); + newStudyBtn.setEnabled(false); + osparc.utils.Utils.fetchJSON("/resource/osparc/new_studies.json") + .then(newStudiesData => { + const product = osparc.product.Utils.getProductName() + if (product in newStudiesData) { + newStudyBtn.setEnabled(true); + + newStudyBtn.addListener("execute", () => { + newStudyBtn.setValue(false); + osparc.data.Resources.get("templates") + .then(templates => { + if (templates) { const newStudies = new osparc.dashboard.NewStudies(newStudiesData[product]); newStudies.addListener("templatesLoaded", () => { newStudies.setGroupBy("category"); @@ -806,9 +809,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); osparc.utils.Utils.setIdToWidget(win, "newStudiesWindow"); }); - }); - } - }); + } + }); + }); } }); }, diff --git a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js index 3351ed0fc96..5709bfd70a2 100644 --- a/services/static-webserver/client/source/class/osparc/info/StudyLarge.js +++ b/services/static-webserver/client/source/class/osparc/info/StudyLarge.js @@ -324,6 +324,10 @@ qx.Class.define("osparc.info.StudyLarge", { studyData["resourceType"] = this.__isTemplate ? "template" : "study"; this.fireDataEvent("updateStudy", studyData); qx.event.message.Bus.getInstance().dispatchByName("updateStudy", studyData); + if (this.__isTemplate) { + // reload templates + osparc.data.Resources.get("templates", {}, false) + } }) .catch(err => { console.error(err);