Skip to content

Commit f983526

Browse files
committed
trashing
1 parent f3b25e3 commit f983526

File tree

1 file changed

+56
-6
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+56
-6
lines changed

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

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
11391139
const selection = this._resourcesContainer.getSelection();
11401140
const preferencesSettings = osparc.Preferences.getInstance();
11411141
if (preferencesSettings.getConfirmDeleteStudy()) {
1142-
const win = this.__createConfirmWindow(selection.map(button => button.getTitle()));
1142+
const win = this.__createConfirmDeleteWindow(selection.map(button => button.getTitle()));
11431143
win.center();
11441144
win.open();
11451145
win.addListener("close", () => {
@@ -1534,13 +1534,33 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
15341534
},
15351535

15361536
_deleteResourceRequested: function(studyId) {
1537-
this.__deleteStudyRequested(this.__getStudyData(studyId));
1537+
if (this.getCurrentContext() === "trash") {
1538+
this.__deleteStudyRequested(this.__getStudyData(studyId));
1539+
} else {
1540+
this.__trashStudyRequested(this.__getStudyData(studyId));
1541+
}
1542+
},
1543+
1544+
__trashStudyRequested: function(studyData) {
1545+
const preferencesSettings = osparc.Preferences.getInstance();
1546+
if (preferencesSettings.getConfirmDeleteStudy()) {
1547+
const win = this.__createConfirmTrashWindow([studyData.name]);
1548+
win.center();
1549+
win.open();
1550+
win.addListener("close", () => {
1551+
if (win.getConfirmed()) {
1552+
this.__trashStudy(studyData);
1553+
}
1554+
}, this);
1555+
} else {
1556+
this.__trashStudy(studyData);
1557+
}
15381558
},
15391559

15401560
__deleteStudyRequested: function(studyData) {
15411561
const preferencesSettings = osparc.Preferences.getInstance();
15421562
if (preferencesSettings.getConfirmDeleteStudy()) {
1543-
const win = this.__createConfirmWindow([studyData.name]);
1563+
const win = this.__createConfirmDeleteWindow([studyData.name]);
15441564
win.center();
15451565
win.open();
15461566
win.addListener("close", () => {
@@ -1553,6 +1573,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
15531573
}
15541574
},
15551575

1576+
__getTrashStudyMenuButton: function(studyData) {
1577+
const trashButton = new qx.ui.menu.Button(this.tr("Trash"), "@FontAwesome5Solid/trash/12");
1578+
trashButton["deleteButton"] = true;
1579+
trashButton.set({
1580+
appearance: "menu-button"
1581+
});
1582+
osparc.utils.Utils.setIdToWidget(trashButton, "studyItemMenuDelete");
1583+
trashButton.addListener("execute", () => this.__trashStudyRequested(studyData), this);
1584+
return trashButton;
1585+
},
1586+
15561587
__getDeleteStudyMenuButton: function(studyData) {
15571588
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
15581589
deleteButton["deleteButton"] = true;
@@ -1771,11 +1802,30 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
17711802
studiesData.forEach(studyData => this.__doDeleteStudy(studyData));
17721803
},
17731804

1774-
__createConfirmWindow: function(studyNames) {
1775-
const rUSure = this.tr("Are you sure you want to delete");
1805+
__deleteConfirmationWindow: function(msg, studyNames) {
17761806
const studiesText = osparc.product.Utils.getStudyAlias({plural: true});
1777-
const msg = rUSure + (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText} ?` : ` <b>${studyNames[0]}</b>?`)
1807+
msg += (studyNames.length > 1 ? ` ${studyNames.length} ${studiesText} ?` : ` <b>${studyNames[0]}</b>?`);
17781808
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({
1809+
confirmText: this.tr("Trash"),
1810+
confirmAction: "delete"
1811+
});
1812+
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn");
1813+
return confirmationWin;
1814+
},
1815+
1816+
__createConfirmTrashWindow: function(studyNames) {
1817+
const rUSure = this.tr("Are you sure you want to move to the trash");
1818+
const confirmationWin = this.__deleteConfirmationWindow(rUSure, studyNames).set({
1819+
confirmText: this.tr("Trash"),
1820+
confirmAction: "delete"
1821+
});
1822+
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteStudyBtn");
1823+
return confirmationWin;
1824+
},
1825+
1826+
__createConfirmDeleteWindow: function(studyNames) {
1827+
const rUSure = this.tr("Are you sure you want to delete");
1828+
const confirmationWin = this.__deleteConfirmationWindow(rUSure, studyNames).set({
17791829
confirmText: this.tr("Delete"),
17801830
confirmAction: "delete"
17811831
});

0 commit comments

Comments
 (0)