Skip to content

Commit 542073c

Browse files
committed
refactor and "Existing tags"
1 parent 0b8ea9d commit 542073c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
106106
this.getChildControl("filters-spacer");
107107
this.getChildControl("shared-with-layout");
108108
this.getChildControl("tags-layout");
109+
this.__populateTags();
110+
osparc.store.Tags.getInstance().addListener("tagsChanged", () => this.__populateTags(), this);
109111
break;
110112
case "service":
111113
this.getChildControl("filters-spacer");
@@ -371,12 +373,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
371373
__createTagsFilterLayout: function() {
372374
const tagsLayout = new qx.ui.container.Composite(new qx.ui.layout.VBox(2));
373375
osparc.utils.Utils.setIdToWidget(tagsLayout, this.__resourceType + "-tagsFilter");
374-
375-
this.__populateTags(tagsLayout, []);
376-
osparc.store.Tags.getInstance().addListener("tagsChanged", () => {
377-
this.__populateTags(tagsLayout, this.__getSelectedTagIds());
378-
}, this);
379-
380376
return tagsLayout;
381377
},
382378

@@ -385,10 +381,12 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
385381
return selectedTagIds;
386382
},
387383

388-
__populateTags: function(tagsLayout, selectedTagIds) {
384+
__populateTags: function() {
385+
const selectedTagIds = this.__getSelectedTagIds();
386+
const tagsLayout = this.getChildControl("tags-layout");
387+
tagsLayout.removeAll();
389388
const maxTags = 10;
390389
this.__tagButtons = [];
391-
tagsLayout.removeAll();
392390
osparc.store.Tags.getInstance().getTags().forEach((tag, idx) => {
393391
const button = new qx.ui.form.ToggleButton(null, "@FontAwesome5Solid/tag/16");
394392
button.id = tag.getTagId();

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ qx.Class.define("osparc.dashboard.TutorialBrowser", {
124124

125125
if (this._resourceFilter) {
126126
this._resourceFilter.getChildControl("tags-layout").setVisibility(groupBy === "tags" ? "visible" : "excluded");
127+
128+
if (groupBy === "tags") {
129+
const existingTags = new Set();
130+
this._resourcesList.forEach(template => {
131+
(template["tags"] || []).forEach(tagId => existingTags.add(tagId));
132+
});
133+
console.log("Existing tags", existingTags);
134+
// this._resourceFilter.setSelectedTagIds(Array.from(existingTags));
135+
}
127136
}
128137
},
129138

0 commit comments

Comments
 (0)