Skip to content

Commit 102c1b6

Browse files
author
GuustMetz
committed
feat: move yearsFilterModel to the filteringModel
1 parent 05461dd commit 102c1b6

2 files changed

Lines changed: 4 additions & 15 deletions

File tree

lib/public/views/lhcPeriods/ActiveColumns/lhcPeriodsActiveColumns.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export const lhcPeriodsActiveColumns = {
9292
visible: true,
9393
sortable: true,
9494
format: (_, lhcPeriod) => formatLhcPeriodYear(lhcPeriod.name),
95-
filter: ({ yearsFilterModel }) => textFilter(
96-
yearsFilterModel,
95+
filter: ({ filteringModel }) => textFilter(
96+
filteringModel.get('years'),
9797
{ class: 'w-75 mt1', placeholder: 'e.g. 2022, 2023, ...' },
9898
),
9999
classes: 'w-7',

lib/public/views/lhcPeriods/Overview/LhcPeriodsOverviewModel.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class LhcPeriodsOverviewModel extends OverviewPageModel {
3030

3131
this._filteringModel = new FilteringModel({
3232
names: new TextTokensFilterModel(),
33+
years: new TextTokensFilterModel(),
3334
});
3435

3536
this._filteringModel.visualChange$.bubbleTo(this);
@@ -38,8 +39,6 @@ export class LhcPeriodsOverviewModel extends OverviewPageModel {
3839
this.load();
3940
});
4041

41-
this._yearsFilterModel = new TextTokensFilterModel();
42-
this._registerFilter(this._yearsFilterModel);
4342
this._pdpBeamTypesFilterModel = new TextTokensFilterModel();
4443
this._registerFilter(this._pdpBeamTypesFilterModel);
4544
}
@@ -49,7 +48,6 @@ export class LhcPeriodsOverviewModel extends OverviewPageModel {
4948
*/
5049
getRootEndpoint() {
5150
const filter = this._filteringModel.normalized;
52-
filter.years = this._yearsFilterModel.normalized;
5351
filter.pdpBeamTypes = this._pdpBeamTypesFilterModel.normalized;
5452

5553
return buildUrl('/api/lhcPeriodsStatistics', { filter });
@@ -80,14 +78,6 @@ export class LhcPeriodsOverviewModel extends OverviewPageModel {
8078
});
8179
}
8280

83-
/**
84-
* Returns lhc periods years filter model
85-
* @return {TextTokensFilterModel} lhc periods years filter model
86-
*/
87-
get yearsFilterModel() {
88-
return this._yearsFilterModel;
89-
}
90-
9181
/**
9282
* Returns lhc periods beam type filter model
9383
* @return {TextTokensFilterModel} lhc periods beam type filter model
@@ -104,7 +94,6 @@ export class LhcPeriodsOverviewModel extends OverviewPageModel {
10494
reset() {
10595
super.reset();
10696
this._filteringModel.reset();
107-
this._yearsFilterModel.reset();
10897
this._pdpBeamTypesFilterModel.reset();
10998
}
11099

@@ -127,6 +116,6 @@ export class LhcPeriodsOverviewModel extends OverviewPageModel {
127116
* @return {boolean} true if any filter is active
128117
*/
129118
isAnyFilterActive() {
130-
return this._filteringModel.isAnyFilterActive() || !this._yearsFilterModel.isEmpty || !this._pdpBeamTypesFilterModel.isEmpty;
119+
return this._filteringModel.isAnyFilterActive() || !this._pdpBeamTypesFilterModel.isEmpty;
131120
}
132121
}

0 commit comments

Comments
 (0)