-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[O2B-532] Improve runs overview run definition filter
- Loading branch information
1 parent
e1f2b03
commit f550eb3
Showing
8 changed files
with
154 additions
and
102 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { RUN_DEFINITIONS, RunDefinition } from '../../../domain/enums/RunDefinition.js'; | ||
import { SelectionFilterModel } from '../common/filters/SelectionFilterModel.js'; | ||
|
||
/** | ||
* Run definition filter model | ||
*/ | ||
export class RunDefinitionFilterModel extends SelectionFilterModel { | ||
/** | ||
* Constructor | ||
*/ | ||
constructor() { | ||
super({ availableOptions: RUN_DEFINITIONS.map((definition) => ({ value: definition })) }); | ||
} | ||
|
||
/** | ||
* Returns true if the current filter is physics only | ||
* | ||
* @return {boolean} true if filter is physics only | ||
*/ | ||
isPhysicsOnly() { | ||
const selectedOptions = this._selectionModel.selected; | ||
return selectedOptions.length === 1 && selectedOptions[0] === RunDefinition.Physics; | ||
} | ||
|
||
/** | ||
* Sets the current filter to physics only | ||
* | ||
* @return {void} | ||
*/ | ||
setPhysicsOnly() { | ||
if (!this.isPhysicsOnly()) { | ||
this._selectionModel.selectedOptions = []; | ||
this._selectionModel.select(RunDefinition.Physics); | ||
this.notify(); | ||
} | ||
} | ||
|
||
/** | ||
* Empty the current filter | ||
* | ||
* @return {void} | ||
*/ | ||
setEmpty() { | ||
if (!this.isEmpty) { | ||
this.reset(); | ||
this.notify(); | ||
} | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
lib/public/components/Filters/RunsFilter/definitionFilter.js
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
lib/public/components/Filters/RunsFilter/runDefinitionFilter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
import { checkboxes } from '../common/filters/checkboxFilter.js'; | ||
|
||
/** | ||
* Renders a list of checkboxes that lets the user look for runs with specific definition | ||
* | ||
* @param {RunDefinitionFilterModel} runDefinitionFilterModel run definition filter model | ||
* @return {Component} the filter | ||
*/ | ||
export const runDefinitionFilter = (runDefinitionFilterModel) => checkboxes(runDefinitionFilterModel.selectionModel); | ||
65 changes: 65 additions & 0 deletions
65
lib/public/components/Filters/common/filters/SelectionFilterModel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
import { FilterModel } from '../FilterModel.js'; | ||
import { SelectionModel } from '../../../common/selection/SelectionModel.js'; | ||
|
||
/** | ||
* Filter model based on a selection model | ||
*/ | ||
export class SelectionFilterModel extends FilterModel { | ||
/** | ||
* Constructor | ||
* | ||
* @param {object} [configuration] the selection filter configuration | ||
* @param {SelectionOption[]} [configuration.availableOptions=[]] the list of available options | ||
*/ | ||
constructor(configuration) { | ||
super(); | ||
|
||
this._selectionModel = new SelectionModel({ availableOptions: configuration.availableOptions }); | ||
this._selectionModel.bubbleTo(this); | ||
} | ||
|
||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* @inheritDoc | ||
*/ | ||
reset() { | ||
this._selectionModel.reset(); | ||
} | ||
|
||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get isEmpty() { | ||
return this._selectionModel.isEmpty; | ||
} | ||
|
||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get normalized() { | ||
return this._selectionModel.selected.join(','); | ||
} | ||
|
||
/** | ||
* Return the underlying selection model | ||
* | ||
* @return {SelectionModel} the underlying selection model | ||
*/ | ||
get selectionModel() { | ||
return this._selectionModel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters