Skip to content

Commit b8e5989

Browse files
committed
no magic strings
1 parent 3f2f3f1 commit b8e5989

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

services/static-webserver/client/source/class/osparc/dashboard/CardBase.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
597597
break;
598598
}
599599
case "function":
600-
this.setIcon(osparc.data.model.StudyUI.PIPELINE_ICON);
600+
if (resourceData["functionClass"] === osparc.data.model.Function.FUNCTION_CLASS.PROJECT) {
601+
this.setIcon(osparc.data.model.StudyUI.PIPELINE_ICON);
602+
} else {
603+
this.setIcon(osparc.dashboard.CardBase.PRODUCT_ICON);
604+
}
601605
break;
602606
}
603607
},

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
8181
this.__resourceModel["resourceType"] = resourceData["resourceType"];
8282
this.__addPages();
8383
}
84-
if (resourceData["functionClass"] === "PROJECT") {
84+
if (resourceData["functionClass"] === osparc.data.model.Function.FUNCTION_CLASS.PROJECT) {
8585
// this is only required for functions that have a template linked
8686
osparc.store.Templates.fetchTemplate(resourceData["templateId"])
8787
.then(templateData => {
@@ -408,7 +408,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
408408
return;
409409
} else if (osparc.utils.Resources.isFunction(this.__resourceData)) {
410410
this.__addInfoPage();
411-
if (this.__resourceModel.getFunctionClass() === "PROJECT") {
411+
if (this.__resourceModel.getFunctionClass() === osparc.data.model.Function.FUNCTION_CLASS.PROJECT) {
412412
this.__addPreviewPage();
413413
}
414414
this.fireEvent("pagesAdded");

services/static-webserver/client/source/class/osparc/data/model/Function.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ qx.Class.define("osparc.data.model.Function", {
5959
},
6060

6161
functionClass: {
62-
check: ["PROJECT", "SOLVER", "PYTHON_CODE"],
62+
check: [
63+
"PROJECT", // osparc.data.model.Function.FUNCTION_CLASS.PROJECT
64+
"SOLVER", // osparc.data.model.Function.FUNCTION_CLASS.SOLVER
65+
"PYTHON_CODE", // osparc.data.model.Function.FUNCTION_CLASS.PYTHON
66+
],
6367
nullable: false,
6468
event: "changeFunctionClass",
6569
init: null
@@ -142,9 +146,15 @@ qx.Class.define("osparc.data.model.Function", {
142146
},
143147

144148
statics: {
149+
FUNCTION_CLASS: {
150+
PROJECT: "PROJECT",
151+
SOLVER: "SOLVER",
152+
PYTHON_CODE: "PYTHON_CODE"
153+
},
154+
145155
getProperties: function() {
146156
return Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.Function));
147-
}
157+
},
148158
},
149159

150160
members: {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ qx.Class.define("osparc.store.Functions", {
2727
"projectId": templateData["uuid"],
2828
"title": name,
2929
"description": description,
30-
"function_class": "PROJECT",
30+
"function_class": osparc.data.model.Function.FUNCTION_CLASS.PROJECT,
3131
"inputSchema": {
3232
"schema_class": "application/schema+json",
3333
"schema_content": {

0 commit comments

Comments
 (0)