Skip to content

Commit 4e46d66

Browse files
authored
Dashboard UI/UX: Study multi-selection (ITISFoundation#2852)
1 parent fed79c9 commit 4e46d66

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

services/web/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
120120
const topBar = this.__createTopBar(resourceType);
121121
resourcesLayout.add(topBar);
122122

123-
const secondaryBar = this._secondaryBar = new qx.ui.container.Composite(new qx.ui.layout.HBox());
123+
const secondaryBar = this._secondaryBar = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
124124
resourcesLayout.add(secondaryBar);
125125

126126
const resourcesContainer = this._resourcesContainer = this.__createResourcesContainer();

services/web/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
3939
"updateTemplates": "qx.event.type.Event"
4040
},
4141

42+
properties: {
43+
multiSelection: {
44+
check: "Boolean",
45+
init: false,
46+
nullable: false,
47+
event: "changeMultiSelection",
48+
apply: "__applyMultiSelection"
49+
}
50+
},
51+
4252
members: {
4353
__studies: null,
4454
__newStudyBtn: null,
@@ -131,9 +141,22 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
131141

132142
const importStudyButton = this.__createImportButton();
133143
this._secondaryBar.add(importStudyButton);
144+
importStudyButton.exclude();
145+
osparc.utils.DisabledPlugins.isImportDisabled()
146+
.then(isDisabled => {
147+
importStudyButton.setVisibility(isDisabled ? "excluded" : "visible");
148+
});
149+
150+
this._secondaryBar.add(new qx.ui.core.Spacer(), {
151+
flex: 1
152+
});
153+
134154
const studiesDeleteButton = this.__createDeleteButton(false);
135155
this._secondaryBar.add(studiesDeleteButton);
136156

157+
const selectStudiesButton = this.__createSelectButton();
158+
this._secondaryBar.add(selectStudiesButton);
159+
137160
osparc.utils.Utils.setIdToWidget(this._resourcesContainer, "studiesList");
138161

139162
const newStudyButton = this.__createNewStudyButton();
@@ -142,19 +165,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
142165
const loadingStudiesBtn = this._createLoadMoreButton("studiesLoading");
143166
this._resourcesContainer.add(loadingStudiesBtn);
144167

145-
this._resourcesContainer.addListener("changeSelection", e => {
146-
const nSelected = e.getData().length;
147-
this._resourcesContainer.getChildren().forEach(studyItem => {
148-
if (osparc.dashboard.ResourceBrowserBase.isCardButtonItem(studyItem)) {
149-
studyItem.setMultiSelectionMode(Boolean(nSelected));
150-
}
151-
});
152-
}, this);
153-
this._resourcesContainer.bind("selection", this.__newStudyBtn, "enabled", {
154-
converter: selection => !selection.length
168+
this.bind("multiSelection", this.__newStudyBtn, "enabled", {
169+
converter: val => !val
155170
});
156-
this._resourcesContainer.bind("selection", importStudyButton, "enabled", {
157-
converter: selection => !selection.length
171+
this.bind("multiSelection", importStudyButton, "enabled", {
172+
converter: val => !val
158173
});
159174
this._resourcesContainer.bind("selection", studiesDeleteButton, "visibility", {
160175
converter: selection => selection.length ? "visible" : "excluded"
@@ -249,6 +264,29 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
249264
return deleteButton;
250265
},
251266

267+
__createSelectButton: function() {
268+
const selectButton = new qx.ui.form.ToggleButton().set({
269+
marginRight: 8
270+
});
271+
selectButton.bind("value", this, "multiSelection");
272+
selectButton.bind("value", selectButton, "label", {
273+
converter: val => val ? this.tr("Cancel Selection") : this.tr("Select Studies")
274+
});
275+
this.bind("multiSelection", selectButton, "value");
276+
return selectButton;
277+
},
278+
279+
__applyMultiSelection: function(value) {
280+
this._resourcesContainer.getChildren().forEach(studyItem => {
281+
if (osparc.dashboard.ResourceBrowserBase.isCardButtonItem(studyItem)) {
282+
studyItem.setMultiSelectionMode(value);
283+
if (value === false) {
284+
studyItem.setValue(false);
285+
}
286+
}
287+
});
288+
},
289+
252290
__getStudyAndStart: function(loadStudyId) {
253291
const params = {
254292
url: {
@@ -295,6 +333,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
295333
const commandEsc = new qx.ui.command.Command("Esc");
296334
commandEsc.addListener("execute", e => {
297335
this.resetSelection();
336+
this.setMultiSelection(false);
298337
});
299338
osparc.store.Store.getInstance().addListener("changeTags", () => {
300339
this.invalidateStudies();
@@ -427,11 +466,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
427466
position: "bottom-right"
428467
});
429468

430-
const selectButton = this.__getSelectMenuButton(item, studyData);
431-
if (selectButton) {
432-
menu.add(selectButton);
433-
}
434-
435469
const renameStudyButton = this.__getRenameStudyMenuButton(studyData);
436470
menu.add(renameStudyButton);
437471

@@ -453,15 +487,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
453487
return menu;
454488
},
455489

456-
__getSelectMenuButton: function(item) {
457-
const selectButton = new qx.ui.menu.Button(this.tr("Select"));
458-
selectButton.addListener("execute", () => {
459-
item.setValue(true);
460-
this._resourcesContainer.setLastSelectedItem(item);
461-
}, this);
462-
return selectButton;
463-
},
464-
465490
__getRenameStudyMenuButton: function(studyData) {
466491
const renameButton = new qx.ui.menu.Button(this.tr("Rename"));
467492
renameButton.addListener("execute", () => {
@@ -550,8 +575,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
550575

551576
__itemClicked: function(item, isShiftPressed) {
552577
const studiesCont = this._resourcesContainer;
553-
const selected = item.getValue();
554-
const selection = studiesCont.getSelection();
555578

556579
if (isShiftPressed) {
557580
const lastIdx = studiesCont.getLastSelectedIndex();
@@ -566,7 +589,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
566589
}
567590
studiesCont.setLastSelectedIndex(studiesCont.getIndex(item));
568591

569-
if (selected && selection.length === 1) {
592+
if (!item.isMultiSelectionMode()) {
570593
const studyData = this.__getStudyData(item.getUuid(), false);
571594
this._startStudy(studyData);
572595
}

services/web/client/source/class/osparc/utils/DisabledPlugins.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ qx.Class.define("osparc.utils.DisabledPlugins", {
2525
statics: {
2626
EXPORT: "WEBSERVER_EXPORTER",
2727
DUPLICATE: "WEBSERVER_EXPORTER",
28+
IMPORT: "WEBSERVER_EXPORTER",
2829
SCICRUNCH: "WEBSERVER_SCICRUNCH",
2930
VERSION_CONTROL: "WEBSERVER_VERSION_CONTROL",
3031
META_MODELING: "WEBSERVER_META_MODELING",
@@ -37,6 +38,10 @@ qx.Class.define("osparc.utils.DisabledPlugins", {
3738
return this.self().isPluginDisabled(this.self().EXPORT);
3839
},
3940

41+
isImportDisabled: function() {
42+
return this.self().isPluginDisabled(this.self().EXPORT);
43+
},
44+
4045
isScicrunchDisabled: function() {
4146
return this.self().isPluginDisabled(this.self().SCICRUNCH);
4247
},

0 commit comments

Comments
 (0)