Skip to content

Commit 565ad8e

Browse files
committed
empty trash workflow
1 parent 29b312f commit 565ad8e

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
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;

0 commit comments

Comments
 (0)