Skip to content

Commit 663df85

Browse files
committed
tab name dependson study name
1 parent bb5e9c8 commit 663df85

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

services/static-webserver/client/source/class/osparc/Application.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,7 @@ qx.Class.define("osparc.Application", {
209209
},
210210

211211
__updateTabName: function() {
212-
let newName = document.title;
213-
const platformName = osparc.store.StaticInfo.getInstance().getPlatformName();
214-
if (osparc.utils.Utils.isInZ43()) {
215-
newName += " Z43";
216-
}
217-
if (platformName) {
218-
newName += ` (${platformName})`;
219-
}
212+
const newName = osparc.utils.Utils.composeTabName();
220213
osparc.utils.Utils.updateTabName(newName);
221214
},
222215

services/static-webserver/client/source/class/osparc/store/Store.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ qx.Class.define("osparc.store.Store", {
5959
check: "osparc.data.model.Study",
6060
init: null,
6161
nullable: true,
62-
event: "changeCurrentStudy"
62+
event: "changeCurrentStudy",
63+
apply: "__applyCurrentStudy",
6364
},
6465
currentStudyId: {
6566
check: "String",
@@ -339,6 +340,21 @@ qx.Class.define("osparc.store.Store", {
339340
}
340341
},
341342

343+
__applyCurrentStudy: function(study) {
344+
if (study) {
345+
study.addListener("changeName", () => {
346+
if (this.getCurrentStudy() === study) {
347+
// the study might have been closed
348+
osparc.utils.Utils.updateTabName(study.getName());
349+
}
350+
});
351+
osparc.utils.Utils.updateTabName(study.getName());
352+
} else {
353+
const newName = osparc.utils.Utils.composeTabName();
354+
osparc.utils.Utils.updateTabName(newName);
355+
}
356+
},
357+
342358
__applyWallets: function(wallets) {
343359
const preferenceSettings = osparc.Preferences.getInstance();
344360
const preferenceWalletId = preferenceSettings.getPreferredWalletId();

services/static-webserver/client/source/class/osparc/utils/Utils.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ qx.Class.define("osparc.utils.Utils", {
9595
document.title = name;
9696
},
9797

98+
composeTabName: function() {
99+
let newName = osparc.store.StaticInfo.getInstance().getDisplayName();
100+
const platformName = osparc.store.StaticInfo.getInstance().getPlatformName();
101+
if (osparc.utils.Utils.isInZ43()) {
102+
newName += " Z43";
103+
}
104+
if (platformName) {
105+
newName += ` (${platformName})`;
106+
}
107+
return newName;
108+
},
109+
98110
replaceTokens: function(str, key, value) {
99111
// `str` might be a a localized string, get the string first
100112
str = str.toString ? str.toString() : str;

0 commit comments

Comments
 (0)