Skip to content

Commit 13dcb39

Browse files
authored
🎨 [Frontend] Enh: Empty trash workflow (#7253)
1 parent f7c8b53 commit 13dcb39

File tree

3 files changed

+56
-34
lines changed

3 files changed

+56
-34
lines changed

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
10661066
this._createSearchBar();
10671067

10681068
const header = this.__header = new osparc.dashboard.StudyBrowserHeader();
1069-
this.__header.addListener("emptyTrashRequested", () => this.__emptyTrash(), this);
1069+
this.__header.addListener("trashEmptied", () => this.reloadResources(), this);
10701070
this._addToLayout(header);
10711071

10721072
this._createResourcesLayout("studiesList");
@@ -1444,19 +1444,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
14441444
return deleteButton;
14451445
},
14461446

1447-
__emptyTrash: function() {
1448-
const win = this.__createConfirmEmptyTrashWindow();
1449-
win.center();
1450-
win.open();
1451-
win.addListener("close", () => {
1452-
if (win.getConfirmed()) {
1453-
osparc.data.Resources.fetch("trash", "delete")
1454-
.then(() => {
1455-
this.__resetStudiesList();
1456-
});
1457-
}
1458-
}, this);
1459-
},
1447+
14601448

14611449
__createSelectButton: function() {
14621450
const selectButton = new qx.ui.form.ToggleButton().set({
@@ -2241,16 +2229,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
22412229
return confirmationWin;
22422230
},
22432231

2244-
__createConfirmEmptyTrashWindow: function() {
2245-
const msg = this.tr("All items will be permanently deleted");
2246-
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({
2247-
caption: this.tr("Delete"),
2248-
confirmText: this.tr("Delete permanently"),
2249-
confirmAction: "delete"
2250-
});
2251-
return confirmationWin;
2252-
},
2253-
22542232
// TASKS //
22552233
__tasksReceived: function(tasks) {
22562234
tasks.forEach(taskData => this._taskDataReceived(taskData));

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", {
4545
"locationChanged": "qx.event.type.Data",
4646
"workspaceUpdated": "qx.event.type.Data",
4747
"deleteWorkspaceRequested": "qx.event.type.Data",
48-
"emptyTrashRequested": "qx.event.type.Event",
48+
"trashEmptied": "qx.event.type.Event",
4949
},
5050

5151
properties: {
@@ -193,12 +193,28 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", {
193193
break;
194194
}
195195
case "empty-trash-button": {
196-
control = new qx.ui.form.Button(this.tr("Delete all"), "@FontAwesome5Solid/trash/14").set({
196+
control = new osparc.ui.form.FetchButton(this.tr("Delete all"), "@FontAwesome5Solid/trash/14").set({
197197
appearance: "danger-button",
198198
allowGrowY: false,
199199
alignY: "middle",
200200
});
201-
control.addListener("execute", () => this.fireEvent("emptyTrashRequested"));
201+
control.addListener("execute", () => {
202+
const win = this.__createConfirmEmptyTrashWindow();
203+
win.center();
204+
win.open();
205+
win.addListener("close", () => {
206+
control.setFetching(true);
207+
if (win.getConfirmed()) {
208+
osparc.data.Resources.fetch("trash", "delete")
209+
.then(() => {
210+
this.fireEvent("trashEmptied")
211+
})
212+
.finally(() => control.setFetching(false));
213+
} else {
214+
control.setFetching(false)
215+
}
216+
}, this);
217+
});
202218
this._addAt(control, this.self().POS.EMPTY_TRASH_BUTTON);
203219
break;
204220
}
@@ -207,6 +223,16 @@ qx.Class.define("osparc.dashboard.StudyBrowserHeader", {
207223
return control || this.base(arguments, id);
208224
},
209225

226+
__createConfirmEmptyTrashWindow: function() {
227+
const msg = this.tr("All items will be permanently deleted");
228+
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({
229+
caption: this.tr("Delete"),
230+
confirmText: this.tr("Delete permanently"),
231+
confirmAction: "delete"
232+
});
233+
return confirmationWin;
234+
},
235+
210236
__titleTapped: function() {
211237
const workspaceId = this.getCurrentWorkspaceId();
212238
const folderId = null;

services/static-webserver/client/source/class/osparc/ui/basic/Thumbnail.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ qx.Class.define("osparc.ui.basic.Thumbnail", {
7272
allowStretchX: true,
7373
allowStretchY: true,
7474
alignX: "center",
75-
alignY: "middle"
75+
alignY: "middle",
7676
});
7777
this.addCenteredWidget(control);
7878
break;
@@ -96,37 +96,55 @@ qx.Class.define("osparc.ui.basic.Thumbnail", {
9696
if (srcWidth && srcHeight) {
9797
const aspectRatio = srcWidth/srcHeight;
9898
if (this.getBounds() && this.getBounds().width < image.getMaxWidth()) {
99-
image.setMaxWidth(this.getBounds().width);
99+
image.set({
100+
minWidth: parseInt(this.getBounds().width),
101+
maxWidth: parseInt(this.getBounds().width),
102+
});
100103
}
101104
if (this.getBounds() && this.getBounds().height < image.getMaxHeight()) {
102-
image.setMaxHeight(this.getBounds().height);
105+
image.set({
106+
minHeight: parseInt(this.getBounds().height),
107+
maxHeight: parseInt(this.getBounds().height),
108+
});
103109
}
104110
const maxWidth = image.getMaxWidth();
105111
const maxHeight = image.getMaxHeight();
106112

107113
if (maxWidth && maxHeight) {
108114
const newMaxHeight = maxWidth/aspectRatio;
109115
if (newMaxHeight < maxHeight) {
110-
image.setMaxHeight(parseInt(newMaxHeight));
116+
image.set({
117+
minHeight: parseInt(newMaxHeight),
118+
maxHeight: parseInt(newMaxHeight),
119+
});
111120
return;
112121
}
113122
const newMaxWidth = maxHeight*aspectRatio;
114123
if (newMaxWidth < maxWidth) {
115-
image.setMaxWidth(parseInt(newMaxWidth));
124+
image.set({
125+
minWidth: parseInt(newMaxWidth),
126+
maxWidth: parseInt(newMaxWidth),
127+
});
116128
return;
117129
}
118130
return;
119131
}
120132

121133
if (maxWidth) {
122134
const newMaxHeight = maxWidth/aspectRatio;
123-
image.setMaxHeight(parseInt(newMaxHeight));
135+
image.set({
136+
minHeight: parseInt(newMaxHeight),
137+
maxHeight: parseInt(newMaxHeight),
138+
});
124139
return;
125140
}
126141

127142
if (maxHeight) {
128143
const newMaxWidth = maxHeight*aspectRatio;
129-
image.setMaxWidth(parseInt(newMaxWidth));
144+
image.set({
145+
minWidth: parseInt(newMaxWidth),
146+
maxWidth: parseInt(newMaxWidth),
147+
});
130148
return;
131149
}
132150
}

0 commit comments

Comments
 (0)