Skip to content

Commit a29ada7

Browse files
committed
fix duplicated cards
1 parent e078bfb commit a29ada7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
177177
return (card instanceof osparc.dashboard.GridButtonItem || card instanceof osparc.dashboard.ListButtonItem);
178178
},
179179

180+
isCardTaskPlaceholder: function(card) {
181+
return (card instanceof osparc.dashboard.GridButtonTaskPlaceholder || card instanceof osparc.dashboard.ListButtonTaskPlaceholder);
182+
},
183+
180184
createToolbarRadioButton: function(label, icon, toolTipText, pos) {
181185
const rButton = new qx.ui.toolbar.RadioButton().set({
182186
label,
@@ -475,6 +479,13 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
475479
},
476480

477481
_addTaskCard: function(task, cardTitle, cardIcon) {
482+
if (task) {
483+
const taskPlaceholders = this._resourcesContainer.getCards().filter(card => osparc.dashboard.ResourceBrowserBase.isCardTaskPlaceholder(card));
484+
if (taskPlaceholders.find(taskPlaceholder => taskPlaceholder.getTask() === task)) {
485+
return null;
486+
}
487+
}
488+
478489
const isGrid = this._resourcesContainer.getMode() === "grid";
479490
const taskCard = isGrid ? new osparc.dashboard.GridButtonTaskPlaceholder() : new osparc.dashboard.ListButtonTaskPlaceholder();
480491
taskCard.setTask(task);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19391939
const cardTitle = this.tr("Importing Study...");
19401940
const cardIcon = "@FontAwesome5Solid/cloud-upload-alt";
19411941
const importingStudyCard = this._addTaskCard(null, cardTitle, cardIcon);
1942-
this.__attachImportEventHandler(file, importTaskUI, importingStudyCard);
1942+
if (importingStudyCard) {
1943+
this.__attachImportEventHandler(file, importTaskUI, importingStudyCard);
1944+
}
19431945
},
19441946

19451947
__attachImportEventHandler: function(file, importTaskUI, importingStudyCard) {
@@ -2129,7 +2131,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21292131

21302132
const cardTitle = this.tr("Duplicating ") + studyName;
21312133
const duplicatingStudyCard = this._addTaskCard(task, cardTitle, osparc.task.Duplicate.ICON);
2132-
this.__attachDuplicateEventHandler(task, duplicateTaskUI, duplicatingStudyCard);
2134+
if (duplicatingStudyCard) {
2135+
this.__attachDuplicateEventHandler(task, duplicateTaskUI, duplicatingStudyCard);
2136+
}
21332137
},
21342138

21352139
__attachDuplicateEventHandler: function(task, taskUI, duplicatingStudyCard) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,9 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
398398

399399
const cardTitle = this.tr("Publishing ") + studyName;
400400
const toTemplateCard = this._addTaskCard(task, cardTitle, osparc.task.ToTemplate.ICON);
401-
this.__attachToTemplateEventHandler(task, toTemplateTaskUI, toTemplateCard);
401+
if (toTemplateCard) {
402+
this.__attachToTemplateEventHandler(task, toTemplateTaskUI, toTemplateCard);
403+
}
402404
},
403405
// TASKS //
404406
}

0 commit comments

Comments
 (0)