Skip to content

Commit 16fab64

Browse files
committed
Merge branch 'feature/daraga-doropa' of github.com:odeimaiz/osparc-simcore into enh/dragging-indicator
2 parents 3425d21 + 1f8f1b9 commit 16fab64

File tree

10 files changed

+121
-49
lines changed

10 files changed

+121
-49
lines changed

services/static-webserver/client/source/class/osparc/auth/ui/LoginView.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ qx.Class.define("osparc.auth.ui.LoginView", {
140140
`;
141141
}
142142
const disclaimer = osparc.announcement.AnnouncementUIFactory.createLoginAnnouncement(this.tr("Disclaimer"), text);
143+
disclaimer.getChildren()[0].setFont("text-14"); // title
144+
disclaimer.getChildren()[1].setFont("text-12"); // description
143145
this.add(disclaimer);
144146

145147
this.add(new qx.ui.core.Spacer(), {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ qx.Class.define("osparc.dashboard.CardBase", {
470470

471471
__evalSelectedButton: function() {
472472
if (
473-
this.isResourceType("study") ||
474-
this.isResourceType("template") ||
475-
this.isResourceType("service")
473+
this.hasChildControl("menu-button") &&
474+
this.hasChildControl("tick-selected") &&
475+
this.hasChildControl("tick-unselected")
476476
) {
477477
const menuButton = this.getChildControl("menu-button");
478478
const tick = this.getChildControl("tick-selected");
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2024 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+
qx.Class.define("osparc.dashboard.DragWidget", {
19+
extend: qx.ui.basic.Atom,
20+
21+
construct: function() {
22+
this.base(arguments);
23+
24+
this.set({
25+
opacity: 0.9,
26+
padding: 10,
27+
zIndex: 1000,
28+
font: "text-14",
29+
backgroundColor: "strong-main",
30+
decorator: "rounded",
31+
visibility: "excluded",
32+
});
33+
34+
const root = qx.core.Init.getApplication().getRoot();
35+
root.add(this);
36+
},
37+
38+
members: {
39+
__onMouseMoveDragging: function(e) {
40+
const domEl = this.getContentElement().getDomElement();
41+
domEl.style.left = `${e.pageX + 15}px`; // Offset for better visibility
42+
domEl.style.top = `${e.pageY + 15}px`;
43+
},
44+
45+
start: function() {
46+
this.show();
47+
document.addEventListener("mousemove", this.__onMouseMoveDragging.bind(this), false);
48+
},
49+
50+
end: function() {
51+
this.exclude();
52+
document.removeEventListener("mousemove", this.__onMouseMoveDragging.bind(this), false);
53+
},
54+
}
55+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ qx.Class.define("osparc.dashboard.GridButtonItem", {
236236
const menuButton = this.getChildControl("menu-button");
237237
if (menu) {
238238
menuButton.setMenu(menu);
239-
menu.setPosition("top-left");
239+
menu.setPosition("bottom-left");
240240
osparc.utils.Utils.prettifyMenu(menu);
241241
osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu");
242242
this.evaluateMenuButtons();

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,16 @@ qx.Class.define("osparc.dashboard.ListButtonItem", {
260260
});
261261
},
262262

263-
_applyMenu: function(value, old) {
263+
_applyMenu: function(menu, old) {
264264
const menuButton = this.getChildControl("menu-button");
265-
if (value) {
266-
menuButton.setMenu(value);
267-
osparc.utils.Utils.setIdToWidget(value, "studyItemMenuMenu");
265+
if (menu) {
266+
menuButton.setMenu(menu);
267+
menu.setPosition("bottom-left");
268+
osparc.utils.Utils.prettifyMenu(menu);
269+
osparc.utils.Utils.setIdToWidget(menu, "studyItemMenuMenu");
270+
this.evaluateMenuButtons();
268271
}
269-
menuButton.setVisibility(value ? "visible" : "excluded");
272+
menuButton.setVisibility(menu ? "visible" : "excluded");
270273
}
271274
}
272275
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ qx.Class.define("osparc.dashboard.MoveResourceTo", {
7373
switch (id) {
7474
case "current-location": {
7575
control = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
76-
const intro = new qx.ui.basic.Label(this.tr("Current location"));
76+
const intro = new qx.ui.basic.Label(this.tr("Current location:"));
7777
control.add(intro);
7878
const workspace = osparc.store.Workspaces.getInstance().getWorkspace(this.__currentWorkspaceId);
7979
const workspaceText = workspace ? workspace.getName() : "My Workspace";

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
100100
__foldersList: null,
101101
__loadingFolders: null,
102102
__loadingWorkspaces: null,
103+
__dragIndicator: null,
103104

104105
// overridden
105106
initResources: function() {
@@ -646,6 +647,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
646647
// /FOLDERS
647648

648649
__configureStudyCards: function(cards) {
650+
// Create drag indicator
651+
this.__dragIndicator = new osparc.dashboard.DragWidget();
652+
649653
cards.forEach(card => {
650654
card.setMultiSelectionMode(this.getMultiSelection());
651655
card.addListener("tap", e => this.__studyCardClicked(card, e.getNativeEvent().shiftKey), this);
@@ -664,6 +668,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
664668
e.addData("osparc-moveStudy", {
665669
"studyDataOrigin": card.getResourceData(),
666670
});
671+
672+
// make it semi transparent while being dragged
673+
card.setOpacity(0.2);
674+
// init drag indicator
675+
this.__dragIndicator.set({
676+
label: card.getTitle(),
677+
});
678+
this.__dragIndicator.start();
679+
});
680+
681+
card.addListener("dragend", () => {
682+
// bring back opacity after drag
683+
card.setOpacity(1);
684+
// hide drag indicator
685+
this.__dragIndicator.end();
667686
});
668687

669688
// Create drag indicator

services/static-webserver/client/source/class/osparc/service/ServiceList.js

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ qx.Class.define("osparc.service.ServiceList", {
3636
},
3737

3838
events: {
39-
"changeValue": "qx.event.type.Data",
39+
"changeSelected": "qx.event.type.Data",
4040
"serviceAdd": "qx.event.type.Data"
4141
},
4242

@@ -53,33 +53,26 @@ qx.Class.define("osparc.service.ServiceList", {
5353
},
5454

5555
members: {
56-
__buttonGroup: null,
5756
__filterGroup: null,
5857

5958
_applyModel: function(model) {
6059
this._removeAll();
61-
const group = this.__buttonGroup = new qx.ui.form.RadioGroup().set({
62-
allowEmptySelection: true
63-
});
6460

61+
this.__serviceListItem = [];
6562
model.toArray().forEach(service => {
66-
const button = new osparc.service.ServiceListItem(service);
63+
const item = new osparc.service.ServiceListItem(service);
6764
if (this.__filterGroup !== null) {
68-
button.subscribeToFilterGroup(this.__filterGroup);
65+
item.subscribeToFilterGroup(this.__filterGroup);
6966
}
70-
group.add(button);
71-
this._add(button);
72-
button.addListener("dbltap", () => {
73-
this.fireDataEvent("serviceAdd", button.getService());
74-
}, this);
75-
button.addListener("keypress", e => {
67+
this._add(item);
68+
item.addListener("tap", () => this.__setSelected(item));
69+
item.addListener("dbltap", () => this.fireDataEvent("serviceAdd", item.getService()), this);
70+
item.addListener("keypress", e => {
7671
if (e.getKeyIdentifier() === "Enter") {
77-
this.fireDataEvent("serviceAdd", button.getService());
72+
this.fireDataEvent("serviceAdd", item.getService());
7873
}
7974
}, this);
8075
});
81-
82-
group.addListener("changeValue", e => this.dispatchEvent(e.clone()), this);
8376
},
8477

8578
/**
@@ -88,37 +81,41 @@ qx.Class.define("osparc.service.ServiceList", {
8881
* @return Returns the model of the selected service or null if selection is empty.
8982
*/
9083
getSelected: function() {
91-
if (this.__buttonGroup && this.__buttonGroup.getSelection().length) {
92-
return this.__buttonGroup.getSelection()[0].getService();
84+
const items = this._getChildren();
85+
for (let i=0; i<items.length; i++) {
86+
const item = items[i];
87+
if (item.isVisible() && item.getSelected()) {
88+
return item.getService();
89+
}
9390
}
9491
return null;
9592
},
9693

94+
__setSelected: function(selectedItem) {
95+
this._getChildren().forEach(item => item.setSelected(item === selectedItem));
96+
this.fireDataEvent("changeSelected", selectedItem);
97+
},
98+
9799
/**
98100
* Function checking if the selection is empty or not
99101
*
100102
* @return True if no item is selected, false if there one or more item selected.
101103
*/
102104
isSelectionEmpty: function() {
103-
if (this.__buttonGroup == null) {
104-
return true;
105-
}
106-
return this.__buttonGroup.getSelection().length === 0;
105+
const selecetedItems = this._getChildren().filter(item => item.getSelected());
106+
selecetedItems.length === 0;
107107
},
108108

109109
/**
110110
* Function that selects the first visible button.
111111
*/
112112
selectFirstVisible: function() {
113-
if (this._hasChildren()) {
114-
const buttons = this._getChildren();
115-
let current = buttons[0];
116-
let i = 1;
117-
while (i<buttons.length && !current.isVisible()) {
118-
current = buttons[i++];
119-
}
120-
if (current.isVisible()) {
121-
this.__buttonGroup.setSelection([this._getChildren()[i-1]]);
113+
const items = this._getChildren();
114+
for (let i=0; i<items.length; i++) {
115+
const item = items[i];
116+
if (item.isVisible()) {
117+
this.__setSelected(item);
118+
return;
122119
}
123120
}
124121
}

services/static-webserver/client/source/class/osparc/service/ServiceListItem.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ qx.Class.define("osparc.service.ServiceListItem", {
3636

3737
this.subscribeToFilterGroup("serviceCatalog");
3838

39-
/**
40-
* The idea here is to show some extra options when a service is selected:
41-
* - Version selection
42-
* - Pricing unit selection if applies
43-
*/
44-
// But the toggle button consumes all the events, I believe that the trick is to use the anonymous property
45-
// this.addListener("changeValue", e => this.__itemSelected(e.getData()));
39+
this.bind("selected", this, "backgroundColor", {
40+
converter: selected => selected ? "strong-main" : "info"
41+
});
4642
},
4743

4844
properties: {

services/static-webserver/client/source/class/osparc/workbench/ServiceCatalog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ qx.Class.define("osparc.workbench.ServiceCatalog", {
136136
});
137137
scrolledServices.add(serviceList);
138138

139-
this.__serviceList.addListener("changeValue", e => {
139+
this.__serviceList.addListener("changeSelected", e => {
140140
if (e.getData() && e.getData().getService()) {
141141
const selectedService = e.getData().getService();
142142
this.__changedSelection(selectedService.getKey());

0 commit comments

Comments
 (0)