Skip to content

Commit

Permalink
🐛🎨 [Frontend] Various bug fixes: new tag from Study, Checkpoint viewe…
Browse files Browse the repository at this point in the history
…r, Leave study message (#6878)
  • Loading branch information
odeimaiz authored Dec 4, 2024
1 parent 81c8ea0 commit 74dd164
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
if (resourceType === "study") {
const workspacesContainer = this.__workspacesContainer = new osparc.dashboard.ToggleButtonContainer();
this._add(workspacesContainer);
workspacesContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded");

const foldersContainer = this.__foldersContainer = new osparc.dashboard.ToggleButtonContainer();
this._add(foldersContainer);
foldersContainer.setVisibility(osparc.utils.DisabledPlugins.isFoldersEnabled() ? "visible" : "excluded");
}

const nonGroupedContainer = this.__nonGroupedContainer = this.__createFlatList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
__serviceTypeButtons: null,

__buildLayout: function() {
if (this.__resourceType === "study" && osparc.utils.DisabledPlugins.isFoldersEnabled()) {
if (this.__resourceType === "study") {
this._add(this.__createWorkspacesAndFoldersTree());
this._add(this.__createTrashBin());
} else {
Expand Down Expand Up @@ -104,7 +104,8 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
value: false,
appearance: "filter-toggle-button",
label: this.tr("Trash"),
icon: "@FontAwesome5Solid/trash/18",
icon: "@FontAwesome5Solid/trash/16",
paddingLeft: 10, // align it with the context
});
trashButton.addListener("changeValue", e => {
const trashEnabled = e.getData();
Expand Down Expand Up @@ -221,11 +222,11 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {

/* TAGS */
__createTagsFilterLayout: function() {
const layout = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
const layout = new qx.ui.container.Composite(new qx.ui.layout.VBox(2));
osparc.utils.Utils.setIdToWidget(layout, this.__resourceType + "-tagsFilter");

this.__populateTags(layout, []);
osparc.store.Store.getInstance().addListener("changeTags", () => {
osparc.store.Tags.getInstance().addListener("tagsChanged", () => {
this.__populateTags(layout, this.__getSelectedTagIds());
}, this);

Expand All @@ -242,7 +243,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
this.__tagButtons = [];
layout.removeAll();
osparc.store.Tags.getInstance().getTags().forEach((tag, idx) => {
const button = new qx.ui.form.ToggleButton(null, "@FontAwesome5Solid/tag/18");
const button = new qx.ui.form.ToggleButton(null, "@FontAwesome5Solid/tag/16");
button.id = tag.getTagId();
tag.bind("name", button, "label");
tag.bind("color", button.getChildControl("icon"), "textColor");
Expand All @@ -266,7 +267,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {


if (this.__tagButtons.length > maxTags) {
const showAllButton = new qx.ui.form.Button(this.tr("All Tags..."), "@FontAwesome5Solid/tags/20");
const showAllButton = new qx.ui.form.Button(this.tr("All Tags..."), "@FontAwesome5Solid/tags/16");
showAllButton.set({
appearance: "filter-toggle-button"
});
Expand All @@ -284,6 +285,20 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
});
layout.add(showAllButton);
}

const editTagsButton = new qx.ui.form.Button(this.tr("Edit Tags..."), "@FontAwesome5Solid/pencil-alt/14");
editTagsButton.set({
appearance: "filter-toggle-button"
});
editTagsButton.addListener("execute", () => {
const preferencesWindow = osparc.desktop.preferences.PreferencesWindow.openWindow();
preferencesWindow.openTags();
});
layout.add(editTagsButton);

if (this.__resourceType === "study") {
layout.getChildren().forEach(item => item.setPaddingLeft(10)); // align them with the context
}
},
/* /TAGS */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {

__addClassifiers: function(menuButton) {
const classifiers = osparc.store.Store.getInstance().getClassifiers();
menuButton.setVisibility(classifiers.length ? "visible" : "excluded");
if (classifiers.length) {
menuButton.setVisibility(classifiers && classifiers.length ? "visible" : "excluded");
if (classifiers && classifiers.length) {
const classifiersMenu = new qx.ui.menu.Menu();
classifiers.forEach(classifier => {
const classifierButton = new qx.ui.menu.Button(classifier.display_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
__reloadWorkspaces: function() {
if (
!osparc.auth.Manager.getInstance().isLoggedIn() ||
!osparc.utils.DisabledPlugins.isFoldersEnabled() ||
this.getCurrentContext() === "studiesAndFolders" ||
this.getCurrentContext() === "search" || // not yet implemented for workspaces
this.__loadingWorkspaces
Expand Down Expand Up @@ -212,7 +211,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
__reloadFolders: function() {
if (
!osparc.auth.Manager.getInstance().isLoggedIn() ||
!osparc.utils.DisabledPlugins.isFoldersEnabled() ||
this.getCurrentContext() === "workspaces" ||
this.__loadingFolders
) {
Expand Down Expand Up @@ -991,11 +989,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
_createLayout: function() {
this._createSearchBar();

if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
const header = this.__header = new osparc.dashboard.StudyBrowserHeader();
this.__header.addListener("emptyTrashRequested", () => this.__emptyTrash(), this);
this._addToLayout(header);
}
const header = this.__header = new osparc.dashboard.StudyBrowserHeader();
this.__header.addListener("emptyTrashRequested", () => this.__emptyTrash(), this);
this._addToLayout(header);

this._createResourcesLayout("studiesList");

Expand Down Expand Up @@ -1069,112 +1065,108 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
},

__connectContexts: function() {
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
const header = this.__header;
header.addListener("locationChanged", () => {
const workspaceId = header.getCurrentWorkspaceId();
const folderId = header.getCurrentFolderId();
this._changeContext("studiesAndFolders", workspaceId, folderId);
}, this);
const header = this.__header;
header.addListener("locationChanged", () => {
const workspaceId = header.getCurrentWorkspaceId();
const folderId = header.getCurrentFolderId();
this._changeContext("studiesAndFolders", workspaceId, folderId);
}, this);

const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree();
workspacesAndFoldersTree.addListener("locationChanged", e => {
const context = e.getData();
const workspaceId = context["workspaceId"];
if (workspaceId === -1) {
this._changeContext("workspaces");
} else {
const folderId = context["folderId"];
this._changeContext("studiesAndFolders", workspaceId, folderId);
}
}, this);
const workspacesAndFoldersTree = this._resourceFilter.getWorkspacesAndFoldersTree();
workspacesAndFoldersTree.addListener("locationChanged", e => {
const context = e.getData();
const workspaceId = context["workspaceId"];
if (workspaceId === -1) {
this._changeContext("workspaces");
} else {
const folderId = context["folderId"];
this._changeContext("studiesAndFolders", workspaceId, folderId);
}
}, this);

this._resourceFilter.addListener("trashContext", () => {
this._changeContext("trash");
});
this._resourceFilter.addListener("trashContext", () => {
this._changeContext("trash");
});

this._searchBarFilter.addListener("filterChanged", e => {
const filterData = e.getData();
if (filterData.text) {
this._changeContext("search");
} else {
const workspaceId = this.getCurrentWorkspaceId();
const folderId = this.getCurrentFolderId();
this._changeContext("studiesAndFolders", workspaceId, folderId);
}
});
}
this._searchBarFilter.addListener("filterChanged", e => {
const filterData = e.getData();
if (filterData.text) {
this._changeContext("search");
} else {
const workspaceId = this.getCurrentWorkspaceId();
const folderId = this.getCurrentFolderId();
this._changeContext("studiesAndFolders", workspaceId, folderId);
}
});
},

_changeContext: function(context, workspaceId = null, folderId = null) {
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
if (
context !== "search" && // reload studies for a new search
context === this.getCurrentContext() &&
workspaceId === this.getCurrentWorkspaceId() &&
folderId === this.getCurrentFolderId()
) {
// didn't really change
return;
}

osparc.store.Store.getInstance().setStudyBrowserContext(context);
this.set({
currentContext: context,
currentWorkspaceId: workspaceId,
currentFolderId: folderId,
});
this.resetSelection();
this.setMultiSelection(false);
if (
context !== "search" && // reload studies for a new search
context === this.getCurrentContext() &&
workspaceId === this.getCurrentWorkspaceId() &&
folderId === this.getCurrentFolderId()
) {
// didn't really change
return;
}

// reset lists
this.__setWorkspacesToList([]);
this.__setFoldersToList([]);
this._resourcesList = [];
this._resourcesContainer.setResourcesToList(this._resourcesList);
this._resourcesContainer.reloadCards("studies");

this._toolbar.show();
switch (this.getCurrentContext()) {
case "studiesAndFolders":
this._searchBarFilter.resetFilters();
this.__reloadFolders();
this._loadingResourcesBtn.setFetching(false);
this.invalidateStudies();
this.__reloadStudies();
break;
case "workspaces":
this._toolbar.exclude();
this._searchBarFilter.resetFilters();
this.__reloadWorkspaces();
break;
case "search":
this.__reloadWorkspaces();
this.__reloadFolders();
this._loadingResourcesBtn.setFetching(false);
this.invalidateStudies();
this.__reloadStudies();
break;
case "trash":
this._searchBarFilter.resetFilters();
this.__reloadWorkspaces();
this.__reloadFolders();
this._loadingResourcesBtn.setFetching(false);
this.invalidateStudies();
this.__reloadStudies();
break;
}
osparc.store.Store.getInstance().setStudyBrowserContext(context);
this.set({
currentContext: context,
currentWorkspaceId: workspaceId,
currentFolderId: folderId,
});
this.resetSelection();
this.setMultiSelection(false);

// notify header
const header = this.__header;
header.set({
currentWorkspaceId: workspaceId,
currentFolderId: folderId,
});
// reset lists
this.__setWorkspacesToList([]);
this.__setFoldersToList([]);
this._resourcesList = [];
this._resourcesContainer.setResourcesToList(this._resourcesList);
this._resourcesContainer.reloadCards("studies");

// notify Filters on the left
this._resourceFilter.contextChanged(context, workspaceId, folderId);
this._toolbar.show();
switch (this.getCurrentContext()) {
case "studiesAndFolders":
this._searchBarFilter.resetFilters();
this.__reloadFolders();
this._loadingResourcesBtn.setFetching(false);
this.invalidateStudies();
this.__reloadStudies();
break;
case "workspaces":
this._toolbar.exclude();
this._searchBarFilter.resetFilters();
this.__reloadWorkspaces();
break;
case "search":
this.__reloadWorkspaces();
this.__reloadFolders();
this._loadingResourcesBtn.setFetching(false);
this.invalidateStudies();
this.__reloadStudies();
break;
case "trash":
this._searchBarFilter.resetFilters();
this.__reloadWorkspaces();
this.__reloadFolders();
this._loadingResourcesBtn.setFetching(false);
this.invalidateStudies();
this.__reloadStudies();
break;
}

// notify header
const header = this.__header;
header.set({
currentWorkspaceId: workspaceId,
currentFolderId: folderId,
});

// notify Filters on the left
this._resourceFilter.contextChanged(context, workspaceId, folderId);
},

__addSortByButton: function() {
Expand Down Expand Up @@ -1560,13 +1552,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
menu.add(billingsSettingsButton);
}

if (writeAccess && osparc.utils.DisabledPlugins.isFoldersEnabled()) {
menu.addSeparator();
menu.addSeparator();

const moveToButton = this.__getMoveStudyToMenuButton(studyData);
if (moveToButton) {
menu.add(moveToButton);
}
const moveToButton = this.__getMoveStudyToMenuButton(studyData);
if (moveToButton) {
menu.add(moveToButton);
}

if (deleteAccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ qx.Class.define("osparc.data.Resources", {
},
moveToWorkspace: {
method: "POST",
url: statics.API + "/folders/{folderId}/folders/{workspaceId}:move"
url: statics.API + "/folders/{folderId}/workspaces/{workspaceId}:move"
},
trash: {
method: "POST",
Expand Down
Loading

0 comments on commit 74dd164

Please sign in to comment.