Skip to content

Commit

Permalink
[skip ci] trashedBy in folder
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz committed Jan 17, 2025
1 parent 606cecf commit b5baa85
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
nullable: true,
apply: "__applyTrashedAt"
},

trashedBy: {
check: "Number",
nullable: true,
apply: "__applyTrashedBy"
},
},

members: {
Expand All @@ -117,11 +123,19 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
});
this._add(control, osparc.dashboard.FolderButtonBase.POS.TITLE);
break;
case "subtitle":
case "subtitle-layout":
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
this._add(control, osparc.dashboard.FolderButtonBase.POS.SUBTITLE);
break;
case "date-text":
control = new qx.ui.basic.Label().set({
font: "text-12",
});
this._add(control, osparc.dashboard.FolderButtonBase.POS.SUBTITLE);
this.getChildControl("subtitle-layout").add(control);
break;
case "last-touching":
control = osparc.info.StudyUtils.createLastTouchedBy();
this.getChildControl("subtitle-layout").add(control);
break;
case "menu-button": {
control = new qx.ui.form.MenuButton().set({
Expand Down Expand Up @@ -155,6 +169,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
folder.bind("name", this, "title");
folder.bind("lastModified", this, "lastModified");
folder.bind("trashedAt", this, "trashedAt");
folder.bind("trashedBy", this, "trashedBy");

osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId());

Expand Down Expand Up @@ -235,7 +250,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {

__applyLastModified: function(value) {
if (value) {
const label = this.getChildControl("subtitle");
const label = this.getChildControl("date-text");
label.set({
value: osparc.utils.Utils.formatDateAndTime(value),
toolTipText: this.tr("Last modified"),
Expand All @@ -245,14 +260,21 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {

__applyTrashedAt: function(value) {
if (value && value.getTime() !== new Date(0).getTime()) {
const label = this.getChildControl("subtitle");
const label = this.getChildControl("date-text");
label.set({
value: osparc.utils.Utils.formatDateAndTime(value),
toolTipText: this.tr("Moved to the bin"),
});
}
},

__applyTrashedBy: function(gid) {
if (gid) {
const atom = this.getChildControl("last-touching");
osparc.dashboard.CardBase.addHintFromGids(atom, [gid]);
}
},

__addMenuButton: function() {
const menuButton = this.getChildControl("menu-button");
menuButton.setVisibility("visible");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
layout = this.getChildControl("footer");
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.FPOS.DATE);
break;
case "last-touching-atom":
control = new qx.ui.basic.Atom().set({
alignY: "middle",
allowGrowX: false,
allowShrinkX: false,
label: "by",
font: "text-12",
icon: osparc.dashboard.CardBase.SHARED_USER,
iconPosition: "right",
});
case "last-touching":
control = osparc.info.StudyUtils.createLastTouchedBy();
layout = this.getChildControl("footer");
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.FPOS.LAST_TOUCHING);
break;
Expand Down Expand Up @@ -289,8 +281,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {

__applyTrashedBy: function(gid) {
if (gid) {
// OM: at the moment I'm receiving userId
const atom = this.getChildControl("last-touching-atom");
const atom = this.getChildControl("last-touching");
osparc.dashboard.CardBase.addHintFromGids(atom, [gid]);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ qx.Class.define("osparc.data.model.Folder", {
createdAt: new Date(folderData.createdAt),
lastModified: new Date(folderData.modifiedAt),
trashedAt: folderData.trashedAt ? new Date(folderData.trashedAt) : null,
trashedBy: folderData.trashedBy || null,
});
},

Expand Down Expand Up @@ -104,6 +105,13 @@ qx.Class.define("osparc.data.model.Folder", {
init: null,
event: "changeTrashedAt"
},

trashedBy: {
check: "Number",
nullable: true,
init: null,
event: "changeTrashedBy",
},
},

statics: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ qx.Class.define("osparc.data.model.Study", {
permalink: studyData.permalink || this.getPermalink(),
dev: studyData.dev || this.getDev(),
trashedAt: studyData.trashedAt ? new Date(studyData.trashedAt) : this.getTrashedAt(),
trashedBy: studyData.trashedBy || null,
});

const wbData = studyData.workbench || this.getWorkbench();
Expand Down Expand Up @@ -217,6 +218,13 @@ qx.Class.define("osparc.data.model.Study", {
nullable: true,
init: null,
},

trashedBy: {
check: "Number",
nullable: true,
init: null,
event: "changeTrashedBy",
},
// ------ ignore for serializing ------
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,18 @@ qx.Class.define("osparc.info.StudyUtils", {
studyData["lastChangeDate"] = new Date().toISOString();
})
.catch(err => osparc.FlashMessenger.logAs(err.message, "ERROR"));
}
},

createLastTouchedBy: function() {
return new qx.ui.basic.Atom().set({
alignY: "middle",
allowGrowX: false,
allowShrinkX: false,
label: "by",
font: "text-12",
icon: osparc.dashboard.CardBase.SHARED_USER,
iconPosition: "right",
});
},
}
});

0 comments on commit b5baa85

Please sign in to comment.