Skip to content

Commit 9ffc52d

Browse files
committed
categories defined in the backend
1 parent 6bc3f08 commit 9ffc52d

File tree

1 file changed

+14
-25
lines changed
  • services/static-webserver/client/source/class/osparc/vipMarket

1 file changed

+14
-25
lines changed

services/static-webserver/client/source/class/osparc/vipMarket/Market.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,26 @@ qx.Class.define("osparc.vipMarket.Market", {
4141
])
4242
.then(values => {
4343
const licensedItems = values[0];
44-
const categories = {};
44+
const categories = [];
4545
licensedItems.forEach(licensedItem => {
4646
if (licensedItem["licensedResourceData"] && licensedItem["licensedResourceData"]["categoryId"]) {
47-
const category = licensedItem["licensedResourceData"]["categoryId"];
48-
if (!(category in categories)) {
49-
categories[category] = [];
47+
const categoryId = licensedItem["licensedResourceData"]["categoryId"];
48+
let category = categories.find(cat => cat["categoryId"] === categoryId);
49+
if (!category) {
50+
category = {
51+
categoryId,
52+
label: licensedItem["licensedResourceData"]["categoryDisplay"] || "Category",
53+
icon: licensedItem["licensedResourceData"]["categoryIcon"] || "@FontAwesome5Solid/users/20",
54+
items: [],
55+
};
56+
categories.push(category);
5057
}
51-
categories[category].push(licensedItem);
58+
category["items"].push(licensedItem);
5259
}
5360
});
5461

55-
const expectedCategories = [{
56-
categoryId: "HumanWholeBody",
57-
label: "Humans",
58-
icon: "@FontAwesome5Solid/users/20",
59-
}, {
60-
categoryId: "HumanBodyRegion",
61-
label: "Humans (Region)",
62-
icon: "@FontAwesome5Solid/users/20",
63-
}, {
64-
categoryId: "AnimalWholeBody",
65-
label: "Animals",
66-
icon: "@FontAwesome5Solid/users/20",
67-
}, {
68-
categoryId: "ComputationalPhantom",
69-
label: "Phantoms",
70-
icon: "@FontAwesome5Solid/users/20",
71-
}]
72-
expectedCategories.forEach(expectedCategory => {
73-
const items = categories[expectedCategory["categoryId"]];
74-
this.__buildViPMarketPage(expectedCategory, items);
62+
categories.forEach(category => {
63+
this.__buildViPMarketPage(category, category["items"]);
7564
});
7665

7766
if (openCategory) {

0 commit comments

Comments
 (0)