-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
104 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
services/static-webserver/client/source/class/osparc/ui/basic/DateAndBy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* ************************************************************************ | ||
osparc - the simcore frontend | ||
https://osparc.io | ||
Copyright: | ||
2020 IT'IS Foundation, https://itis.swiss | ||
License: | ||
MIT: https://opensource.org/licenses/MIT | ||
Authors: | ||
* Odei Maiz (odeimaiz) | ||
************************************************************************ */ | ||
|
||
/** | ||
* Widget that shows a date followed by "by (user_icon)" | ||
*/ | ||
qx.Class.define("osparc.ui.basic.DateAndBy", { | ||
extend: qx.ui.core.Widget, | ||
|
||
construct: function() { | ||
this.base(arguments); | ||
|
||
this._setLayout(new qx.ui.layout.HBox(5)); | ||
|
||
this.set({ | ||
alignY: "middle", | ||
}); | ||
}, | ||
|
||
properties: { | ||
date: { | ||
check: "Date", | ||
nullable: true, | ||
apply: "__applyDate", | ||
}, | ||
|
||
gid: { | ||
check: "Number", | ||
nullable: true, | ||
apply: "__applyGid", | ||
}, | ||
}, | ||
|
||
members: { | ||
_createChildControlImpl: function(id) { | ||
let control; | ||
switch (id) { | ||
case "date-text": | ||
control = new qx.ui.basic.Label().set({ | ||
textColor: "contrasted-text-dark", | ||
alignY: "middle", | ||
rich: true, | ||
font: "text-12", | ||
allowGrowY: false | ||
}); | ||
this._addAt(control, 0); | ||
break; | ||
case "last-touching": | ||
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", | ||
}); | ||
this._addAt(control, 1); | ||
break; | ||
} | ||
return control || this.base(arguments, id); | ||
}, | ||
|
||
__applyDate: function(value) { | ||
if (value) { | ||
const label = this.getChildControl("date-text"); | ||
label.set({ | ||
value: osparc.utils.Utils.formatDateAndTime(value), | ||
}); | ||
} | ||
}, | ||
|
||
__applyGid: function(gid) { | ||
if (gid) { | ||
const atom = this.getChildControl("last-touching"); | ||
osparc.dashboard.CardBase.addHintFromGids(atom, [gid]); | ||
} | ||
}, | ||
} | ||
}); |