Skip to content

Commit

Permalink
fix selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Aug 1, 2024
1 parent 90120ce commit 5b5d0bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
17 changes: 15 additions & 2 deletions lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,29 @@ export class GaqFlagsOverviewModel extends OverviewPageModel {
* Select detectors from selection model which are in GAQ detectors list
* @return {void}
*/
updateDetectorSelectionModel() {
pickCurrentGaqDetectors() {
this._gaqDetectors$.getCurrent().match({
Success: (gaqDetectors) => this._gaqDetectorPickerModel.options.match({
Success: () => gaqDetectors.forEach(({ id }) => this._gaqDetectorPickerModel.select(id)),
Success: () => {
if (!this._currentGaqDetectorsSelected) {
gaqDetectors.forEach(({ id }) => this._gaqDetectorPickerModel.select(id));
this._currentGaqDetectorsSelected = true;
}
},
Other: () => {},
}),
Other: () => {},
});
}

/**
* Set that current GAQ detector will need to be selected in detectors picker model
* @return {void}
*/
dismissGaqDetectorSelectionInPickerModel() {
this._currentGaqDetectorsSelected = false;
}

/**
* Fetch data pass data which QC flags are fetched
* @return {Promise<void>} promise
Expand Down
5 changes: 2 additions & 3 deletions lib/public/views/QcFlags/GaqFlags/gaqDetectectorSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { picker } from '../../../components/common/selection/picker/picker.js';
*/
const selectionForm = (gaqOverviewModel, gaqDetectors, modalHandler) => {
const { gaqDetectorPickerModel } = gaqOverviewModel;
gaqOverviewModel.pickCurrentGaqDetectors();

return [
picker(
Expand Down Expand Up @@ -56,11 +57,9 @@ const errorDisplay = () => h('.danger', 'Data fetching failed');
* @return {Component} Return the view of the inputs
*/
const gaqDetectorsSelectionModal = (gaqOverviewModel, modalHandler) => {
gaqOverviewModel.updateDetectorSelectionModel();

const { gaqDetectorPickerModel } = gaqOverviewModel;

return h('div#export-runs-modal', [
return h('div#gaq-detector-selection-modal', { onremove: () => gaqOverviewModel.dismissGaqDetectorSelectionInPickerModel() }, [
h('h2', 'GAQ detectors selection'),
gaqDetectorPickerModel.options.match({
NotAsked: () => errorDisplay(),
Expand Down

0 comments on commit 5b5d0bd

Please sign in to comment.