From 565681c9f659691e759e6ffbb8f1b510856790b3 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 11:03:42 +0100 Subject: [PATCH 01/32] set layout first --- .../source/class/osparc/dashboard/GridButtonBase.js | 5 ++--- .../source/class/osparc/dashboard/ListButtonBase.js | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonBase.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonBase.js index ad0a78c20c1..e1b7c72ff71 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonBase.js @@ -28,6 +28,8 @@ qx.Class.define("osparc.dashboard.GridButtonBase", { construct: function() { this.base(arguments); + this._setLayout(new qx.ui.layout.Canvas()); + this.set({ width: this.self().ITEM_WIDTH, height: this.self().ITEM_HEIGHT, @@ -35,8 +37,6 @@ qx.Class.define("osparc.dashboard.GridButtonBase", { allowGrowX: false }); - this._setLayout(new qx.ui.layout.Canvas()); - this.getChildControl("main-layout"); }, @@ -107,7 +107,6 @@ qx.Class.define("osparc.dashboard.GridButtonBase", { }, members: { - // overridden _createChildControlImpl: function(id) { let layout; diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js index 86decb00157..d99d33f6608 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonBase.js @@ -27,16 +27,17 @@ qx.Class.define("osparc.dashboard.ListButtonBase", { construct: function() { this.base(arguments); - this.set({ - minHeight: osparc.dashboard.ListButtonBase.ITEM_HEIGHT, - allowGrowX: true - }); const layout = new qx.ui.layout.Grid(); layout.setSpacing(10); layout.setColumnFlex(osparc.dashboard.ListButtonBase.POS.SPACER, 1); this._setLayout(layout); + this.set({ + minHeight: osparc.dashboard.ListButtonBase.ITEM_HEIGHT, + allowGrowX: true + }); + this.getChildControl("spacer"); }, From 20e3f3da71fd0c7a9b9d29f1ede53a4b81f40599 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 11:16:15 +0100 Subject: [PATCH 02/32] isValidWidget --- .../osparc/dashboard/ResourceContainerManager.js | 4 ++-- .../class/osparc/dashboard/ToggleButtonContainer.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 679c2b45cf1..eebcfc98b86 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -118,7 +118,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __groupedContainers: null, addNonResourceCard: function(card) { - if (card instanceof qx.ui.form.ToggleButton) { + if (osparc.dashboard.ToggleButtonContainer.isValidWidget(card)) { if (this.getGroupBy()) { // it will always go to the no-group group const noGroupContainer = this.__getGroupContainer("no-group"); @@ -134,7 +134,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, removeNonResourceCard: function(card) { - if (card instanceof qx.ui.form.ToggleButton) { + if (osparc.dashboard.ToggleButtonContainer.isValidWidget(card)) { if (this.getGroupBy()) { const noGroupContainer = this.__getGroupContainer("no-group"); if (noGroupContainer.getContentContainer().getChildren().indexOf(card) > -1) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js index bbabe433161..846624f88e4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js @@ -22,12 +22,22 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { "changeVisibility": "qx.event.type.Data" }, + static: { + isValidWidget: function(widget) { + // return (card instanceof qx.ui.form.ToggleButton); + return ( + widget instanceof osparc.dashboard.CardBase || + widget instanceof osparc.dashboard.FolderButtonBase + ); + }, + }, + members: { __lastSelectedIdx: null, // overridden add: function(child, options) { - if (child instanceof qx.ui.form.ToggleButton) { + if (this.self().isValidWidget(child)) { if (osparc.dashboard.ResourceContainerManager.cardExists(this, child)) { return; } From 955bf5df73845df2524af05ca1be51e16a750575 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 11:19:48 +0100 Subject: [PATCH 03/32] [skip ci] ToggleButton -> Widget --- .../source/class/osparc/dashboard/CardBase.js | 23 ++++++++++++++++++- .../osparc/dashboard/FolderButtonBase.js | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 0d058644bce..56a8ebb0e56 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -16,7 +16,7 @@ ************************************************************************ */ qx.Class.define("osparc.dashboard.CardBase", { - extend: qx.ui.form.ToggleButton, + extend: qx.ui.core.Widget, implement: [qx.ui.form.IModel, osparc.filter.IFilterable], include: [qx.ui.form.MModelProperty, osparc.filter.MFilterable], type: "abstract", @@ -237,6 +237,19 @@ qx.Class.define("osparc.dashboard.CardBase", { nullable: true }, + selected: { + check: "Boolean", + init: false, + nullable: false, + }, + + icon: { + check: "String", + init: null, + nullable: true, + apply: "_applyIcon", + }, + resourceData: { check: "Object", nullable: false, @@ -886,6 +899,14 @@ qx.Class.define("osparc.dashboard.CardBase", { return control; }, + setValue: function(value) { + this.setSelected(value); + }, + + getValue: function() { + this.getSelected(); + }, + /** * Event handler for the pointer over event. */ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonBase.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonBase.js index ff567a659cb..435e63b2129 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonBase.js @@ -16,7 +16,7 @@ ************************************************************************ */ qx.Class.define("osparc.dashboard.FolderButtonBase", { - extend: qx.ui.form.ToggleButton, + extend: qx.ui.core.Widget, implement: [qx.ui.form.IModel, osparc.filter.IFilterable], include: [qx.ui.form.MModelProperty, osparc.filter.MFilterable], type: "abstract", From be05ce1cd8df1645d9913348d0f0a189d564fe93 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 11:20:40 +0100 Subject: [PATCH 04/32] [skip ci] minor --- .../source/class/osparc/dashboard/ToggleButtonContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js index 846624f88e4..1c9c23f84d5 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js @@ -22,7 +22,7 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { "changeVisibility": "qx.event.type.Data" }, - static: { + statics: { isValidWidget: function(widget) { // return (card instanceof qx.ui.form.ToggleButton); return ( From e5affe506608cff7cefbd63d8f9150c9fcb763c2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 12:29:02 +0100 Subject: [PATCH 05/32] [skip ci] tap service button --- .../client/source/class/osparc/dashboard/ServiceBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js index 5fbaa4ebaf7..7ae65ff0bd1 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js @@ -86,7 +86,7 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", { const cards = this._resourcesContainer.reloadCards("services"); cards.forEach(card => { card.setMultiSelectionMode(this.getMultiSelection()); - card.addListener("execute", () => this.__itemClicked(card), this); + card.addListener("tap", () => this.__itemClicked(card), this); this._populateCardMenu(card); }); osparc.filter.UIFilterController.dispatch("searchBarFilter"); From 011f9de8661d1a944d1c253fe75579cf890e9b63 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 12:47:40 +0100 Subject: [PATCH 06/32] [skip ci] don't listen to change value --- .../source/class/osparc/dashboard/CardBase.js | 1 + .../osparc/dashboard/FolderButtonItem.js | 3 +-- .../class/osparc/dashboard/FolderButtonNew.js | 3 +-- .../class/osparc/dashboard/GridButtonItem.js | 6 ++--- .../osparc/dashboard/GridButtonLoadMore.js | 4 --- .../class/osparc/dashboard/GridButtonNew.js | 4 --- .../osparc/dashboard/GridButtonPlaceholder.js | 7 ----- .../class/osparc/dashboard/ListButtonItem.js | 6 ++--- .../osparc/dashboard/ListButtonLoadMore.js | 4 --- .../class/osparc/dashboard/ListButtonNew.js | 4 --- .../osparc/dashboard/ListButtonPlaceholder.js | 7 ----- .../class/osparc/dashboard/StudyBrowser.js | 26 +++++++++---------- .../class/osparc/dashboard/TemplateBrowser.js | 1 - .../osparc/dashboard/ToggleButtonContainer.js | 15 ++++++----- .../osparc/dashboard/WorkspaceButtonBase.js | 13 +++++++--- .../osparc/dashboard/WorkspaceButtonItem.js | 3 +-- .../osparc/dashboard/WorkspaceButtonNew.js | 3 +-- 17 files changed, 41 insertions(+), 69 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 56a8ebb0e56..5a8a66df13a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -241,6 +241,7 @@ qx.Class.define("osparc.dashboard.CardBase", { check: "Boolean", init: false, nullable: false, + event: "changeSelected", }, icon: { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index ac919b73579..b54d45be542 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -33,7 +33,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { appearance: "pb-study" }); - this.addListener("changeValue", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", e => this.__itemSelected(e.getData()), this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); @@ -246,7 +246,6 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { if (studyBrowserContext !== "trash" && newVal) { this.fireDataEvent("folderSelected", this.getFolderId()); } - this.setValue(false); }, __editFolder: function() { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js index 6fe4c7d9bba..0a637e8d5b3 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js @@ -30,7 +30,7 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", { appearance: "pb-new" }); - this.addListener("changeValue", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", e => this.__itemSelected(e.getData()), this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW); @@ -92,7 +92,6 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", { }); folderEditor.addListener("cancel", () => win.close()); } - this.setValue(false); } } }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index e9019262342..764be022f22 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -32,7 +32,7 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); - this.addListener("changeValue", this.__itemSelected, this); + this.addListener("tap", this.__itemSelected, this); }, statics: { @@ -189,12 +189,12 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { __itemSelected: function() { if (this.isItemNotClickable()) { - this.setValue(false); + this.setSelected(false); return; } if (this.isResourceType("study") && this.isMultiSelectionMode()) { - const selected = this.getValue(); + const selected = this.getSelected(); const tick = this.getChildControl("tick-selected"); tick.setVisibility(selected ? "visible" : "excluded"); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonLoadMore.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonLoadMore.js index a10d57dcaa2..af3bf1ae666 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonLoadMore.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonLoadMore.js @@ -50,10 +50,6 @@ qx.Class.define("osparc.dashboard.GridButtonLoadMore", { this.setEnabled(!value); }, - _onToggleChange: function(e) { - this.setValue(false); - }, - _shouldApplyFilter: function() { return false; }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonNew.js index 4a2a3577e31..3cb8a8c92b7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonNew.js @@ -67,10 +67,6 @@ qx.Class.define("osparc.dashboard.GridButtonNew", { }, members: { - _onToggleChange: function(e) { - this.setValue(false); - }, - _shouldApplyFilter: function(data) { return false; }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonPlaceholder.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonPlaceholder.js index 89f9c94270a..b6eb9906ef7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonPlaceholder.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonPlaceholder.js @@ -23,9 +23,6 @@ qx.Class.define("osparc.dashboard.GridButtonPlaceholder", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.PLACEHOLDER); - // make unselectable - this.addListener("changeValue", () => this.setValue(false), this); - this.set({ cursor: "not-allowed" }); @@ -122,10 +119,6 @@ qx.Class.define("osparc.dashboard.GridButtonPlaceholder", { return true; }, - _onToggleChange: function() { - this.setValue(false); - }, - _shouldApplyFilter: function(data) { if (data.text) { const checks = [ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js index 9c433550185..390019015d0 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js @@ -29,7 +29,7 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); - this.addListener("changeValue", this.__itemSelected, this); + this.addListener("tap", this.__itemSelected, this); }, statics: { @@ -275,12 +275,12 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { __itemSelected: function() { if (this.isItemNotClickable()) { - this.setValue(false); + this.setSelected(false); return; } if (this.isResourceType("study") && this.isMultiSelectionMode()) { - const selected = this.getValue(); + const selected = this.getSelected(); const tick = this.getChildControl("tick-selected"); tick.setVisibility(selected ? "visible" : "excluded"); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonLoadMore.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonLoadMore.js index cbf818c8cdc..1f0fad3e4a6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonLoadMore.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonLoadMore.js @@ -49,10 +49,6 @@ qx.Class.define("osparc.dashboard.ListButtonLoadMore", { this.setEnabled(!value); }, - _onToggleChange: function(e) { - this.setValue(false); - }, - _shouldApplyFilter: function() { return false; }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonNew.js index d9bb0679f46..7ae28a96cf4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonNew.js @@ -51,10 +51,6 @@ qx.Class.define("osparc.dashboard.ListButtonNew", { }, members: { - _onToggleChange: function(e) { - this.setValue(false); - }, - _shouldApplyFilter: function(data) { return false; }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonPlaceholder.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonPlaceholder.js index 7074ded3194..d813261ef3c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonPlaceholder.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonPlaceholder.js @@ -23,9 +23,6 @@ qx.Class.define("osparc.dashboard.ListButtonPlaceholder", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.PLACEHOLDER); - // make unselectable - this.addListener("changeValue", () => this.setValue(false), this); - this.__layout = this.getChildControl("progress-layout") this.set({ appearance: "pb-new", @@ -108,10 +105,6 @@ qx.Class.define("osparc.dashboard.ListButtonPlaceholder", { return true; }, - _onToggleChange: function() { - this.setValue(false); - }, - _shouldApplyFilter: function(data) { if (data.text) { const checks = [ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 0a25257f247..c1c4339efd6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -640,16 +640,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { card.setMultiSelectionMode(this.getMultiSelection()); card.addListener("tap", e => { if (card.isItemNotClickable()) { - card.setValue(false); + card.setSelected(false); } else { - this.__itemClicked(card, e.getNativeEvent().shiftKey); + this.__studyCardClicked(card, e.getNativeEvent().shiftKey); } }, this); this._populateCardMenu(card); }); }, - __itemClicked: function(item, isShiftPressed) { + __studyCardClicked: function(item, isShiftPressed) { const studiesCont = this._resourcesContainer.getFlatList(); if (isShiftPressed) { @@ -659,13 +659,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { for (let i=minMax[0]; i<=minMax[1]; i++) { const card = studiesCont.getChildren()[i]; if (card.isVisible()) { - card.setValue(true); + card.setSelected(true); } } } studiesCont.setLastSelectedIndex(studiesCont.getIndex(item)); - if (!item.isMultiSelectionMode()) { + if (item.isMultiSelectionMode()) { + item.setSelected(true); + } else { const studyData = this.__getStudyData(item.getUuid(), false); this._openResourceDetails(studyData); this.resetSelection(); @@ -860,7 +862,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { newStudyBtn.setCardKey("new-study"); newStudyBtn.subscribeToFilterGroup("searchBarFilter"); osparc.utils.Utils.setIdToWidget(newStudyBtn, "newStudyBtn"); - newStudyBtn.addListener("execute", () => this.__newStudyBtnClicked(newStudyBtn)); + newStudyBtn.addListener("tap", () => this.__newStudyBtnClicked(newStudyBtn)); this._resourcesContainer.addNonResourceCard(newStudyBtn); }, @@ -880,8 +882,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (product in newStudiesData) { newStudyBtn.setEnabled(true); - newStudyBtn.addListener("execute", () => { - newStudyBtn.setValue(false); + newStudyBtn.addListener("tap", () => { osparc.data.Resources.get("templates") .then(templates => { if (templates) { @@ -930,7 +931,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const newStudyFromServiceButton = (mode === "grid") ? new osparc.dashboard.GridButtonNew(title, desc) : new osparc.dashboard.ListButtonNew(title, desc); newStudyFromServiceButton.setCardKey("new-"+key); osparc.utils.Utils.setIdToWidget(newStudyFromServiceButton, newButtonInfo.idToWidget); - newStudyFromServiceButton.addListener("execute", () => this.__newStudyFromServiceBtnClicked(newStudyFromServiceButton, latestMetadata["key"], latestMetadata["version"], newButtonInfo.newStudyLabel)); + newStudyFromServiceButton.addListener("tap", () => this.__newStudyFromServiceBtnClicked(newStudyFromServiceButton, latestMetadata["key"], latestMetadata["version"], newButtonInfo.newStudyLabel)); this._resourcesContainer.addNonResourceCard(newStudyFromServiceButton); }) } @@ -1153,8 +1154,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const loadMoreBtn = this._loadingResourcesBtn = (mode === "grid") ? new osparc.dashboard.GridButtonLoadMore() : new osparc.dashboard.ListButtonLoadMore(); loadMoreBtn.setCardKey("load-more"); osparc.utils.Utils.setIdToWidget(loadMoreBtn, "studiesLoading"); - loadMoreBtn.addListener("execute", () => { - loadMoreBtn.setValue(false); + loadMoreBtn.addListener("tap", () => { this._moreResourcesRequired(); }); return loadMoreBtn; @@ -1324,7 +1324,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if (osparc.dashboard.ResourceBrowserBase.isCardButtonItem(studyItem)) { studyItem.setMultiSelectionMode(value); if (value === false) { - studyItem.setValue(false); + studyItem.setSelected(false); } } }); @@ -1347,7 +1347,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __newStudyBtnClicked: function(button) { - button.setValue(false); const minStudyData = osparc.data.model.Study.createMinStudyObject(); const existingNames = this._resourcesList.map(study => study["name"]); const title = osparc.utils.Utils.getUniqueName(minStudyData.name, existingNames); @@ -1388,7 +1387,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __newStudyFromServiceBtnClicked: function(button, key, version, newStudyLabel) { - button.setValue(false); this._showLoadingPage(this.tr("Creating ") + osparc.product.Utils.getStudyAlias()); const contextProps = { workspaceId: this.getCurrentWorkspaceId(), diff --git a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js index 0b6fc8ccd26..fab2dc1eb94 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/TemplateBrowser.js @@ -125,7 +125,6 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", { __itemClicked: function(card) { if (!card.getBlocked()) { - card.setValue(false); const templateData = this.__getTemplateData(card.getUuid()); this._openResourceDetails(templateData); } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js index 1c9c23f84d5..258303b7532 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js @@ -27,7 +27,8 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { // return (card instanceof qx.ui.form.ToggleButton); return ( widget instanceof osparc.dashboard.CardBase || - widget instanceof osparc.dashboard.FolderButtonBase + widget instanceof osparc.dashboard.FolderButtonBase || + widget instanceof osparc.dashboard.WorkspaceButtonBase ); }, }, @@ -42,7 +43,7 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { return; } this.base(arguments, child, options); - child.addListener("changeValue", () => this.fireDataEvent("changeSelection", this.getSelection()), this); + child.addListener("changeSelected", () => this.fireDataEvent("changeSelection", this.getSelection()), this); child.addListener("changeVisibility", () => this.fireDataEvent("changeVisibility", this.__getVisibles()), this); } else { console.error("ToggleButtonContainer only allows ToggleButton as its children."); @@ -53,7 +54,7 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { * Resets the selection so no toggle button is checked. */ resetSelection: function() { - this.getChildren().map(button => button.setValue(false)); + this.getChildren().map(button => button.setSelected(false)); this.__lastSelectedIdx = null; this.fireDataEvent("changeSelection", this.getSelection()); }, @@ -62,7 +63,7 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { * Returns an array that contains all buttons that are checked. */ getSelection: function() { - return this.getChildren().filter(button => button.getValue()); + return this.getChildren().filter(button => button.getSelected()); }, /** @@ -73,12 +74,12 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { }, /** - * Sets the given button's value to true (checks it) and unchecks all other buttons. If the given button is not present, - * every button in the container will get a false value (unchecked). + * Sets the given button's select prop to true (checks it) and unchecks all other buttons. If the given button is not present, + * every button in the container will get a unselected (unchecked). * @param {qx.ui.form.ToggleButton} child Button that will be checked */ selectOne: function(child) { - this.getChildren().map(button => button.setValue(button === child)); + this.getChildren().map(button => button.setSelected(button === child)); this.setLastSelectedIndex(this.getIndex(child)); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonBase.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonBase.js index c0c93cc9508..a6fb451fc2d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonBase.js @@ -16,7 +16,7 @@ ************************************************************************ */ qx.Class.define("osparc.dashboard.WorkspaceButtonBase", { - extend: qx.ui.form.ToggleButton, + extend: qx.ui.core.Widget, implement: [qx.ui.form.IModel, osparc.filter.IFilterable], include: [qx.ui.form.MModelProperty, osparc.filter.MFilterable], type: "abstract", @@ -24,14 +24,14 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonBase", { construct: function() { this.base(arguments); + this._setLayout(new qx.ui.layout.Canvas()); + this.set({ width: this.self().ITEM_WIDTH, height: this.self().ITEM_HEIGHT, padding: 0 }); - this._setLayout(new qx.ui.layout.Canvas()); - this.getChildControl("main-layout"); [ @@ -51,6 +51,13 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonBase", { nullable: true }, + icon: { + check: "String", + init: null, + nullable: true, + apply: "_applyIcon", + }, + resourceType: { check: ["workspace"], init: "workspace", diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index eb777ca5dd7..f6d6f53909f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -33,7 +33,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { appearance: "pb-listitem" }); - this.addListener("changeValue", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", e => this.__itemSelected(e.getData()), this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); @@ -259,7 +259,6 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { if (studyBrowserContext !== "trash" && newVal) { this.fireDataEvent("workspaceSelected", this.getWorkspaceId()); } - this.setValue(false); }, __openShareWith: function() { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js index dd65702503b..b2ba2a74eb1 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js @@ -30,7 +30,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", { appearance: "pb-new" }); - this.addListener("changeValue", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", e => this.__itemSelected(e.getData()), this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW); @@ -72,7 +72,6 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", { win.getChildControl("close-button").addListener("tap", () => workspaceEditor.cancel()); workspaceEditor.addListener("cancel", () => win.close()); } - this.setValue(false); } } }); From 84ba8f79e60038b42295e07b49aac4d546d2edbe Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 14:17:59 +0100 Subject: [PATCH 07/32] [skip ci] __evalSelectedButton --- .../class/osparc/dashboard/GridButtonItem.js | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index 764be022f22..36f13117e2b 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -33,6 +33,8 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); this.addListener("tap", this.__itemSelected, this); + + this.addListener("changeSelected", this.__evalSelectedButton, this); }, statics: { @@ -179,11 +181,9 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { // overridden _applyMultiSelectionMode: function(value) { if (value) { - const menuButton = this.getChildControl("menu-button"); - menuButton.setVisibility("excluded"); - this.__itemSelected(); + this.__evalSelectedButton(); } else { - this.__showMenuOnly(); + this.setSelected(false); } }, @@ -193,26 +193,23 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { return; } - if (this.isResourceType("study") && this.isMultiSelectionMode()) { - const selected = this.getSelected(); - - const tick = this.getChildControl("tick-selected"); - tick.setVisibility(selected ? "visible" : "excluded"); - - const untick = this.getChildControl("tick-unselected"); - untick.setVisibility(selected ? "excluded" : "visible"); - } else { - this.__showMenuOnly(); - } + this.setSelected(!this.getSelected()); }, - __showMenuOnly: function() { + __evalSelectedButton: function() { + const selected = this.getSelected(); const menuButton = this.getChildControl("menu-button"); - menuButton.setVisibility("visible"); const tick = this.getChildControl("tick-selected"); - tick.setVisibility("excluded"); const untick = this.getChildControl("tick-unselected"); - untick.setVisibility("excluded"); + if (this.isResourceType("study") && this.isMultiSelectionMode()) { + menuButton.setVisibility("excluded"); + tick.setVisibility(selected ? "visible" : "excluded"); + untick.setVisibility(selected ? "excluded" : "visible"); + } else { + menuButton.setVisibility("visible"); + tick.setVisibility("excluded"); + untick.setVisibility("excluded"); + } }, // overridden From 23a0aae1f4203ff3d48ce76cbec6d744b8beff0f Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 15:33:03 +0100 Subject: [PATCH 08/32] empty specific-info by default --- .../client/source/class/osparc/pricing/UnitEditor.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/pricing/UnitEditor.js b/services/static-webserver/client/source/class/osparc/pricing/UnitEditor.js index 26469666570..38f9022172e 100644 --- a/services/static-webserver/client/source/class/osparc/pricing/UnitEditor.js +++ b/services/static-webserver/client/source/class/osparc/pricing/UnitEditor.js @@ -36,7 +36,6 @@ qx.Class.define("osparc.pricing.UnitEditor", { const manager = this.__validator = new qx.ui.form.validation.Manager(); unitName.setRequired(true); costPerUnit.setRequired(true); - specificInfo.setRequired(true); unitExtraInfoCPU.setRequired(true); unitExtraInfoRAM.setRequired(true); unitExtraInfoVRAM.setRequired(true); @@ -114,8 +113,8 @@ qx.Class.define("osparc.pricing.UnitEditor", { specificInfo: { check: "String", - init: "t2.medium", - nullable: false, + init: null, + nullable: true, event: "changeSpecificInfo" }, @@ -307,7 +306,11 @@ qx.Class.define("osparc.pricing.UnitEditor", { const unitName = this.getUnitName(); const costPerUnit = this.getCostPerUnit(); const comment = this.getComment(); + const awsEc2Instances = []; const specificInfo = this.getSpecificInfo(); + if (specificInfo) { + awsEc2Instances.push(specificInfo); + } const extraInfo = {}; extraInfo["CPU"] = this.getUnitExtraInfoCPU(); extraInfo["RAM"] = this.getUnitExtraInfoRAM(); @@ -323,7 +326,7 @@ qx.Class.define("osparc.pricing.UnitEditor", { "costPerUnit": costPerUnit, "comment": comment, "specificInfo": { - "aws_ec2_instances": [specificInfo] + "aws_ec2_instances": awsEc2Instances }, "unitExtraInfo": extraInfo, "default": isDefault From 4302f5d7e2725e2123bb9e04c91bffc55f7960c2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:05:43 +0100 Subject: [PATCH 09/32] not needed --- .../client/source/class/osparc/dashboard/CardBase.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 5a8a66df13a..a919f13e311 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -900,14 +900,6 @@ qx.Class.define("osparc.dashboard.CardBase", { return control; }, - setValue: function(value) { - this.setSelected(value); - }, - - getValue: function() { - this.getSelected(); - }, - /** * Event handler for the pointer over event. */ From b0e51d55fdd827b0f8f01448f9c81f39fe7c8b87 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:13:22 +0100 Subject: [PATCH 10/32] [skip ci] minor --- .../source/class/osparc/dashboard/GridButtonItem.js | 1 - .../client/source/class/osparc/dashboard/StudyBrowser.js | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index 36f13117e2b..1825b3f684a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -189,7 +189,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { __itemSelected: function() { if (this.isItemNotClickable()) { - this.setSelected(false); return; } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c1c4339efd6..98dea1ee205 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -650,6 +650,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, __studyCardClicked: function(item, isShiftPressed) { + if (item.isItemNotClickable()) { + item.setSelected(false); + return; + } + const studiesCont = this._resourcesContainer.getFlatList(); if (isShiftPressed) { @@ -665,9 +670,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } studiesCont.setLastSelectedIndex(studiesCont.getIndex(item)); - if (item.isMultiSelectionMode()) { - item.setSelected(true); - } else { + if (!item.isMultiSelectionMode()) { const studyData = this.__getStudyData(item.getUuid(), false); this._openResourceDetails(studyData); this.resetSelection(); From 8719ce83e942a2ea576db3e4e5c8c32ed1229bed Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:25:59 +0100 Subject: [PATCH 11/32] simpler --- .../class/osparc/dashboard/GridButtonItem.js | 10 ------ .../class/osparc/dashboard/ListButtonItem.js | 34 +++++++------------ .../class/osparc/dashboard/StudyBrowser.js | 8 +---- 3 files changed, 13 insertions(+), 39 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index 1825b3f684a..537c55aa676 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -32,8 +32,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); - this.addListener("tap", this.__itemSelected, this); - this.addListener("changeSelected", this.__evalSelectedButton, this); }, @@ -187,14 +185,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { } }, - __itemSelected: function() { - if (this.isItemNotClickable()) { - return; - } - - this.setSelected(!this.getSelected()); - }, - __evalSelectedButton: function() { const selected = this.getSelected(); const menuButton = this.getChildControl("menu-button"); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js index 390019015d0..f701758eade 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js @@ -29,7 +29,7 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); - this.addListener("tap", this.__itemSelected, this); + this.addListener("changeSelected", this.__evalSelectedButton, this); }, statics: { @@ -265,38 +265,28 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { // overridden _applyMultiSelectionMode: function(value) { if (value) { - const menuButton = this.getChildControl("menu-button"); - menuButton.setVisibility("excluded"); - this.__itemSelected(); + this.__evalSelectedButton(); } else { - this.__showMenuOnly(); - } - }, - - __itemSelected: function() { - if (this.isItemNotClickable()) { this.setSelected(false); - return; } + }, + __evalSelectedButton: function() { + const selected = this.getSelected(); + const menuButton = this.getChildControl("menu-button"); + const tick = this.getChildControl("tick-selected"); + const untick = this.getChildControl("tick-unselected"); if (this.isResourceType("study") && this.isMultiSelectionMode()) { - const selected = this.getSelected(); - - const tick = this.getChildControl("tick-selected"); + menuButton.setVisibility("excluded"); tick.setVisibility(selected ? "visible" : "excluded"); - - const untick = this.getChildControl("tick-unselected"); untick.setVisibility(selected ? "excluded" : "visible"); } else { - this.__showMenuOnly(); + menuButton.setVisibility("visible"); + tick.setVisibility("excluded"); + untick.setVisibility("excluded"); } }, - __showMenuOnly: function() { - const menu = this.getChildControl("menu-button"); - this.getChildControl("menu-selection-stack").setSelection([menu]); - }, - _applyMenu: function(value, old) { const menuButton = this.getChildControl("menu-button"); if (value) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 98dea1ee205..6b457bc794d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -638,13 +638,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __configureStudyCards: function(cards) { cards.forEach(card => { card.setMultiSelectionMode(this.getMultiSelection()); - card.addListener("tap", e => { - if (card.isItemNotClickable()) { - card.setSelected(false); - } else { - this.__studyCardClicked(card, e.getNativeEvent().shiftKey); - } - }, this); + card.addListener("tap", e => this.__studyCardClicked(card, e.getNativeEvent().shiftKey), this); this._populateCardMenu(card); }); }, From 63d496b85a63d6dc8e45bc4b81a613847ca752a2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:52:39 +0100 Subject: [PATCH 12/32] minors --- .../class/osparc/dashboard/FolderButtonNew.js | 28 +++++++-------- .../osparc/dashboard/WorkspaceButtonNew.js | 36 +++++++++---------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js index 0a637e8d5b3..42bdb7128b4 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonNew.js @@ -30,7 +30,7 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", { appearance: "pb-new" }); - this.addListener("tap", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", this.__itemSelected, this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW); @@ -77,21 +77,19 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", { this.getChildControl("title"); }, - __itemSelected: function(newVal) { - if (newVal) { - const newFolder = true; - const folderEditor = new osparc.editor.FolderEditor(newFolder); - const title = this.tr("New Folder"); - const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 120); - folderEditor.addListener("createFolder", () => { - const name = folderEditor.getLabel(); - this.fireDataEvent("createFolder", { - name, - }); - win.close(); + __itemSelected: function() { + const newFolder = true; + const folderEditor = new osparc.editor.FolderEditor(newFolder); + const title = this.tr("New Folder"); + const win = osparc.ui.window.Window.popUpInWindow(folderEditor, title, 300, 120); + folderEditor.addListener("createFolder", () => { + const name = folderEditor.getLabel(); + this.fireDataEvent("createFolder", { + name, }); - folderEditor.addListener("cancel", () => win.close()); - } + win.close(); + }); + folderEditor.addListener("cancel", () => win.close()); } } }); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js index b2ba2a74eb1..aa8425858a8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonNew.js @@ -30,7 +30,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", { appearance: "pb-new" }); - this.addListener("tap", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", this.__itemSelected, this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW); @@ -54,24 +54,22 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", { }, members: { - __itemSelected: function(newVal) { - if (newVal) { - const workspaceEditor = new osparc.editor.WorkspaceEditor(); - const title = this.tr("New Workspace"); - const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 500, 500).set({ - modal: true, - clickAwayClose: false, - }); - workspaceEditor.addListener("workspaceCreated", () => this.fireEvent("workspaceCreated")); - workspaceEditor.addListener("workspaceDeleted", () => this.fireEvent("workspaceDeleted")); - workspaceEditor.addListener("workspaceUpdated", () => { - win.close(); - this.fireEvent("workspaceUpdated"); - }, this); - workspaceEditor.addListener("updateAccessRights", () => this.fireEvent("workspaceUpdated")); - win.getChildControl("close-button").addListener("tap", () => workspaceEditor.cancel()); - workspaceEditor.addListener("cancel", () => win.close()); - } + __itemSelected: function() { + const workspaceEditor = new osparc.editor.WorkspaceEditor(); + const title = this.tr("New Workspace"); + const win = osparc.ui.window.Window.popUpInWindow(workspaceEditor, title, 500, 500).set({ + modal: true, + clickAwayClose: false, + }); + workspaceEditor.addListener("workspaceCreated", () => this.fireEvent("workspaceCreated")); + workspaceEditor.addListener("workspaceDeleted", () => this.fireEvent("workspaceDeleted")); + workspaceEditor.addListener("workspaceUpdated", () => { + win.close(); + this.fireEvent("workspaceUpdated"); + }, this); + workspaceEditor.addListener("updateAccessRights", () => this.fireEvent("workspaceUpdated")); + win.getChildControl("close-button").addListener("tap", () => workspaceEditor.cancel()); + workspaceEditor.addListener("cancel", () => win.close()); } } }); From dea32d27bb260ad8e03034414a2f98e47111b042 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:53:23 +0100 Subject: [PATCH 13/32] refactor --- .../source/class/osparc/dashboard/CardBase.js | 32 +++++++++++++++++-- .../class/osparc/dashboard/GridButtonItem.js | 27 ---------------- .../class/osparc/dashboard/ListButtonItem.js | 27 ---------------- .../class/osparc/dashboard/StudyBrowser.js | 4 ++- 4 files changed, 33 insertions(+), 57 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index a919f13e311..6419ff08c41 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -33,6 +33,8 @@ qx.Class.define("osparc.dashboard.CardBase", { "pointerout", "focusout" ].forEach(e => this.addListener(e, this._onPointerOut, this)); + + this.addListener("changeSelected", this.__evalSelectedButton, this); }, events: { @@ -260,7 +262,8 @@ qx.Class.define("osparc.dashboard.CardBase", { resourceType: { check: ["study", "template", "service"], - nullable: false, + init: true, + nullable: true, event: "changeResourceType" }, @@ -379,7 +382,7 @@ qx.Class.define("osparc.dashboard.CardBase", { check: "Boolean", init: false, nullable: false, - apply: "_applyMultiSelectionMode" + apply: "__applyMultiSelectionMode" }, fetching: { @@ -458,6 +461,31 @@ qx.Class.define("osparc.dashboard.CardBase", { }); }, + __applyMultiSelectionMode: function(value) { + if (!value) { + this.setSelected(false); + } + this.__evalSelectedButton(); + }, + + __evalSelectedButton: function() { + if ("getResourceType" in this && this.isResourceType("study")) { + const menuButton = this.getChildControl("menu-button"); + const tick = this.getChildControl("tick-selected"); + const untick = this.getChildControl("tick-unselected"); + if (this.isMultiSelectionMode()) { + const selected = this.getSelected(); + menuButton.setVisibility("excluded"); + tick.setVisibility(selected ? "visible" : "excluded"); + untick.setVisibility(selected ? "excluded" : "visible"); + } else { + menuButton.setVisibility("visible"); + tick.setVisibility("excluded"); + untick.setVisibility("excluded"); + } + } + }, + __applyUuid: function(value, old) { const resourceType = this.getResourceType() || "study"; osparc.utils.Utils.setIdToWidget(this, resourceType + "BrowserListItem_" + value); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js index 537c55aa676..5b2778349a1 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GridButtonItem.js @@ -31,8 +31,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { this.base(arguments); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); - - this.addListener("changeSelected", this.__evalSelectedButton, this); }, statics: { @@ -176,31 +174,6 @@ qx.Class.define("osparc.dashboard.GridButtonItem", { return control || this.base(arguments, id); }, - // overridden - _applyMultiSelectionMode: function(value) { - if (value) { - this.__evalSelectedButton(); - } else { - this.setSelected(false); - } - }, - - __evalSelectedButton: function() { - const selected = this.getSelected(); - const menuButton = this.getChildControl("menu-button"); - const tick = this.getChildControl("tick-selected"); - const untick = this.getChildControl("tick-unselected"); - if (this.isResourceType("study") && this.isMultiSelectionMode()) { - menuButton.setVisibility("excluded"); - tick.setVisibility(selected ? "visible" : "excluded"); - untick.setVisibility(selected ? "excluded" : "visible"); - } else { - menuButton.setVisibility("visible"); - tick.setVisibility("excluded"); - untick.setVisibility("excluded"); - } - }, - // overridden _applyLastChangeDate: function(value, old) { if (value && (this.isResourceType("study") || this.isResourceType("template"))) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js index f701758eade..01557d8947c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ListButtonItem.js @@ -28,8 +28,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { this.base(arguments); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); - - this.addListener("changeSelected", this.__evalSelectedButton, this); }, statics: { @@ -262,31 +260,6 @@ qx.Class.define("osparc.dashboard.ListButtonItem", { }); }, - // overridden - _applyMultiSelectionMode: function(value) { - if (value) { - this.__evalSelectedButton(); - } else { - this.setSelected(false); - } - }, - - __evalSelectedButton: function() { - const selected = this.getSelected(); - const menuButton = this.getChildControl("menu-button"); - const tick = this.getChildControl("tick-selected"); - const untick = this.getChildControl("tick-unselected"); - if (this.isResourceType("study") && this.isMultiSelectionMode()) { - menuButton.setVisibility("excluded"); - tick.setVisibility(selected ? "visible" : "excluded"); - untick.setVisibility(selected ? "excluded" : "visible"); - } else { - menuButton.setVisibility("visible"); - tick.setVisibility("excluded"); - untick.setVisibility("excluded"); - } - }, - _applyMenu: function(value, old) { const menuButton = this.getChildControl("menu-button"); if (value) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 6b457bc794d..0d7a18a4be6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -664,7 +664,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { } studiesCont.setLastSelectedIndex(studiesCont.getIndex(item)); - if (!item.isMultiSelectionMode()) { + if (item.isMultiSelectionMode()) { + item.setSelected(!item.getSelected()); + } else { const studyData = this.__getStudyData(item.getUuid(), false); this._openResourceDetails(studyData); this.resetSelection(); From 4f6f2b596cf960d79e49e4c993312f93b39009ee Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:54:28 +0100 Subject: [PATCH 14/32] [skip ci] minor --- .../client/source/class/osparc/dashboard/CardBase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index 6419ff08c41..f7c2c9dffcb 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -469,7 +469,7 @@ qx.Class.define("osparc.dashboard.CardBase", { }, __evalSelectedButton: function() { - if ("getResourceType" in this && this.isResourceType("study")) { + if (this.isResourceType("study")) { const menuButton = this.getChildControl("menu-button"); const tick = this.getChildControl("tick-selected"); const untick = this.getChildControl("tick-unselected"); From fdc8a5c5ea1e31557009d66cef1d050c335526c7 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 16:56:19 +0100 Subject: [PATCH 15/32] [skip ci] cleanup --- .../source/class/osparc/dashboard/FolderButtonItem.js | 6 +++--- .../source/class/osparc/dashboard/WorkspaceButtonItem.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index b54d45be542..3badcacb564 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -33,7 +33,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { appearance: "pb-study" }); - this.addListener("tap", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", this.__itemSelected, this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); @@ -240,10 +240,10 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { menuButton.setMenu(menu); }, - __itemSelected: function(newVal) { + __itemSelected: function() { const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); // do not allow selecting workspace - if (studyBrowserContext !== "trash" && newVal) { + if (studyBrowserContext !== "trash") { this.fireDataEvent("folderSelected", this.getFolderId()); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index f6d6f53909f..01de40e62ca 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -33,7 +33,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { appearance: "pb-listitem" }); - this.addListener("tap", e => this.__itemSelected(e.getData()), this); + this.addListener("tap", this.__itemSelected, this); this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.ITEM); @@ -253,10 +253,10 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { }) }, - __itemSelected: function(newVal) { + __itemSelected: function() { const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); // do not allow selecting workspace - if (studyBrowserContext !== "trash" && newVal) { + if (studyBrowserContext !== "trash") { this.fireDataEvent("workspaceSelected", this.getWorkspaceId()); } }, From 7850d4ff42d9d51223769841046e9f95c9eef18b Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 17:02:39 +0100 Subject: [PATCH 16/32] rename files --- ...ToggleButtonContainer.js => CardContainer.js} | 4 ++-- ...uttonContainer.js => GroupedCardContainer.js} | 6 +++--- .../source/class/osparc/dashboard/NewStudies.js | 6 +++--- .../osparc/dashboard/ResourceContainerManager.js | 16 ++++++++-------- .../class/osparc/dashboard/StudyBrowser.js | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) rename services/static-webserver/client/source/class/osparc/dashboard/{ToggleButtonContainer.js => CardContainer.js} (96%) rename services/static-webserver/client/source/class/osparc/dashboard/{GroupedToggleButtonContainer.js => GroupedCardContainer.js} (96%) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js similarity index 96% rename from services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js rename to services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js index 258303b7532..b02ba7a1cd9 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ToggleButtonContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js @@ -8,7 +8,7 @@ /** * Container for GridButtonItems and ListButtonItems (ToggleButtons), with some convenient methods. */ -qx.Class.define("osparc.dashboard.ToggleButtonContainer", { +qx.Class.define("osparc.dashboard.CardContainer", { extend: qx.ui.container.Composite, construct: function() { @@ -46,7 +46,7 @@ qx.Class.define("osparc.dashboard.ToggleButtonContainer", { child.addListener("changeSelected", () => this.fireDataEvent("changeSelection", this.getSelection()), this); child.addListener("changeVisibility", () => this.fireDataEvent("changeVisibility", this.__getVisibles()), this); } else { - console.error("ToggleButtonContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows ToggleButton as its children."); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GroupedToggleButtonContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js similarity index 96% rename from services/static-webserver/client/source/class/osparc/dashboard/GroupedToggleButtonContainer.js rename to services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js index d5dc5505d09..10b7cf8a585 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GroupedToggleButtonContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js @@ -15,7 +15,7 @@ ************************************************************************ */ -qx.Class.define("osparc.dashboard.GroupedToggleButtonContainer", { +qx.Class.define("osparc.dashboard.GroupedCardContainer", { extend: qx.ui.core.Widget, construct: function() { @@ -118,7 +118,7 @@ qx.Class.define("osparc.dashboard.GroupedToggleButtonContainer", { const expanded = this.isExpanded(); const showAllBtn = this.__showAllButton; if (expanded) { - contentContainer = new osparc.dashboard.ToggleButtonContainer(); + contentContainer = new osparc.dashboard.CardContainer(); showAllBtn.show(); } else { const spacing = osparc.dashboard.GridButtonBase.SPACING; @@ -189,7 +189,7 @@ qx.Class.define("osparc.dashboard.GroupedToggleButtonContainer", { } this.__childVisibilityChanged(); } else { - console.error("ToggleButtonContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows ToggleButton as its children."); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/NewStudies.js b/services/static-webserver/client/source/class/osparc/dashboard/NewStudies.js index 7c01ff5c74d..0e0d92b61b6 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/NewStudies.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/NewStudies.js @@ -27,7 +27,7 @@ qx.Class.define("osparc.dashboard.NewStudies", { this._setLayout(new qx.ui.layout.VBox(10)); - const flatList = this.__flatList = new osparc.dashboard.ToggleButtonContainer(); + const flatList = this.__flatList = new osparc.dashboard.CardContainer(); [ "changeSelection", "changeVisibility" @@ -86,7 +86,7 @@ qx.Class.define("osparc.dashboard.NewStudies", { this._add(groupContainer); }); } else { - const flatList = this.__flatList = new osparc.dashboard.ToggleButtonContainer(); + const flatList = this.__flatList = new osparc.dashboard.CardContainer(); osparc.utils.Utils.setIdToWidget(flatList, listId); [ "changeSelection", @@ -138,7 +138,7 @@ qx.Class.define("osparc.dashboard.NewStudies", { }, __createGroupContainer: function(groupId, headerLabel, headerColor = "text") { - const groupContainer = new osparc.dashboard.GroupedToggleButtonContainer().set({ + const groupContainer = new osparc.dashboard.GroupedCardContainer().set({ groupId: groupId.toString(), headerLabel, headerIcon: "", diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index eebcfc98b86..5f142b52ec0 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -33,10 +33,10 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__groupedContainersList = []; if (resourceType === "study") { - const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.ToggleButtonContainer(); + const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.CardContainer(); this._add(workspacesContainer); - const foldersContainer = this.__foldersContainer = new osparc.dashboard.ToggleButtonContainer(); + const foldersContainer = this.__foldersContainer = new osparc.dashboard.CardContainer(); this._add(foldersContainer); } @@ -118,7 +118,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __groupedContainers: null, addNonResourceCard: function(card) { - if (osparc.dashboard.ToggleButtonContainer.isValidWidget(card)) { + if (osparc.dashboard.CardContainer.isValidWidget(card)) { if (this.getGroupBy()) { // it will always go to the no-group group const noGroupContainer = this.__getGroupContainer("no-group"); @@ -129,12 +129,12 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.self().sortListByPriority(this.__nonGroupedContainer); } } else { - console.error("ToggleButtonContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows ToggleButton as its children."); } }, removeNonResourceCard: function(card) { - if (osparc.dashboard.ToggleButtonContainer.isValidWidget(card)) { + if (osparc.dashboard.CardContainer.isValidWidget(card)) { if (this.getGroupBy()) { const noGroupContainer = this.__getGroupContainer("no-group"); if (noGroupContainer.getContentContainer().getChildren().indexOf(card) > -1) { @@ -144,7 +144,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__nonGroupedContainer.remove(card); } } else { - console.error("ToggleButtonContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows ToggleButton as its children."); } }, @@ -161,7 +161,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, __createGroupContainer: function(groupId, headerLabel, headerColor = "text") { - const groupContainer = new osparc.dashboard.GroupedToggleButtonContainer().set({ + const groupContainer = new osparc.dashboard.GroupedCardContainer().set({ groupId: groupId.toString(), headerLabel, headerIcon: "", @@ -317,7 +317,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, __createFlatList: function() { - const flatList = new osparc.dashboard.ToggleButtonContainer(); + const flatList = new osparc.dashboard.CardContainer(); const setContainerSpacing = () => { const spacing = this.getMode() === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING; flatList.getLayout().set({ diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 0d7a18a4be6..a4c93dbcb48 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -48,7 +48,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, events: { - "publishTemplate": "qx.event.type.Data" + "publishTemplate": "qx.event.type.Data", }, properties: { From fe218542d8ef4f2b3efae70a9dcdf94a71d3516b Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 17:03:08 +0100 Subject: [PATCH 17/32] [skip ci] rename --- .../client/source/class/osparc/dashboard/CardContainer.js | 4 ++-- .../source/class/osparc/dashboard/ResourceContainerManager.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js index b02ba7a1cd9..ee7c2bc0fc9 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js @@ -23,7 +23,7 @@ qx.Class.define("osparc.dashboard.CardContainer", { }, statics: { - isValidWidget: function(widget) { + isValidCard: function(widget) { // return (card instanceof qx.ui.form.ToggleButton); return ( widget instanceof osparc.dashboard.CardBase || @@ -38,7 +38,7 @@ qx.Class.define("osparc.dashboard.CardContainer", { // overridden add: function(child, options) { - if (this.self().isValidWidget(child)) { + if (this.self().isValidCard(child)) { if (osparc.dashboard.ResourceContainerManager.cardExists(this, child)) { return; } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 5f142b52ec0..d5cbb386f05 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -118,7 +118,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { __groupedContainers: null, addNonResourceCard: function(card) { - if (osparc.dashboard.CardContainer.isValidWidget(card)) { + if (osparc.dashboard.CardContainer.isValidCard(card)) { if (this.getGroupBy()) { // it will always go to the no-group group const noGroupContainer = this.__getGroupContainer("no-group"); @@ -134,7 +134,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { }, removeNonResourceCard: function(card) { - if (osparc.dashboard.CardContainer.isValidWidget(card)) { + if (osparc.dashboard.CardContainer.isValidCard(card)) { if (this.getGroupBy()) { const noGroupContainer = this.__getGroupContainer("no-group"); if (noGroupContainer.getContentContainer().getChildren().indexOf(card) > -1) { From 0e44843c756265da6e314224ea67f55a3af36773 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 17:06:06 +0100 Subject: [PATCH 18/32] [skip ci] renaming --- .../source/class/osparc/dashboard/CardContainer.js | 9 ++++----- .../class/osparc/dashboard/GroupedCardContainer.js | 4 ++-- .../class/osparc/dashboard/ResourceContainerManager.js | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js index ee7c2bc0fc9..047b047e8f7 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardContainer.js @@ -6,7 +6,7 @@ */ /** - * Container for GridButtonItems and ListButtonItems (ToggleButtons), with some convenient methods. + * Container for GridButtons and ListButtons (CardBase, FolderButtonBase and WorkspaceButtonBase), with some convenient methods. */ qx.Class.define("osparc.dashboard.CardContainer", { extend: qx.ui.container.Composite, @@ -24,7 +24,6 @@ qx.Class.define("osparc.dashboard.CardContainer", { statics: { isValidCard: function(widget) { - // return (card instanceof qx.ui.form.ToggleButton); return ( widget instanceof osparc.dashboard.CardBase || widget instanceof osparc.dashboard.FolderButtonBase || @@ -46,7 +45,7 @@ qx.Class.define("osparc.dashboard.CardContainer", { child.addListener("changeSelected", () => this.fireDataEvent("changeSelection", this.getSelection()), this); child.addListener("changeVisibility", () => this.fireDataEvent("changeVisibility", this.__getVisibles()), this); } else { - console.error("CardContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows CardBase as its children."); } }, @@ -76,7 +75,7 @@ qx.Class.define("osparc.dashboard.CardContainer", { /** * Sets the given button's select prop to true (checks it) and unchecks all other buttons. If the given button is not present, * every button in the container will get a unselected (unchecked). - * @param {qx.ui.form.ToggleButton} child Button that will be checked + * @param {qx.ui.form.CardBase} child Button that will be checked */ selectOne: function(child) { this.getChildren().map(button => button.setSelected(button === child)); @@ -85,7 +84,7 @@ qx.Class.define("osparc.dashboard.CardContainer", { /** * Gets the index in the container of the given button. - * @param {qx.ui.form.ToggleButton} child Button that will be checked + * @param {qx.ui.form.CardBase} child Button that will be checked */ getIndex: function(child) { return this.getChildren().findIndex(button => button === child); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js b/services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js index 10b7cf8a585..2223517302c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js @@ -176,7 +176,7 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", { // overridden add: function(child, idx) { - if (child instanceof qx.ui.form.ToggleButton) { + if (osparc.dashboard.CardContainer.isValidCard(child)) { const container = this.getContentContainer(); if (osparc.dashboard.ResourceContainerManager.cardExists(container, child)) { return; @@ -189,7 +189,7 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", { } this.__childVisibilityChanged(); } else { - console.error("CardContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows CardBase as its children."); } }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index d5cbb386f05..258916eefbb 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -129,7 +129,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.self().sortListByPriority(this.__nonGroupedContainer); } } else { - console.error("CardContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows CardBase as its children."); } }, @@ -144,7 +144,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { this.__nonGroupedContainer.remove(card); } } else { - console.error("CardContainer only allows ToggleButton as its children."); + console.error("CardContainer only allows CardBase as its children."); } }, From 44713c9cc1bd98faf512eb78cd58c98d2a802ea4 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Thu, 12 Dec 2024 17:09:51 +0100 Subject: [PATCH 19/32] prettifyMenus --- .../source/class/osparc/dashboard/FolderButtonItem.js | 6 +++--- .../source/class/osparc/dashboard/WorkspaceButtonItem.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 3badcacb564..9699e6f3c4a 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -188,9 +188,9 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { const menuButton = this.getChildControl("menu-button"); menuButton.setVisibility("visible"); - const menu = new qx.ui.menu.Menu().set({ - position: "bottom-right" - }); + const menu = new qx.ui.menu.Menu(); + menu.setPosition("bottom-right"); + osparc.utils.Utils.prettifyMenu(menu); const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); if ( diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js index 01de40e62ca..91ab3a26233 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspaceButtonItem.js @@ -181,9 +181,9 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", { const menuButton = this.getChildControl("menu-button"); menuButton.setVisibility("visible"); - const menu = new qx.ui.menu.Menu().set({ - position: "bottom-right" - }); + const menu = new qx.ui.menu.Menu(); + menu.setPosition("bottom-right"); + osparc.utils.Utils.prettifyMenu(menu); const studyBrowserContext = osparc.store.Store.getInstance().getStudyBrowserContext(); if ( From 288ef496e1aa1360726232c4b0e3126556c5cfe2 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 10:14:56 +0100 Subject: [PATCH 20/32] [skip ci] multiselection working --- .../source/class/osparc/dashboard/CardBase.js | 8 ++++-- .../class/osparc/dashboard/StudyBrowser.js | 28 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index f7c2c9dffcb..d8c6d7f4d92 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -469,11 +469,15 @@ qx.Class.define("osparc.dashboard.CardBase", { }, __evalSelectedButton: function() { - if (this.isResourceType("study")) { + if ( + this.isResourceType("study") || + this.isResourceType("template") || + this.isResourceType("service") + ) { const menuButton = this.getChildControl("menu-button"); const tick = this.getChildControl("tick-selected"); const untick = this.getChildControl("tick-unselected"); - if (this.isMultiSelectionMode()) { + if (this.isResourceType("study") && this.isMultiSelectionMode()) { const selected = this.getSelected(); menuButton.setVisibility("excluded"); tick.setVisibility(selected ? "visible" : "excluded"); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index a4c93dbcb48..eb74c16ebbc 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -649,23 +649,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { return; } - const studiesCont = this._resourcesContainer.getFlatList(); - - if (isShiftPressed) { - const lastIdx = studiesCont.getLastSelectedIndex(); - const currentIdx = studiesCont.getIndex(item); - const minMax = [Math.min(lastIdx, currentIdx), Math.max(lastIdx, currentIdx)]; - for (let i=minMax[0]; i<=minMax[1]; i++) { - const card = studiesCont.getChildren()[i]; - if (card.isVisible()) { - card.setSelected(true); - } - } - } - studiesCont.setLastSelectedIndex(studiesCont.getIndex(item)); - if (item.isMultiSelectionMode()) { item.setSelected(!item.getSelected()); + const studiesCont = this._resourcesContainer.getFlatList(); + if (isShiftPressed) { + const lastIdx = studiesCont.getLastSelectedIndex(); + const currentIdx = studiesCont.getIndex(item); + const minMax = [Math.min(lastIdx, currentIdx), Math.max(lastIdx, currentIdx)]; + for (let i=minMax[0]; i<=minMax[1]; i++) { + const card = studiesCont.getChildren()[i]; + if (card.isVisible()) { + card.setSelected(true); + } + } + } + studiesCont.setLastSelectedIndex(studiesCont.getIndex(item)); } else { const studyData = this.__getStudyData(item.getUuid(), false); this._openResourceDetails(studyData); From a51fc687c7cf2254460f6ec9d9078018713a4154 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 10:28:28 +0100 Subject: [PATCH 21/32] support null first and last name --- .../class/osparc/desktop/account/MyAccount.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js b/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js index 40a3e5b5918..1d19d05f390 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js +++ b/services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js @@ -64,17 +64,24 @@ qx.Class.define("osparc.desktop.account.MyAccount", { authData.bind("username", usernameLabel, "value"); layout.add(usernameLabel); - const name = new qx.ui.basic.Label().set({ + const nameLabel = new qx.ui.basic.Label().set({ font: "text-13", alignX: "center" }); - layout.add(name); - authData.bind("firstName", name, "value", { - converter: firstName => firstName + " " + authData.getLastName() - }); - authData.bind("lastName", name, "value", { - converter: lastName => authData.getFirstName() + " " + lastName - }); + layout.add(nameLabel); + const updateName = () => { + let name = ""; + if (authData.getFirstName()) { + name += authData.getFirstName(); + } + if (authData.getLastName()) { + name += " " + authData.getLastName(); + } + nameLabel.setValue(name); + } + updateName(); + authData.addListener("changeFirstName", updateName); + authData.addListener("changeLastName", updateName); if (authData.getRole() !== "user") { const role = authData.getFriendlyRole(); From 744d96fd23522595db1804e3cc027d810d7439eb Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 11:30:12 +0100 Subject: [PATCH 22/32] [skip ci] attachDragHandlers and attachDropHandlers --- .../osparc/dashboard/FolderButtonItem.js | 24 +++++++++++++++++++ .../class/osparc/dashboard/StudyBrowser.js | 16 +++++++++++++ 2 files changed, 40 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 9699e6f3c4a..c4822e946a8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -152,6 +152,30 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId()); this.__addMenuButton(); + + this.__attachDragHandlers(); + this.__attachDropHandlers(); + }, + + __attachDragHandlers: function() { + this.setDraggable(true); + this.addListener("dragstart", e => { + e.addType("moveFolder"); + }); + }, + + __attachDropHandlers: function() { + this.setDroppable(true); + this.addListener("dragover", e => { + if (e.supportsType("moveStudy")) { + console.log("dragover", "moveStudy", e); + return; + } else if (e.supportsType("moveFolder")) { + console.log("dragover", "moveFolder", e); + return; + } + e.preventDefault(); + }); }, __applyWorkspaceId: function(workspaceId) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index eb74c16ebbc..0361eaece8e 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -640,6 +640,22 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { card.setMultiSelectionMode(this.getMultiSelection()); card.addListener("tap", e => this.__studyCardClicked(card, e.getNativeEvent().shiftKey), this); this._populateCardMenu(card); + + this.__attachDragHandlers(card); + }); + }, + + __attachDragHandlers: function(card) { + card.setDraggable(true); + card.addListener("dragstart", e => { + // Register supported types + e.addType("moveStudy"); + + // Register supported actions + e.addAction("move"); + }); + card.addListener("droprequest", e => { + console.log("Related of droprequest: " + e.getRelatedTarget()); }); }, From 1f68f7cf68d3e8d952117a1ee6107d488d195121 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 12:44:11 +0100 Subject: [PATCH 23/32] [skip ci] minor --- .../client/source/class/osparc/file/FileLabelWithActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js index 15eec413914..35837fff2c7 100644 --- a/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js +++ b/services/static-webserver/client/source/class/osparc/file/FileLabelWithActions.js @@ -198,7 +198,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", { request .then(data => { this.fireDataEvent("fileDeleted", data); - osparc.FlashMessenger.getInstance().logAs(this.tr("File successfully deleted"), "ERROR"); + osparc.FlashMessenger.getInstance().logAs(this.tr("File successfully deleted"), "INFO"); }); } } From b5605852bd33ec69ba95013db8001aafdbc39859 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 13:02:42 +0100 Subject: [PATCH 24/32] [skip ci] pass ordingin info in drag event --- .../osparc/dashboard/FolderButtonItem.js | 25 +++++++++++++------ .../class/osparc/dashboard/StudyBrowser.js | 8 +++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index c4822e946a8..c8dfbb7bb95 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -160,21 +160,30 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { __attachDragHandlers: function() { this.setDraggable(true); this.addListener("dragstart", e => { - e.addType("moveFolder"); + e.addAction("move"); + e.addType("osparc-moveFolder"); + e.addData("osparc-moveFolder", { + "folderOrigin": this.getFolder(), + }); }); }, __attachDropHandlers: function() { this.setDroppable(true); this.addListener("dragover", e => { - if (e.supportsType("moveStudy")) { - console.log("dragover", "moveStudy", e); - return; - } else if (e.supportsType("moveFolder")) { - console.log("dragover", "moveFolder", e); - return; + let compatible = false; + if (e.supportsType("osparc-moveStudy")) { + compatible = true; + const data = e.getData("osparc-moveStudy"); + console.log("osparc-moveStudy", data["studyDataOrigin"]); + } else if (e.supportsType("osparc-moveFolder")) { + compatible = true; + const data = e.getData("osparc-moveFolder"); + console.log("osparc-moveFolder", data["folderOrigin"]); + } + if (!compatible) { + e.preventDefault(); } - e.preventDefault(); }); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 0361eaece8e..98153e7937f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -648,11 +648,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { __attachDragHandlers: function(card) { card.setDraggable(true); card.addListener("dragstart", e => { - // Register supported types - e.addType("moveStudy"); - - // Register supported actions e.addAction("move"); + e.addType("osparc-moveStudy"); + e.addData("osparc-moveStudy", { + "studyDataOrigin": card.getResourceData(), + }); }); card.addListener("droprequest", e => { console.log("Related of droprequest: " + e.getRelatedTarget()); From 3a5bd4a6a4f1b9c8a0650287c85ad8d70918b698 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 13:15:24 +0100 Subject: [PATCH 25/32] [skip ci] compatibility checks --- .../osparc/dashboard/FolderButtonItem.js | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index c8dfbb7bb95..8c1336ce1a5 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -173,13 +173,42 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { this.addListener("dragover", e => { let compatible = false; if (e.supportsType("osparc-moveStudy")) { - compatible = true; - const data = e.getData("osparc-moveStudy"); - console.log("osparc-moveStudy", data["studyDataOrigin"]); + const studyData = e.getData("osparc-moveStudy"); + // Compatibility checks: + // - My workspace + // - None + // - Shared workspace + // - write access on workspace + const workspaceId = studyData["workspaceId"]; + if (workspaceId) { + const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); + if (workspace) { + compatible = workspace.getMyAccessRights()["write"]; + } + } else { + compatible = true; + } } else if (e.supportsType("osparc-moveFolder")) { - compatible = true; const data = e.getData("osparc-moveFolder"); - console.log("osparc-moveFolder", data["folderOrigin"]); + const folder = data["folderOrigin"]; + // Compatibility checks: + // - It's not the same folder + // - My workspace + // - None + // - Shared workspace + // - write access on workspace + compatible = this.getFolder() !== folder; + const workspaceId = folder.getWorkspaceId(); + if (compatible) { + if (workspaceId) { + const workspace = osparc.store.Workspaces.getInstance().getWorkspace(workspaceId); + if (workspace) { + compatible = workspace.getMyAccessRights()["write"]; + } + } else { + compatible = true; + } + } } if (!compatible) { e.preventDefault(); From c3622d09366f3c410c10a3bf08a1635f490d96e1 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 13:51:29 +0100 Subject: [PATCH 26/32] move working --- .../osparc/dashboard/FolderButtonItem.js | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index 8c1336ce1a5..cb3cd9b4c07 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -170,10 +170,11 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { __attachDropHandlers: function() { this.setDroppable(true); + this.addListener("dragover", e => { let compatible = false; if (e.supportsType("osparc-moveStudy")) { - const studyData = e.getData("osparc-moveStudy"); + const studyData = e.getData("osparc-moveStudy")["studyDataOrigin"]; // Compatibility checks: // - My workspace // - None @@ -189,14 +190,13 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { compatible = true; } } else if (e.supportsType("osparc-moveFolder")) { - const data = e.getData("osparc-moveFolder"); - const folder = data["folderOrigin"]; // Compatibility checks: // - It's not the same folder // - My workspace // - None // - Shared workspace // - write access on workspace + const folder = e.getData("osparc-moveFolder")["folderOrigin"]; compatible = this.getFolder() !== folder; const workspaceId = folder.getWorkspaceId(); if (compatible) { @@ -211,9 +211,32 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { } } if (!compatible) { + // do not allow e.preventDefault(); } }); + + this.addListener("drop", e => { + if (e.supportsType("osparc-moveStudy")) { + const studyData = e.getData("osparc-moveStudy")["studyDataOrigin"]; + const params = { + url: { + studyId: studyData["uuid"], + folderId: this.getFolderId(), + } + }; + osparc.data.Resources.fetch("studies", "moveToFolder", params) + .then(() => { + studyData["folderId"] = this.getFolderId(); + osparc.FlashMessenger.logAs("Study moved", "INFO"); + this.fireDataEvent("studyDroppedToFolder", studyData["uuid"]); + }) + .catch(err => { + console.error(err); + osparc.FlashMessenger.logAs(err.message, "ERROR"); + }); + } + }); }, __applyWorkspaceId: function(workspaceId) { From b3833b54bce323ebd0100595b98c1026bf986197 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 16:40:37 +0100 Subject: [PATCH 27/32] wire signals --- .../osparc/dashboard/FolderButtonItem.js | 28 +++++++++---------- .../osparc/dashboard/ResourceBrowserBase.js | 10 +++++++ .../dashboard/ResourceContainerManager.js | 4 +++ .../class/osparc/dashboard/StudyBrowser.js | 11 ++++++-- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index cb3cd9b4c07..ec55b646712 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -50,6 +50,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { "untrashFolderRequested": "qx.event.type.Data", "deleteFolderRequested": "qx.event.type.Data", "changeContext": "qx.event.type.Data", + "studyToFolderRequested": "qx.event.type.Data", + "folderToFolderRequested": "qx.event.type.Data", }, properties: { @@ -219,22 +221,18 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { this.addListener("drop", e => { if (e.supportsType("osparc-moveStudy")) { const studyData = e.getData("osparc-moveStudy")["studyDataOrigin"]; - const params = { - url: { - studyId: studyData["uuid"], - folderId: this.getFolderId(), - } + const studyToFolderData = { + studyId: studyData["uuid"], + destFolderId: this.getFolderId(), }; - osparc.data.Resources.fetch("studies", "moveToFolder", params) - .then(() => { - studyData["folderId"] = this.getFolderId(); - osparc.FlashMessenger.logAs("Study moved", "INFO"); - this.fireDataEvent("studyDroppedToFolder", studyData["uuid"]); - }) - .catch(err => { - console.error(err); - osparc.FlashMessenger.logAs(err.message, "ERROR"); - }); + this.fireDataEvent("studyToFolderRequested", studyToFolderData); + } else if (e.supportsType("osparc-moveFolder")) { + const folder = e.getData("osparc-moveFolder")["folderOrigin"]; + const folderToFolderData = { + folderId: folder.getFolderId(), + destFolderId: this.getFolderId(), + }; + this.fireDataEvent("folderToFolderRequested", folderToFolderData); } }); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js index c007ca05f7e..8c3cfd23637 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js @@ -279,6 +279,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { resourcesContainer.addListener("trashFolderRequested", e => this._trashFolderRequested(e.getData())); resourcesContainer.addListener("untrashFolderRequested", e => this._untrashFolderRequested(e.getData())); resourcesContainer.addListener("deleteFolderRequested", e => this._deleteFolderRequested(e.getData())); + resourcesContainer.addListener("studyToFolderRequested", e => this._studyToFolderRequested(e.getData())); + resourcesContainer.addListener("folderToFolderRequested", e => this._folderToFolderRequested(e.getData())); resourcesContainer.addListener("folderSelected", e => { const folderId = e.getData(); this._folderSelected(folderId); @@ -524,6 +526,14 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", { throw new Error("Abstract method called!"); }, + _studyToFolderRequested: function(studyId) { + throw new Error("Abstract method called!"); + }, + + _folderToFolderRequested: function(folderId) { + throw new Error("Abstract method called!"); + }, + _workspaceSelected: function(workspaceId) { throw new Error("Abstract method called!"); }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 258916eefbb..55ac1f85697 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -83,6 +83,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { "untrashWorkspaceRequested": "qx.event.type.Data", "deleteWorkspaceRequested": "qx.event.type.Data", "changeContext": "qx.event.type.Data", + "studyToFolderRequested": "qx.event.type.Data", + "folderToFolderRequested": "qx.event.type.Data", }, statics: { @@ -429,6 +431,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { "untrashFolderRequested", "deleteFolderRequested", "changeContext", + "studyToFolderRequested", + "folderToFolderRequested", ].forEach(eName => card.addListener(eName, e => this.fireDataEvent(eName, e.getData()))); return card; }, diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 98153e7937f..384a19046be 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -635,6 +635,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, // /FOLDERS + _studyToFolderRequested: function(data) { + console.log("studyToFolderRequested", data); + }, + + _folderToFolderRequested: function(data) { + console.log("folderToFolderRequested", data); + }, + __configureStudyCards: function(cards) { cards.forEach(card => { card.setMultiSelectionMode(this.getMultiSelection()); @@ -654,9 +662,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { "studyDataOrigin": card.getResourceData(), }); }); - card.addListener("droprequest", e => { - console.log("Related of droprequest: " + e.getRelatedTarget()); - }); }, __studyCardClicked: function(item, isShiftPressed) { From 1ff160af05972f985f4b036b186030d41b5cf03f Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 16:45:05 +0100 Subject: [PATCH 28/32] [skip ci] minor --- .../class/osparc/dashboard/StudyBrowser.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 384a19046be..676e690c4f8 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -433,6 +433,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { osparc.filter.UIFilterController.dispatch("searchBarFilter"); }, + _studyToFolderRequested: function(data) { + console.log("studyToFolderRequested", data); + }, + // WORKSPACES __reloadWorkspaceCards: function() { this._resourcesContainer.setWorkspacesToList(this.__workspacesList); @@ -595,6 +599,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { moveFolderTo.addListener("cancel", () => win.close()); }, + _folderToFolderRequested: function(data) { + console.log("folderToFolderRequested", data); + }, + _trashFolderRequested: function(folderId) { osparc.store.Folders.getInstance().trashFolder(folderId, this.getCurrentWorkspaceId()) .then(() => { @@ -635,14 +643,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, // /FOLDERS - _studyToFolderRequested: function(data) { - console.log("studyToFolderRequested", data); - }, - - _folderToFolderRequested: function(data) { - console.log("folderToFolderRequested", data); - }, - __configureStudyCards: function(cards) { cards.forEach(card => { card.setMultiSelectionMode(this.getMultiSelection()); From 10ebce48b5cac6e6460637a7e84c53e2925d4bce Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 16:58:38 +0100 Subject: [PATCH 29/32] move study working --- .../osparc/dashboard/FolderButtonItem.js | 2 +- .../class/osparc/dashboard/StudyBrowser.js | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js index ec55b646712..9c9de365572 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/FolderButtonItem.js @@ -222,7 +222,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", { if (e.supportsType("osparc-moveStudy")) { const studyData = e.getData("osparc-moveStudy")["studyDataOrigin"]; const studyToFolderData = { - studyId: studyData["uuid"], + studyData, destFolderId: this.getFolderId(), }; this.fireDataEvent("studyToFolderRequested", studyToFolderData); diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 676e690c4f8..bd962e0d636 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -433,10 +433,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { osparc.filter.UIFilterController.dispatch("searchBarFilter"); }, - _studyToFolderRequested: function(data) { - console.log("studyToFolderRequested", data); - }, - // WORKSPACES __reloadWorkspaceCards: function() { this._resourcesContainer.setWorkspacesToList(this.__workspacesList); @@ -600,7 +596,13 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }, _folderToFolderRequested: function(data) { - console.log("folderToFolderRequested", data); + const { + folderId, + destFolderId, + } = data; + osparc.store.Folders.getInstance().moveFolderToFolder(folderId, destFolderId) + .then(() => this.__reloadFolders()) + .catch(err => console.error(err)); }, _trashFolderRequested: function(folderId) { @@ -1229,7 +1231,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const studyData = button.getResourceData(); this.__moveStudyToWorkspace(studyData, destWorkspaceId) // first move to workspace .then(() => this.__moveStudyToFolder(studyData, destFolderId)) // then move to folder - .then(() => this.__removeFromStudyList(studyData["uuid"])) .catch(err => { console.error(err); osparc.FlashMessenger.logAs(err.message, "ERROR"); @@ -1649,7 +1650,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const moveStudy = () => { this.__moveStudyToWorkspace(studyData, destWorkspaceId) // first move to workspace .then(() => this.__moveStudyToFolder(studyData, destFolderId)) // then move to folder - .then(() => this.__removeFromStudyList(studyData["uuid"])) .catch(err => { console.error(err); osparc.FlashMessenger.logAs(err.message, "ERROR"); @@ -1703,6 +1703,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }; return osparc.data.Resources.fetch("studies", "moveToFolder", params) .then(() => studyData["folderId"] = destFolderId) + .then(() => this.__removeFromStudyList(studyData["uuid"])); + }, + + _studyToFolderRequested: function(data) { + const { + studyData, + destFolderId, + } = data; + this.__moveStudyToFolder(studyData, destFolderId) .catch(err => { console.error(err); osparc.FlashMessenger.logAs(err.message, "ERROR"); From 451f3bb58c46f5f0696c5d5b1d054e523e8d9898 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 18:28:29 +0100 Subject: [PATCH 30/32] minor --- .../client/source/class/osparc/dashboard/CardBase.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index d8c6d7f4d92..c9171ebc2e2 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -470,9 +470,9 @@ qx.Class.define("osparc.dashboard.CardBase", { __evalSelectedButton: function() { if ( - this.isResourceType("study") || - this.isResourceType("template") || - this.isResourceType("service") + this.hasChildControl("menu-button") && + this.hasChildControl("tick-selected") && + this.hasChildControl("tick-unselected") ) { const menuButton = this.getChildControl("menu-button"); const tick = this.getChildControl("tick-selected"); From 884f8338180d88767aa0210dc0b83c70c578e01b Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 18:28:42 +0100 Subject: [PATCH 31/32] not needed --- .../client/source/class/osparc/service/ServiceListItem.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/service/ServiceListItem.js b/services/static-webserver/client/source/class/osparc/service/ServiceListItem.js index c970c2df3a9..dc239da7c93 100644 --- a/services/static-webserver/client/source/class/osparc/service/ServiceListItem.js +++ b/services/static-webserver/client/source/class/osparc/service/ServiceListItem.js @@ -35,14 +35,6 @@ qx.Class.define("osparc.service.ServiceListItem", { } this.subscribeToFilterGroup("serviceCatalog"); - - /** - * The idea here is to show some extra options when a service is selected: - * - Version selection - * - Pricing unit selection if applies - */ - // But the toggle button consumes all the events, I believe that the trick is to use the anonymous property - // this.addListener("changeValue", e => this.__itemSelected(e.getData())); }, properties: { From afe48e5af0fd0893e39dfdd5473644c578676c4e Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Fri, 13 Dec 2024 18:30:54 +0100 Subject: [PATCH 32/32] list items are not toggle buttons --- .../class/osparc/service/ServiceList.js | 59 +++++++++---------- .../class/osparc/workbench/ServiceCatalog.js | 2 +- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/service/ServiceList.js b/services/static-webserver/client/source/class/osparc/service/ServiceList.js index 06ca9bca1e7..72d1164f6dd 100644 --- a/services/static-webserver/client/source/class/osparc/service/ServiceList.js +++ b/services/static-webserver/client/source/class/osparc/service/ServiceList.js @@ -36,7 +36,7 @@ qx.Class.define("osparc.service.ServiceList", { }, events: { - "changeValue": "qx.event.type.Data", + "changeSelected": "qx.event.type.Data", "serviceAdd": "qx.event.type.Data" }, @@ -53,33 +53,26 @@ qx.Class.define("osparc.service.ServiceList", { }, members: { - __buttonGroup: null, __filterGroup: null, _applyModel: function(model) { this._removeAll(); - const group = this.__buttonGroup = new qx.ui.form.RadioGroup().set({ - allowEmptySelection: true - }); + this.__serviceListItem = []; model.toArray().forEach(service => { - const button = new osparc.service.ServiceListItem(service); + const item = new osparc.service.ServiceListItem(service); if (this.__filterGroup !== null) { - button.subscribeToFilterGroup(this.__filterGroup); + item.subscribeToFilterGroup(this.__filterGroup); } - group.add(button); - this._add(button); - button.addListener("dbltap", () => { - this.fireDataEvent("serviceAdd", button.getService()); - }, this); - button.addListener("keypress", e => { + this._add(item); + item.addListener("tap", () => this.__setSelected(item)); + item.addListener("dbltap", () => this.fireDataEvent("serviceAdd", item.getService()), this); + item.addListener("keypress", e => { if (e.getKeyIdentifier() === "Enter") { - this.fireDataEvent("serviceAdd", button.getService()); + this.fireDataEvent("serviceAdd", item.getService()); } }, this); }); - - group.addListener("changeValue", e => this.dispatchEvent(e.clone()), this); }, /** @@ -88,37 +81,41 @@ qx.Class.define("osparc.service.ServiceList", { * @return Returns the model of the selected service or null if selection is empty. */ getSelected: function() { - if (this.__buttonGroup && this.__buttonGroup.getSelection().length) { - return this.__buttonGroup.getSelection()[0].getService(); + const items = this._getChildren(); + for (let i=0; i item.setSelected(item === selectedItem)); + this.fireDataEvent("changeSelected", selectedItem); + }, + /** * Function checking if the selection is empty or not * * @return True if no item is selected, false if there one or more item selected. */ isSelectionEmpty: function() { - if (this.__buttonGroup == null) { - return true; - } - return this.__buttonGroup.getSelection().length === 0; + const selecetedItems = this._getChildren().filter(item => item.getSelected()); + selecetedItems.length === 0; }, /** * Function that selects the first visible button. */ selectFirstVisible: function() { - if (this._hasChildren()) { - const buttons = this._getChildren(); - let current = buttons[0]; - let i = 1; - while (i { + this.__serviceList.addListener("changeSelected", e => { if (e.getData() && e.getData().getService()) { const selectedService = e.getData().getService(); this.__changedSelection(selectedService.getKey());