Skip to content

Commit 12bdf2b

Browse files
authored
Use dedicated thumbnails for ISAN templates (#904)
* Use existing thumbnail field if any * thumbnails moved to GH repo * expose "thumbnail" field
1 parent d72f443 commit 12bdf2b

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

services/web/client/source/class/qxapp/desktop/StudyBrowser.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,19 @@ qx.Class.define("qxapp.desktop.StudyBrowser", {
389389
return list;
390390
},
391391

392+
__uuidToNumber: function(uuid) {
393+
const nThumbnails = 25;
394+
const lastCharacters = uuid.substr(uuid.length-10);
395+
const aNumber = parseInt(lastCharacters, 16);
396+
return aNumber%nThumbnails;
397+
},
398+
392399
/**
393400
* Delegates appearance and binding of each study item
394401
*/
395402
__getDelegate: function(fromTemplate, list) {
396403
const thumbnailWidth = 200;
397404
const thumbnailHeight = 120;
398-
const nThumbnails = 25;
399405
let that = this;
400406
let delegate = {
401407
// Item's Layout
@@ -433,12 +439,15 @@ qx.Class.define("qxapp.desktop.StudyBrowser", {
433439
},
434440
// Item's data binding
435441
bindItem: function(controller, item, id) {
436-
controller.bindProperty("uuid", "icon", {
442+
controller.bindProperty("uuid", "model", null, item, id);
443+
controller.bindProperty("thumbnail", "icon", {
437444
converter: function(data) {
438-
if (data) {
439-
const lastCharacters = data.substr(data.length-10);
440-
const aNumber = parseInt(lastCharacters, 16);
441-
const thumbnailId = aNumber%nThumbnails;
445+
const uuid = item.getModel();
446+
if (uuid) {
447+
if (data) {
448+
return data;
449+
}
450+
const thumbnailId = that.__uuidToNumber(uuid); // eslint-disable-line no-underscore-dangle
442451
return "qxapp/img"+ thumbnailId +".jpg";
443452
}
444453
return "@FontAwesome5Solid/plus-circle/80";
@@ -459,11 +468,6 @@ qx.Class.define("qxapp.desktop.StudyBrowser", {
459468
return data ? new Date(data) : null;
460469
}
461470
}, item, id);
462-
controller.bindProperty("uuid", "model", {
463-
converter: function(data) {
464-
return data;
465-
}
466-
}, item, id);
467471
},
468472
configureItem: item => {
469473
item.getChildControl("icon").set({
@@ -514,8 +518,8 @@ qx.Class.define("qxapp.desktop.StudyBrowser", {
514518
this.__editStudyLayout.removeAt(1);
515519
}
516520

517-
const itemsToBeDisplayed = ["name", "description", "prjOwner", "creationDate", "lastChangeDate"];
518-
const itemsToBeModified = fromTemplate ? [] : ["name", "description"];
521+
const itemsToBeDisplayed = ["name", "description", "thumbnail", "prjOwner", "creationDate", "lastChangeDate"];
522+
const itemsToBeModified = fromTemplate ? [] : ["name", "description", "thumbnail"];
519523
let form = new qx.ui.form.Form();
520524
let control;
521525
for (const dataId in studyData) {
@@ -529,6 +533,10 @@ qx.Class.define("qxapp.desktop.StudyBrowser", {
529533
control = new qx.ui.form.TextField();
530534
form.add(control, this.tr("Description"));
531535
break;
536+
case "thumbnail":
537+
control = new qx.ui.form.TextField();
538+
form.add(control, this.tr("Thumbnail"));
539+
break;
532540
case "prjOwner":
533541
control = new qx.ui.form.TextField();
534542
form.add(control, this.tr("Owner"));

0 commit comments

Comments
 (0)