Skip to content

Commit 8407d9e

Browse files
committed
DateTimeChooser
1 parent efdf2c7 commit 8407d9e

File tree

3 files changed

+128
-7
lines changed

3 files changed

+128
-7
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,14 @@ qx.Class.define("osparc.data.model.Conversation", {
299299
}
300300
return null;
301301
},
302+
303+
setAppointment: function(appointment) {
304+
const extraContext = this.getExtraContext() || {};
305+
extraContext["appointment"] = appointment ? appointment.toISOString() : null;
306+
return osparc.store.ConversationsSupport.getInstance().patchExtraContext(this.getConversationId(), extraContext)
307+
.then(() => {
308+
this.setExtraContext(extraContext);
309+
});
310+
},
302311
},
303312
});

services/static-webserver/client/source/class/osparc/support/ConversationPage.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ qx.Class.define("osparc.support.ConversationPage", {
233233
},
234234

235235
__openAppointmentDetails: function() {
236-
const dateTimeField = new osparc.ui.form.DateTimeField();
237-
const title = this.tr("Choose a Date and Time");
238-
const win = osparc.ui.window.Window.popUpInWindow(dateTimeField, title, 260, 26).set({
239-
clickAwayClose: false,
240-
resizable: false,
241-
showClose: true
242-
});
236+
const win = new osparc.widget.DateTimeChooser();
237+
win.addListener("dateChanged", e => {
238+
const newValue = e.getData()["newValue"];
239+
this.getConversation().setAppointment(newValue)
240+
.catch(err => console.error(err));
241+
win.close();
242+
}, this);
243+
win.open();
243244
},
244245

245246
__renameConversation: function() {
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
19+
qx.Class.define("osparc.widget.DateTimeChooser", {
20+
extend: osparc.ui.window.Window,
21+
22+
construct: function(winTitle, value) {
23+
this.base(arguments, winTitle || this.tr("Choose a Date and Time"));
24+
25+
const width = 260;
26+
const height = 26;
27+
this.set({
28+
layout: new qx.ui.layout.VBox(10),
29+
autoDestroy: true,
30+
modal: true,
31+
width,
32+
height,
33+
showMaximize: false,
34+
showMinimize: false,
35+
showClose: true,
36+
resizable: false,
37+
clickAwayClose: false,
38+
});
39+
40+
const dateTimeField = this.getChildControl("date-time-field");
41+
if (value) {
42+
dateTimeField.setValue(value);
43+
}
44+
this.getChildControl("cancel-button");
45+
this.getChildControl("save-button");
46+
47+
this.center();
48+
49+
this.__attachEventHandlers();
50+
},
51+
52+
events: {
53+
"dateChanged": "qx.event.type.Data",
54+
},
55+
56+
members: {
57+
_createChildControlImpl: function(id) {
58+
let control;
59+
switch (id) {
60+
case "date-time-field":
61+
control = new osparc.ui.form.DateTimeField();
62+
this.add(control);
63+
break;
64+
case "buttons-layout":
65+
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5).set({
66+
alignX: "right"
67+
}));
68+
this.add(control);
69+
break;
70+
case "cancel-button":
71+
control = new qx.ui.form.Button(this.tr("Cancel")).set({
72+
appearance: "form-button-text",
73+
});
74+
control.addListener("execute", () => this.close(), this);
75+
this.getChildControl("buttons-layout").add(control);
76+
break;
77+
case "save-button": {
78+
control = new qx.ui.form.Button(this.tr("Save")).set({
79+
appearance: "form-button",
80+
});
81+
control.addListener("execute", e => {
82+
const dateTimeField = this.getChildControl("date-time-field");
83+
const data = {
84+
newValue: dateTimeField.getValue()
85+
};
86+
this.fireDataEvent("dateChanged", data);
87+
}, this);
88+
this.getChildControl("buttons-layout").add(control);
89+
break;
90+
}
91+
}
92+
return control || this.base(arguments, id);
93+
},
94+
95+
__attachEventHandlers: function() {
96+
let command = new qx.ui.command.Command("Enter");
97+
command.addListener("execute", () => {
98+
this.getChildControl("save-button").execute();
99+
command.dispose();
100+
command = null;
101+
});
102+
103+
let commandEsc = new qx.ui.command.Command("Esc");
104+
commandEsc.addListener("execute", () => {
105+
this.close();
106+
commandEsc.dispose();
107+
commandEsc = null;
108+
});
109+
}
110+
}
111+
});

0 commit comments

Comments
 (0)