Skip to content

Commit 969fb4f

Browse files
committed
robot is right
1 parent 5fefda0 commit 969fb4f

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ qx.Class.define("osparc.data.model.Function", {
4141
lastChangeDate: functionData.lastChangeDate ? new Date(functionData.lastChangeDate) : this.getLastChangeDate(),
4242
thumbnail: functionData.thumbnail || this.getThumbnail(),
4343
workbenchData: functionData.workbench || this.getWorkbenchData(),
44-
functionUIData: functionData.ui || this.functionUIData(),
44+
functionUIData: functionData.ui || this.getFunctionUIData(),
4545
});
4646
},
4747

@@ -148,5 +148,33 @@ qx.Class.define("osparc.data.model.Function", {
148148
}
149149
return canWrite;
150150
},
151+
},
152+
153+
members: {
154+
serialize: function(clean = true) {
155+
let jsonObject = {};
156+
const propertyKeys = this.self().getProperties();
157+
propertyKeys.forEach(key => {
158+
jsonObject[key] = this.get(key);
159+
});
160+
return jsonObject;
161+
},
162+
163+
patchFunction: function(functionChanges) {
164+
return osparc.store.Study.getInstance().patchStudy(this.getUuid(), functionChanges)
165+
.then(() => {
166+
Object.keys(functionChanges).forEach(fieldKey => {
167+
const upKey = qx.lang.String.firstUp(fieldKey);
168+
const setter = "set" + upKey;
169+
this[setter](functionChanges[fieldKey]);
170+
})
171+
this.set({
172+
lastChangeDate: new Date()
173+
});
174+
const functionData = this.serialize();
175+
resolve(functionData);
176+
})
177+
.catch(err => reject(err));
178+
},
151179
}
152180
});

services/static-webserver/client/source/class/osparc/info/FunctionLarge.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ qx.Class.define("osparc.info.FunctionLarge", {
168168

169169
__openDescriptionEditor: function() {
170170
const title = this.tr("Edit Description");
171-
const textEditor = new osparc.editor.MarkdownEditor(this.getStudy().getDescription());
171+
const textEditor = new osparc.editor.MarkdownEditor(this.getFunction().getDescription());
172172
textEditor.setMaxHeight(570);
173173
const win = osparc.ui.window.Window.popUpInWindow(textEditor, title, 400, 300);
174174
textEditor.addListener("textChanged", e => {
@@ -182,11 +182,10 @@ qx.Class.define("osparc.info.FunctionLarge", {
182182
},
183183

184184
__patchFunction: function(fieldKey, value) {
185-
this.getStudy().patchStudy({[fieldKey]: value})
186-
.then(studyData => {
187-
studyData["resourceType"] = this.getStudy().getTemplateType() ? "template" : "study";
188-
this.fireDataEvent("updateStudy", studyData);
189-
qx.event.message.Bus.getInstance().dispatchByName("updateStudy", studyData);
185+
this.getFunction().patchFunction({[fieldKey]: value})
186+
.then(functionData => {
187+
this.fireDataEvent("updateFunction", functionData);
188+
qx.event.message.Bus.getInstance().dispatchByName("updateFunction", functionData);
190189
})
191190
.catch(err => {
192191
const msg = this.tr("An issue occurred while updating the information.");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ qx.Class.define("osparc.store.Functions", {
8484
},
8585

8686
registerFunction: function(templateData, name, description, defaultInputs, exposedInputs, exposedOutputs) {
87-
const functionData = this.self().__createFunctionData(templateData, name, description, defaultInputs, exposedInputs, exposedOutputs);
87+
const functionData = this.__createFunctionData(templateData, name, description, defaultInputs, exposedInputs, exposedOutputs);
8888
const params = {
8989
data: functionData,
9090
};
@@ -122,7 +122,7 @@ qx.Class.define("osparc.store.Functions", {
122122
"functionId": functionId
123123
}
124124
};
125-
return osparc.data.Resources.fetch("functions", "getOne", params, options)
125+
return osparc.data.Resources.fetch("functions", "getOne", params)
126126
.then(func => {
127127
func["resourceType"] = "function";
128128
return func;

0 commit comments

Comments
 (0)