Skip to content

Commit 781c98d

Browse files
committed
convertKeysToTitles
1 parent 1a92ef3 commit 781c98d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

services/static-webserver/client/source/class/osparc/user/UserDetails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ qx.Class.define("osparc.user.UserDetails", {
277277
user.setContactData(userData);
278278
// remove the displayed properties from the contact info
279279
Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.User)).forEach(prop => delete userData[prop]);
280-
this.__remainingUserData = userData;
280+
this.__remainingUserData = osparc.utils.Utils.convertKeysToTitles(userData);
281281
this.setUser(user);
282282
}
283283
})

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,18 @@ qx.Class.define("osparc.utils.Utils", {
11971197
return str;
11981198
},
11991199

1200+
camelToTitle: function(str) {
1201+
return str
1202+
.replace(/([A-Z])/g, ' $1') // insert space before capital letters
1203+
.replace(/^./, c => c.toUpperCase()); // capitalize first letter
1204+
},
1205+
1206+
convertKeysToTitles: function(obj) {
1207+
return Object.fromEntries(
1208+
Object.entries(obj).map(([key, value]) => [this.camelToTitle(key), value])
1209+
);
1210+
},
1211+
12001212
setIdToWidget: (qWidget, id) => {
12011213
if (qWidget.getContentElement && qWidget.getContentElement() && id) {
12021214
qWidget.getContentElement().setAttribute("osparc-test-id", id);

0 commit comments

Comments
 (0)