Skip to content

Commit a37af36

Browse files
committed
shouldShowFn
1 parent 077f996 commit a37af36

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

services/static-webserver/client/source/class/osparc/jobs/RunsTable.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,24 @@ qx.Class.define("osparc.jobs.RunsTable", {
4444

4545
Object.values(this.self().COLS).forEach(col => columnModel.setColumnWidth(col.column, col.width));
4646

47+
const jobsStore =osparc.store.Jobs.getInstance();
48+
4749
const iconPathStop = "osparc/icons/circle-xmark-text.svg";
4850
const fontButtonRendererStop = new osparc.ui.table.cellrenderer.ImageButtonRenderer("cancel", iconPathStop);
4951
columnModel.setDataCellRenderer(this.self().COLS.ACTION_CANCEL.column, fontButtonRendererStop);
5052

5153
const iconPathInfo = "osparc/icons/circle-info-text.svg";
52-
const fontButtonRendererInfo = new osparc.ui.table.cellrenderer.ImageButtonRenderer("info", iconPathInfo);
54+
const shouldShowInfo = cellInfo => {
55+
if (cellInfo && cellInfo.rowData) {
56+
const job = jobsStore.getJob(cellInfo.rowData["collectionRunId"]);
57+
if (!job) {
58+
return true;
59+
}
60+
return Object.keys(job.getInfo()).length > 0;
61+
}
62+
return true;
63+
}
64+
const fontButtonRendererInfo = new osparc.ui.table.cellrenderer.ImageButtonRenderer("info", iconPathInfo, shouldShowInfo);
5365
columnModel.setDataCellRenderer(this.self().COLS.ACTION_INFO.column, fontButtonRendererInfo);
5466

5567
this.__attachHandlers();

services/static-webserver/client/source/class/osparc/ui/table/cellrenderer/ImageButtonRenderer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
qx.Class.define("osparc.ui.table.cellrenderer.ImageButtonRenderer", {
1919
extend: osparc.ui.table.cellrenderer.ButtonRenderer,
2020

21-
construct: function(clickAction, iconPath) {
21+
construct: function(clickAction, iconPath, shouldShowFn = null) {
2222
this.base(arguments, clickAction);
2323

2424
this.__imageCache = {};
25+
this.__shouldShowFn = shouldShowFn;
2526

2627
this.setIconPath(iconPath);
2728
},
@@ -37,6 +38,20 @@ qx.Class.define("osparc.ui.table.cellrenderer.ImageButtonRenderer", {
3738

3839
members: {
3940
__imageCache: null,
41+
__shouldShowFn: null,
42+
43+
// overridden to play with it's visibility
44+
createDataCellHtml: function(cellInfo, htmlArr) {
45+
const shouldShow = this.__shouldShowFn
46+
?
47+
this.__shouldShowFn(cellInfo)
48+
:
49+
true;
50+
if (!shouldShow) {
51+
return ""; // Hide button
52+
}
53+
return this.base(arguments, cellInfo, htmlArr);
54+
},
4055

4156
__applyIconPath: function(iconPath) {
4257
const resMgr = qx.util.ResourceManager.getInstance();

0 commit comments

Comments
 (0)