Skip to content

Commit bdba964

Browse files
author
GuustMetz
committed
feat: replace qcFlagType bad filter with radioButtonFilterModel
1 parent 30d7b39 commit bdba964

2 files changed

Lines changed: 36 additions & 7 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { SelectionModel } from '../../common/selection/SelectionModel.js';
15+
16+
/**
17+
* Model for managing a radiobutton view and state
18+
*/
19+
export class RadioButtonFilterModel extends SelectionModel {
20+
/**
21+
* Constructor
22+
*
23+
* @param {SelectionOption[]} [availableOptions] the list of possible operators
24+
* @param {function} [setDefault] function that selects the default from the list of available options. Selects first entry by default
25+
*/
26+
constructor(availableOptions, setDefault = (options) => [options[0]]) {
27+
super({
28+
availableOptions,
29+
defaultSelection: setDefault(availableOptions),
30+
multiple: false,
31+
allowEmpty: false,
32+
});
33+
}
34+
}

lib/public/views/QcFlagTypes/Overview/QcFlagTypesOverviewModel.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
import { TextTokensFilterModel } from '../../../components/Filters/common/filters/TextTokensFilterModel.js';
1515
import { OverviewPageModel } from '../../../models/OverviewModel.js';
16-
import { SelectionModel } from '../../../components/common/selection/SelectionModel.js';
1716
import { buildUrl } from '/js/src/index.js';
1817
import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js';
18+
import { RadioButtonFilterModel } from '../../../components/Filters/common/RadioButtonFilterModel.js';
1919

2020
/**
2121
* QcFlagTypesOverviewModel
@@ -30,12 +30,7 @@ export class QcFlagTypesOverviewModel extends OverviewPageModel {
3030
this._filteringModel = new FilteringModel({
3131
names: new TextTokensFilterModel(),
3232
methods: new TextTokensFilterModel(),
33-
bad: new SelectionModel({
34-
availableOptions: [{ label: 'Any' }, { label: 'Bad', value: true }, { label: 'Not Bad', value: false }],
35-
defaultSelection: [{ label: 'Any' }],
36-
allowEmpty: false,
37-
multiple: false,
38-
}),
33+
bad: new RadioButtonFilterModel([{ label: 'Any' }, { label: 'Bad', value: true }, { label: 'Not Bad', value: false }]),
3934
});
4035

4136
this._filteringModel.observe(() => {

0 commit comments

Comments
 (0)