Skip to content

Commit 7863d91

Browse files
committed
[skip ci] DateAndBy
1 parent b5baa85 commit 7863d91

File tree

2 files changed

+104
-16
lines changed

2 files changed

+104
-16
lines changed

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
127127
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
128128
this._add(control, osparc.dashboard.FolderButtonBase.POS.SUBTITLE);
129129
break;
130-
case "date-text":
131-
control = new qx.ui.basic.Label().set({
132-
font: "text-12",
133-
});
134-
this.getChildControl("subtitle-layout").add(control);
135-
break;
136-
case "last-touching":
137-
control = osparc.info.StudyUtils.createLastTouchedBy();
130+
case "date-by":
131+
control = new osparc.ui.basic.DateAndBy();
138132
this.getChildControl("subtitle-layout").add(control);
139133
break;
140134
case "menu-button": {
@@ -250,28 +244,28 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
250244

251245
__applyLastModified: function(value) {
252246
if (value) {
253-
const label = this.getChildControl("date-text");
254-
label.set({
255-
value: osparc.utils.Utils.formatDateAndTime(value),
247+
const dateBy = this.getChildControl("date-by");
248+
dateBy.set({
249+
date: value,
256250
toolTipText: this.tr("Last modified"),
257251
})
258252
}
259253
},
260254

261255
__applyTrashedAt: function(value) {
262256
if (value && value.getTime() !== new Date(0).getTime()) {
263-
const label = this.getChildControl("date-text");
264-
label.set({
265-
value: osparc.utils.Utils.formatDateAndTime(value),
257+
const dateBy = this.getChildControl("date-by");
258+
dateBy.set({
259+
date: value,
266260
toolTipText: this.tr("Moved to the bin"),
267261
});
268262
}
269263
},
270264

271265
__applyTrashedBy: function(gid) {
272266
if (gid) {
273-
const atom = this.getChildControl("last-touching");
274-
osparc.dashboard.CardBase.addHintFromGids(atom, [gid]);
267+
const dateBy = this.getChildControl("date-by");
268+
dateBy.setGid(gid);
275269
}
276270
},
277271

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2020 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
/**
19+
* Widget that shows a date followed by "by (user_icon)"
20+
*/
21+
qx.Class.define("osparc.ui.basic.DateAndBy", {
22+
extend: qx.ui.core.Widget,
23+
24+
construct: function() {
25+
this.base(arguments);
26+
27+
this._setLayout(new qx.ui.layout.HBox(5));
28+
29+
this.set({
30+
alignY: "middle",
31+
});
32+
},
33+
34+
properties: {
35+
date: {
36+
check: "Date",
37+
nullable: true,
38+
apply: "__applyDate",
39+
},
40+
41+
gid: {
42+
check: "Number",
43+
nullable: true,
44+
apply: "__applyGid",
45+
},
46+
},
47+
48+
members: {
49+
_createChildControlImpl: function(id) {
50+
let control;
51+
switch (id) {
52+
case "date-text":
53+
control = new qx.ui.basic.Label().set({
54+
textColor: "contrasted-text-dark",
55+
alignY: "middle",
56+
rich: true,
57+
font: "text-12",
58+
allowGrowY: false
59+
});
60+
this._addAt(control, 0);
61+
break;
62+
case "last-touching":
63+
new qx.ui.basic.Atom().set({
64+
alignY: "middle",
65+
allowGrowX: false,
66+
allowShrinkX: false,
67+
label: "by",
68+
font: "text-12",
69+
icon: osparc.dashboard.CardBase.SHARED_USER,
70+
iconPosition: "right",
71+
});
72+
this._addAt(control, 1);
73+
break;
74+
}
75+
return control || this.base(arguments, id);
76+
},
77+
78+
__applyDate: function(value) {
79+
if (value) {
80+
const label = this.getChildControl("date-text");
81+
label.set({
82+
value: osparc.utils.Utils.formatDateAndTime(value),
83+
});
84+
}
85+
},
86+
87+
__applyGid: function(gid) {
88+
if (gid) {
89+
const atom = this.getChildControl("last-touching");
90+
osparc.dashboard.CardBase.addHintFromGids(atom, [gid]);
91+
}
92+
},
93+
}
94+
});

0 commit comments

Comments
 (0)