-
Notifications
You must be signed in to change notification settings - Fork 21
[O2B-1548] Migrate qc flag types overview model to use filtering model pattern #2100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NarrowsProjects
wants to merge
5
commits into
improv/O2B-1534/Migrate-Log-Overview-to-use-FilteringModel-pattern
Choose a base branch
from
improv/O2B-1548/Migrate-qcFlagTypesOverviewModel-to-use-FilteringModel-pattern
base: improv/O2B-1534/Migrate-Log-Overview-to-use-FilteringModel-pattern
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25244f4
chore: add filteringmodel to QcFlagTypesOverviewModel
6970a74
feat: move namesFilterModelFilter to fileringmodel
cdaaf0e
feat: move methodsFilterModelFilter to filteringModel
27a8bbc
feat: move methodsFilterModelFilter to filteringModel
a9a1cd9
fix: fix Selectionmodel.normalized to use selected rather than select…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,36 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE Trg. 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-Trg.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 { radioButton } from '../../common/form/inputs/radioButton.js'; | ||
| import { h } from '/js/src/index.js'; | ||
|
|
||
| /** | ||
| * Radiobutton filter for the qcFlag 'bad' filter | ||
| * @param {SelectionModel} selectionModel the a selectionmodel | ||
| * @return {vnode} A number of radiobuttons corresponding with the selection options | ||
| */ | ||
| const badFilterRadioButtons = (selectionModel) => { | ||
| const name = 'badFilterRadio'; | ||
| return h( | ||
| '.form-group-header.flex-row.w-100', | ||
| selectionModel.options.map((option) => { | ||
| const { label } = option; | ||
| const action = () => selectionModel.select(option); | ||
| const isChecked = selectionModel.isSelected(option); | ||
|
|
||
| return radioButton({ label, isChecked, action, name }); | ||
| }), | ||
| ); | ||
| }; | ||
|
|
||
| export default badFilterRadioButtons; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { TextTokensFilterModel } from '../../../components/Filters/common/filter | |
| import { OverviewPageModel } from '../../../models/OverviewModel.js'; | ||
| import { SelectionModel } from '../../../components/common/selection/SelectionModel.js'; | ||
| import { buildUrl } from '/js/src/index.js'; | ||
| import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js'; | ||
|
|
||
| /** | ||
| * QcFlagTypesOverviewModel | ||
|
|
@@ -26,73 +27,39 @@ export class QcFlagTypesOverviewModel extends OverviewPageModel { | |
| constructor() { | ||
| super(); | ||
|
|
||
| this._namesFilterModel = new TextTokensFilterModel(); | ||
| this._registerFilter(this._namesFilterModel); | ||
| this._methodsFilterModel = new TextTokensFilterModel(); | ||
| this._registerFilter(this._methodsFilterModel); | ||
| this._isBadFilterModel = | ||
| new SelectionModel({ availableOptions: [{ label: 'Bad', value: true }, { label: 'Not Bad', value: false }] }); | ||
| this._registerFilter(this._isBadFilterModel); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| getRootEndpoint() { | ||
| const params = {}; | ||
| if (this.isAnyFilterActive()) { | ||
| params.filter = { | ||
| names: this._namesFilterModel.normalized, | ||
| methods: this._methodsFilterModel.normalized, | ||
| bad: this._isBadFilterModel.selected.length === 2 | ||
| ? undefined | ||
| : this._isBadFilterModel.selected[0], | ||
| }; | ||
| } | ||
|
|
||
| return buildUrl('/api/qcFlagTypes', params); | ||
| } | ||
| this._filteringModel = new FilteringModel({ | ||
| names: new TextTokensFilterModel(), | ||
| methods: new TextTokensFilterModel(), | ||
| bad: new SelectionModel({ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment |
||
| availableOptions: [{ label: 'Any' }, { label: 'Bad', value: true }, { label: 'Not Bad', value: false }], | ||
| defaultSelection: [{ label: 'Any' }], | ||
| allowEmpty: false, | ||
| multiple: false, | ||
| }), | ||
| }); | ||
|
|
||
| /** | ||
| * Get names filter model | ||
| * | ||
| * @return {TextTokensFilterModel} names filter model | ||
| */ | ||
| get namesFilterModel() { | ||
| return this._namesFilterModel; | ||
| } | ||
| this._filteringModel.observe(() => { | ||
| this._pagination.silentlySetCurrentPage(1); | ||
| this.load(); | ||
| }); | ||
|
|
||
| /** | ||
| * Get methods filter model | ||
| * | ||
| * @return {TextTokensFilterModel} methods filter model | ||
| */ | ||
| get methodsFilterModel() { | ||
| return this._methodsFilterModel; | ||
| this._filteringModel.visualChange$.bubbleTo(this); | ||
| } | ||
|
|
||
| /** | ||
| * Returns filter model for filtering bad and not bad flags | ||
| * | ||
| * @return {TextTokensFilterModel} filter model for filtering bad and not bad flags | ||
| * @inheritdoc | ||
| */ | ||
| get isBadFilterModel() { | ||
| return this._isBadFilterModel; | ||
| getRootEndpoint() { | ||
| return buildUrl('/api/qcFlagTypes', { filter: this._filteringModel.normalized }); | ||
| } | ||
|
|
||
| /** | ||
| * Register a new filter model | ||
| * Return the model managing all filters | ||
| * | ||
| * @param {FilterModel} filterModel the filter model to register | ||
| * @return {void} | ||
| * @private | ||
| * @return {FilteringModel} the filtering model | ||
| */ | ||
| _registerFilter(filterModel) { | ||
| filterModel.visualChange$.bubbleTo(this); | ||
| filterModel.observe(() => { | ||
| this._pagination.silentlySetCurrentPage(1); | ||
| this.load(); | ||
| }); | ||
| get filteringModel() { | ||
| return this._filteringModel; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -101,7 +68,7 @@ export class QcFlagTypesOverviewModel extends OverviewPageModel { | |
| * @return {boolean} true if any filter is active | ||
| */ | ||
| isAnyFilterActive() { | ||
| return !this._namesFilterModel.isEmpty || !this._methodsFilterModel.isEmpty || this._isBadFilterModel.selected.length; | ||
| return this._filteringModel.isAnyFilterActive(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -110,9 +77,7 @@ export class QcFlagTypesOverviewModel extends OverviewPageModel { | |
| * @returns {void} | ||
| */ | ||
| reset() { | ||
| this._methodsFilterModel.reset(); | ||
| this._namesFilterModel.reset(); | ||
| this._isBadFilterModel.reset(); | ||
| this._filteringModel.reset(); | ||
| super.reset(); | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now a couple of filters that make use of radio buttons.
Make a common component for that in a later PR