Skip to content

Commit db0030e

Browse files
authored
Fix: update metadata from Study Editor (#1766)
* Confirmation window for deleting node * Study details canbe edited from the study
1 parent 6901d09 commit db0030e

File tree

7 files changed

+69
-49
lines changed

7 files changed

+69
-49
lines changed

services/web/client/source/class/osparc/Application.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ qx.Class.define("osparc.Application", {
135135
if (osparc.utils.Utils.isInZ43()) {
136136
document.title += " Z43";
137137
}
138-
document.title += ` (${platformName})`;
138+
if (platformName) {
139+
document.title += ` (${platformName})`;
140+
}
139141
});
140142
},
141143

services/web/client/source/class/osparc/component/metadata/StudyDetailsEditor.js

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
3434
this.base(arguments);
3535
this._setLayout(new qx.ui.layout.Grow());
3636

37-
this.__studyModel = qx.data.marshal.Json.createModel(studyData);
38-
this.__selectedTags = studyData.tags;
39-
this.__workbench = studyData.workbench;
37+
this.__studyData = osparc.data.model.Study.deepCloneStudyObject(studyData);
4038

4139
this.__stack = new qx.ui.container.Stack();
4240
this.__displayView = this.__createDisplayView(studyData, isTemplate, winWidth);
@@ -66,10 +64,7 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
6664
__stack: null,
6765
__fields: null,
6866
__openButton: null,
69-
__study: null,
70-
__studyModel: null,
71-
__workbench: null,
72-
__selectedTags: null,
67+
__studyData: null,
7368

7469
showOpenButton: function(show) {
7570
this.__openButton.setVisibility(show ? "visible" : "excluded");
@@ -118,14 +113,14 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
118113
const editView = new qx.ui.container.Composite(new qx.ui.layout.VBox(8));
119114

120115
this.__fields = {
121-
name: new qx.ui.form.TextField(this.__studyModel.getName()).set({
116+
name: new qx.ui.form.TextField(this.__studyData.name).set({
122117
font: "title-16",
123118
enabled: fieldIsEnabled
124119
}),
125-
description: new qx.ui.form.TextArea(this.__studyModel.getDescription()).set({
120+
description: new qx.ui.form.TextArea(this.__studyData.description).set({
126121
enabled: fieldIsEnabled
127122
}),
128-
thumbnail: new qx.ui.form.TextField(this.__studyModel.getThumbnail()).set({
123+
thumbnail: new qx.ui.form.TextField(this.__studyData.thumbnail).set({
129124
enabled: fieldIsEnabled
130125
})
131126
};
@@ -198,13 +193,13 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
198193
appearance: "link-button"
199194
});
200195
editButton.addListener("execute", () => {
201-
const tagManager = new osparc.component.form.tag.TagManager(this.__selectedTags, editButton, "study", this.__studyModel.getUuid());
196+
const tagManager = new osparc.component.form.tag.TagManager(this.__studyData.tags, editButton, "study", this.__studyData.uuid);
202197
tagManager.addListener("changeSelected", evt => {
203-
this.__selectedTags = evt.getData().selected;
198+
this.__studyData.tags = evt.getData().selected;
204199
}, this);
205200
tagManager.addListener("close", () => {
206201
this.__renderTags();
207-
this.fireDataEvent("updateTags", this.__studyModel.getUuid());
202+
this.fireDataEvent("updateTags", this.__studyData.uuid);
208203
}, this);
209204
});
210205
header.add(editButton);
@@ -224,7 +219,7 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
224219
this.__tagsContainer = this.__tagsContainer || new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
225220
this.__tagsContainer.removeAll();
226221
this.__tagsContainer.setMarginTop(5);
227-
osparc.store.Store.getInstance().getTags().filter(tag => this.__selectedTags.includes(tag.id))
222+
osparc.store.Store.getInstance().getTags().filter(tag => this.__studyData.tags.includes(tag.id))
228223
.forEach(selectedTag => {
229224
this.__tagsContainer.add(new osparc.ui.basic.Tag(selectedTag.name, selectedTag.color));
230225
});
@@ -233,12 +228,9 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
233228

234229
__saveStudy: function(isTemplate, btn) {
235230
const data = this.__serializeForm();
236-
// FIXME: Avoid adding invalid properties to standard entities.
237-
delete data.locked;
238-
delete data.resourceType;
239231
const params = {
240232
url: {
241-
projectId: this.__studyModel.getUuid()
233+
projectId: this.__studyData.uuid
242234
},
243235
data
244236
};
@@ -247,9 +239,8 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
247239
btn.resetIcon();
248240
btn.getChildControl("icon").getContentElement()
249241
.removeClass("rotate");
250-
this.__studyModel.set(studyData);
251242
this.setMode("display");
252-
this.fireDataEvent(isTemplate ? "updateTemplate" : "updateStudy", studyData.uuid);
243+
this.fireDataEvent(isTemplate ? "updateTemplate" : "updateStudy", studyData);
253244
})
254245
.catch(err => {
255246
btn.resetIcon();
@@ -261,11 +252,7 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
261252
},
262253

263254
__serializeForm: function() {
264-
let data = {};
265-
data = {
266-
...qx.util.Serializer.toNativeObject(this.__studyModel),
267-
workbench: this.__workbench
268-
};
255+
const data = this.__studyData;
269256

270257
for (let key in this.__fields) {
271258
data[key] = this.__fields[key].getValue();
@@ -279,11 +266,10 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
279266
const dirty = data[fieldKey];
280267
const clean = osparc.wrapper.DOMPurify.getInstance().sanitize(dirty);
281268
if (dirty && dirty !== clean) {
282-
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("There was an issue in the text of ") + fieldKey, "ERROR");
269+
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("There was some curation in the text of ") + fieldKey, "WARNING");
283270
}
284271
data[fieldKey] = clean;
285272
}, this);
286-
data.tags = this.__selectedTags;
287273
return data;
288274
},
289275

@@ -299,8 +285,8 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
299285
},
300286

301287
__isUserOwner: function() {
302-
if (this.__studyModel) {
303-
return this.__studyModel.getPrjOwner() === osparc.auth.Data.getInstance().getEmail();
288+
if (this.__studyData) {
289+
return this.__studyData.prjOwner === osparc.auth.Data.getInstance().getEmail();
304290
}
305291
return false;
306292
}

services/web/client/source/class/osparc/component/metadata/StudyInfo.js

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ qx.Class.define("osparc.component.metadata.StudyInfo", {
2424
extend: qx.ui.core.Widget,
2525

2626
/**
27-
* @param study {Object|osparc.data.model.Study} Study (metadata)
27+
* @param study {osparc.data.model.Study} Study model
2828
*/
2929
construct: function(study) {
3030
this.base(arguments);
@@ -35,15 +35,20 @@ qx.Class.define("osparc.component.metadata.StudyInfo", {
3535
});
3636
this._setLayout(new qx.ui.layout.VBox(8));
3737

38-
this.__study = study;
39-
4038
this._add(this.__getMoreInfoMenuButton());
41-
const windowWidth = 400;
42-
this._add(new osparc.component.metadata.StudyDetails(study, windowWidth));
39+
this.setStudy(study);
40+
},
41+
42+
properties: {
43+
study: {
44+
check: "osparc.data.model.Study",
45+
apply: "_applyStudy",
46+
nullable: false
47+
}
4348
},
4449

4550
members: {
46-
__study: null,
51+
__studyDetails: null,
4752

4853
__getMoreInfoMenuButton: function() {
4954
const moreInfoButton = new qx.ui.form.Button(this.tr("More Info")).set({
@@ -57,19 +62,33 @@ qx.Class.define("osparc.component.metadata.StudyInfo", {
5762
return moreInfoButton;
5863
},
5964

65+
_applyStudy: function(newStudy) {
66+
if (this.__studyDetails) {
67+
this._remove(this.__studyDetails);
68+
}
69+
70+
const windowWidth = 400;
71+
const studyDetails = this.__studyDetails = new osparc.component.metadata.StudyDetails(newStudy, windowWidth);
72+
this._add(studyDetails);
73+
},
74+
6075
__createStudyDetailsEditor: function() {
6176
const width = 500;
6277
const height = 500;
6378
const title = this.tr("Study Details Editor");
64-
const studyDetails = new osparc.component.metadata.StudyDetailsEditor(this.__study.serializeStudy(), false, width);
65-
studyDetails.showOpenButton(false);
66-
const win = osparc.ui.window.Window.popUpInWindow(studyDetails, title, width, height);
67-
[
68-
"updateStudy"
69-
].forEach(event => studyDetails.addListener(event, () => {
70-
qx.event.message.Bus.getInstance().dispatchByName("updateStudy", this.__study.serializeStudy());
79+
const studyDetailsEditor = new osparc.component.metadata.StudyDetailsEditor(this.getStudy().serializeStudy(), false, width);
80+
studyDetailsEditor.showOpenButton(false);
81+
const win = osparc.ui.window.Window.popUpInWindow(studyDetailsEditor, title, width, height);
82+
studyDetailsEditor.addListener("updateStudy", e => {
83+
const newStudyData = e.getData();
84+
this.getStudy().set({
85+
name: newStudyData.name,
86+
description: newStudyData.description,
87+
thumbnail: newStudyData.thumbnail
88+
});
89+
qx.event.message.Bus.getInstance().dispatchByName("updateStudy", newStudyData.uuid);
7190
win.close();
72-
}));
91+
});
7392
}
7493
}
7594
});

services/web/client/source/class/osparc/component/widget/NodesTree.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,15 @@ qx.Class.define("osparc.component.widget.NodesTree", {
131131
enabled: false
132132
});
133133
deleteButton.addListener("execute", e => {
134-
this.__deleteNode();
134+
const msg = this.tr("Are you sure you want to delete node?");
135+
const win = new osparc.ui.window.Confirmation(msg);
136+
win.center();
137+
win.open();
138+
win.addListener("close", () => {
139+
if (win.getConfirmed()) {
140+
this.__deleteNode();
141+
}
142+
});
135143
}, this);
136144
osparc.utils.Utils.setIdToWidget(deleteButton, "deleteServiceBtn");
137145
toolbar.add(deleteButton);

services/web/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
563563
__createStudyDetailsEditor: function(studyData, winWidth) {
564564
const studyDetails = new osparc.component.metadata.StudyDetailsEditor(studyData, false, winWidth);
565565
studyDetails.addListener("updateStudy", e => {
566-
const studyId = e.getData();
567-
this.__reloadUserStudy(studyId, true);
566+
const newStudyData = e.getData();
567+
this.__reloadUserStudy(newStudyData.uuid, true);
568568
});
569569
studyDetails.addListener("openStudy", () => {
570570
this.__startStudy(studyData["uuid"]);

services/web/client/source/class/osparc/data/model/Study.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,16 @@ qx.Class.define("osparc.data.model.Study", {
251251
...params
252252
})
253253
.then(data => {
254+
// TODO OM: Hacky
255+
if ("dev" in data) {
256+
delete data["dev"];
257+
}
254258
this.set({
255259
...data,
256260
creationDate: new Date(data.creationDate),
257261
lastChangeDate: new Date(data.lastChangeDate),
258-
workbench: this.getWorkbench()
262+
workbench: this.getWorkbench(),
263+
sweeper: this.getSweeper()
259264
});
260265
return data;
261266
});

services/web/client/source/class/osparc/ui/message/FlashMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ qx.Class.define("osparc.ui.message.FlashMessage", {
6363
LOG_LEVEL_COLOR_MAP: {
6464
"INFO": "blue",
6565
"DEBUG": "yellow",
66-
"WARING": "orange",
66+
"WARNING": "orange",
6767
"ERROR": "red"
6868
}
6969
},

0 commit comments

Comments
 (0)