Skip to content

Commit 690fa62

Browse files
committed
trashed by in Workspace
1 parent 7d4ff8c commit 690fa62

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,27 +151,27 @@ qx.Class.define("osparc.dashboard.CardBase", {
151151
populateShareIcon: function(shareIcon, accessRights) {
152152
const gids = Object.keys(accessRights).map(key => parseInt(key));
153153

154-
const groupsStore = osparc.store.Groups.getInstance();
155-
156154
// Icon
155+
const groupsStore = osparc.store.Groups.getInstance();
157156
const groupEveryone = groupsStore.getEveryoneGroup();
158157
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
159158
const organizations = groupsStore.getOrganizations();
159+
const myGroupId = groupsStore.getMyGroupId();
160+
160161
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
161162
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
162163
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
163164
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
164165
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
165-
} else if (gids.length === 1) {
166+
} else if (gids.length === 1 && gids[0] === myGroupId) {
166167
shareIcon.setSource(osparc.dashboard.CardBase.SHARE_ICON);
167168
} else {
168169
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_USER);
169170
}
170171

171172
// Tooltip
172-
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
173-
const myGroupId = groupsStore.getMyGroupId();
174173
if (gids.length === 0 || (gids.length === 1 && gids[0] === myGroupId)) {
174+
const canIWrite = osparc.data.model.Study.canIWrite(accessRights);
175175
if (canIWrite) {
176176
shareIcon.set({
177177
toolTipText: qx.locale.Manager.tr("Share")
@@ -180,6 +180,16 @@ qx.Class.define("osparc.dashboard.CardBase", {
180180
return;
181181
}
182182

183+
this.populateTooltip(shareIcon, gids);
184+
},
185+
186+
populateTooltip: function(icon, gids) {
187+
const groupsStore = osparc.store.Groups.getInstance();
188+
const groupEveryone = groupsStore.getEveryoneGroup();
189+
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
190+
const organizations = groupsStore.getOrganizations();
191+
const myGroupId = groupsStore.getMyGroupId();
192+
183193
const sharedGrps = [];
184194
const groups = [];
185195
groups.push(groupEveryone);
@@ -193,8 +203,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
193203
}
194204
});
195205

196-
const hint = new osparc.ui.hint.Hint(shareIcon);
197-
shareIcon.addListener("mouseover", async () => {
206+
const hint = new osparc.ui.hint.Hint(icon);
207+
icon.addListener("mouseover", async () => {
198208
hint.show();
199209

200210
// lazy load tooltip, this can be an expensive call
@@ -230,7 +240,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
230240
}
231241
}
232242
}, this);
233-
shareIcon.addListener("mouseout", () => hint.exclude(), this);
243+
icon.addListener("mouseout", () => hint.exclude(), this);
234244
},
235245
},
236246

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonBase", {
9090
MENU: 2,
9191
},
9292
FPOS: {
93-
MODIFIED: 0
93+
DATE: 0,
94+
LAST_TOUCHING: 1,
9495
}
9596
},
9697

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
9898
nullable: true,
9999
apply: "__applyTrashedAt"
100100
},
101+
102+
trashedBy: {
103+
check: "Number",
104+
nullable: true,
105+
apply: "__applyTrashedBy"
106+
},
101107
},
102108

103109
statics: {
@@ -139,7 +145,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
139145
layout = this.getChildControl("header");
140146
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.HPOS.MENU);
141147
break;
142-
case "footer-text":
148+
case "date-text":
143149
control = new qx.ui.basic.Label().set({
144150
textColor: "contrasted-text-dark",
145151
alignY: "middle",
@@ -149,7 +155,16 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
149155
allowGrowY: false
150156
});
151157
layout = this.getChildControl("footer");
152-
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.FPOS.MODIFIED);
158+
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.FPOS.DATE);
159+
break;
160+
case "last-touching-icon":
161+
control = new qx.ui.basic.Image().set({
162+
alignY: "middle",
163+
allowGrowX: false,
164+
allowShrinkX: false
165+
});
166+
layout = this.getChildControl("footer");
167+
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.FPOS.LAST_TOUCHING);
153168
break;
154169
}
155170
return control || this.base(arguments, id);
@@ -168,6 +183,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
168183
workspace.bind("accessRights", this, "accessRights");
169184
workspace.bind("modifiedAt", this, "modifiedAt");
170185
workspace.bind("trashedAt", this, "trashedAt");
186+
workspace.bind("trashedBy", this, "trashedBy");
171187
workspace.bind("myAccessRights", this, "myAccessRights");
172188

173189
osparc.utils.Utils.setIdToWidget(this, "workspaceItem_" + workspace.getWorkspaceId());
@@ -250,18 +266,29 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
250266

251267
__applyModifiedAt: function(value) {
252268
if (value) {
253-
const label = this.getChildControl("footer-text");
269+
const label = this.getChildControl("date-text");
254270
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
255271
}
256272
},
257273

258274
__applyTrashedAt: function(value) {
259275
if (value && value.getTime() !== new Date(0).getTime()) {
260-
const label = this.getChildControl("footer-text");
276+
const label = this.getChildControl("date-text");
261277
label.setValue(osparc.utils.Utils.formatDateAndTime(value));
262278
}
263279
},
264280

281+
__applyTrashedBy: function(gid) {
282+
if (gid) {
283+
// OM: at the moment I'm receiving userId
284+
const label = this.getChildControl("date-text");
285+
label.setValue(label.getValue() + " by ");
286+
const icon = this.getChildControl("last-touching-icon");
287+
osparc.dashboard.CardBase.populateTooltip(icon, [gid]);
288+
icon.setSource(osparc.dashboard.CardBase.SHARED_USER);
289+
}
290+
},
291+
265292
__updateTooltip: function() {
266293
const toolTipText = this.getTitle() + (this.getDescription() ? "<br>" + this.getDescription() : "");
267294
this.set({

services/static-webserver/client/source/class/osparc/data/model/Workspace.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ qx.Class.define("osparc.data.model.Workspace", {
110110
check: "Number",
111111
nullable: true,
112112
init: null,
113+
event: "changeTrashedBy",
113114
},
114115
},
115116

0 commit comments

Comments
 (0)