Skip to content

Commit f37b63d

Browse files
committed
refactoring
1 parent 761303f commit f37b63d

File tree

3 files changed

+19
-32
lines changed

3 files changed

+19
-32
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,21 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
474474
}
475475
},
476476

477+
_addTaskCard: function(task, cardTitle, cardIcon) {
478+
const isGrid = this._resourcesContainer.getMode() === "grid";
479+
const taskCard = isGrid ? new osparc.dashboard.GridButtonPlaceholder() : new osparc.dashboard.ListButtonPlaceholder();
480+
taskCard.setTask(task);
481+
taskCard.buildLayout(
482+
cardTitle,
483+
cardIcon + (isGrid ? "/60" : "/24"),
484+
null,
485+
true
486+
);
487+
taskCard.subscribeToFilterGroup("searchBarFilter");
488+
this._resourcesContainer.addNonResourceCard(taskCard);
489+
return taskCard;
490+
},
491+
477492
_populateCardMenu: function(card) {
478493
throw new Error("Abstract method called!");
479494
},

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,18 +1884,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
18841884
return this._resourcesList.find(study => study.uuid === id);
18851885
},
18861886

1887-
__createDuplicateCard: function(studyName) {
1888-
const isGrid = this._resourcesContainer.getMode() === "grid";
1889-
const duplicatingStudyCard = isGrid ? new osparc.dashboard.GridButtonPlaceholder() : new osparc.dashboard.ListButtonPlaceholder();
1890-
duplicatingStudyCard.buildLayout(
1891-
this.tr("Duplicating ") + studyName,
1892-
osparc.task.Duplicate.ICON + (isGrid ? "60" : "24"),
1893-
null,
1894-
true
1895-
);
1896-
return duplicatingStudyCard;
1897-
},
1898-
18991887
__duplicateStudy: function(studyData) {
19001888
const text = this.tr("Duplicate process started and added to the background tasks");
19011889
osparc.FlashMessenger.logAs(text, "INFO");
@@ -2143,10 +2131,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21432131

21442132
osparc.task.TasksContainer.getInstance().addTaskUI(duplicateTaskUI);
21452133

2146-
const duplicatingStudyCard = this.__createDuplicateCard(studyName);
2147-
duplicatingStudyCard.setTask(task);
2148-
duplicatingStudyCard.subscribeToFilterGroup("searchBarFilter");
2149-
this._resourcesContainer.addNonResourceCard(duplicatingStudyCard);
2134+
const cardTitle = this.tr("Duplicating ") + studyName;
2135+
const duplicatingStudyCard = this._addTaskCard(task, cardTitle, osparc.task.Duplicate.ICON);
21502136
this.__attachDuplicateEventHandler(task, duplicateTaskUI, duplicatingStudyCard);
21512137
},
21522138

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -396,24 +396,10 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
396396

397397
osparc.task.TasksContainer.getInstance().addTaskUI(toTemplateTaskUI);
398398

399-
const toTemplateCard = this.__createToTemplateCard(studyName);
400-
toTemplateCard.setTask(task);
399+
const cardTitle = this.tr("Publishing ") + studyName;
400+
const toTemplateCard = this._addTaskCard(task, cardTitle, osparc.task.ToTemplate.ICON);
401401
this.__attachToTemplateEventHandler(task, toTemplateTaskUI, toTemplateCard);
402402
},
403-
404-
__createToTemplateCard: function(studyName) {
405-
const isGrid = this._resourcesContainer.getMode() === "grid";
406-
const toTemplateCard = isGrid ? new osparc.dashboard.GridButtonPlaceholder() : new osparc.dashboard.ListButtonPlaceholder();
407-
toTemplateCard.buildLayout(
408-
this.tr("Publishing ") + studyName,
409-
osparc.task.ToTemplate.ICON + (isGrid ? "60" : "24"),
410-
null,
411-
true
412-
);
413-
toTemplateCard.subscribeToFilterGroup("searchBarFilter");
414-
this._resourcesContainer.addNonResourceCard(toTemplateCard);
415-
return toTemplateCard;
416-
}
417403
// TASKS //
418404
}
419405
});

0 commit comments

Comments
 (0)