Skip to content

Commit 822a88d

Browse files
committed
wip
1 parent 362514d commit 822a88d

3 files changed

Lines changed: 24 additions & 29 deletions

File tree

lib/public/components/Filters/common/FilteringModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class FilteringModel extends Observable {
6868
*/
6969
isAnyFilterActive() {
7070
for (const model of this._filterModels) {
71-
if (!model.isEmpty) {
71+
if (model.isEmpty instanceof Boolean && !model.isEmpty || model.isEmpty instanceof Function && !model.isEmpty()) {
7272
return true;
7373
}
7474
}

lib/public/views/DataPasses/ActiveColumns/dataPassesActiveColumns.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export const dataPassesActiveColumns = {
3535
visible: true,
3636
sortable: true,
3737
format: (_, dataPass) => formatDataPassName(dataPass),
38-
filter: ({ nameFilterModel }) => textFilter(
39-
nameFilterModel,
38+
filter: ({ filteringModel }) => textFilter(
39+
filteringModel.get('names'),
4040
{ class: 'w-75 mt1', placeholder: 'e.g. LHC22a_apass1, ...' },
4141
),
4242
balloon: true,
@@ -105,7 +105,7 @@ export const dataPassesActiveColumns = {
105105

106106
nonPhysicsProductions: {
107107
name: 'include nonphysical productions',
108-
filter: (runsOverviewModel) => checkboxes(runsOverviewModel.filteringModel.get('runQualities').selectionModel),
108+
// filter: (runsOverviewModel) => checkboxes(runsOverviewModel.filteringModel.get('runQualities').selectionModel),
109109
visible: false,
110110
}
111111
};

lib/public/views/DataPasses/PerLhcPeriodOverview/DataPassesPerLhcPeriodOverviewModel.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* granted to it by virtue of its status as an Intergovernmental Organization
1111
* or submit itself to any jurisdiction.
1212
*/
13+
import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js';
1314
import { TextTokensFilterModel } from '../../../components/Filters/common/filters/TextTokensFilterModel.js';
1415
import { OverviewPageModel } from '../../../models/OverviewModel.js';
1516
import { buildUrl } from '/js/src/index.js';
@@ -23,8 +24,15 @@ export class DataPassesPerLhcPeriodOverviewModel extends OverviewPageModel {
2324
*/
2425
constructor() {
2526
super();
26-
this._nameFilterModel = new TextTokensFilterModel();
27-
this._registerFilter(this._nameFilterModel);
27+
this._filteringModel = new FilteringModel({
28+
names: new TextTokensFilterModel(),
29+
});
30+
31+
this._filteringModel.visualChange$.bubbleTo(this);
32+
this._filteringModel.observe(() => {
33+
this._pagination.silentlySetCurrentPage(1);
34+
this.load();
35+
});
2836
}
2937

3038
/**
@@ -42,7 +50,7 @@ export class DataPassesPerLhcPeriodOverviewModel extends OverviewPageModel {
4250
const params = {
4351
filter: {
4452
lhcPeriodIds: [this._lhcPeriodId],
45-
names: this._nameFilterModel.normalized,
53+
names: this._filteringModel.get('names').normalized,
4654
},
4755
};
4856

@@ -55,7 +63,7 @@ export class DataPassesPerLhcPeriodOverviewModel extends OverviewPageModel {
5563
* @returns {void}
5664
*/
5765
reset() {
58-
this._nameFilterModel.reset();
66+
this._filteringModel.reset();
5967
super.reset();
6068
}
6169

@@ -67,32 +75,19 @@ export class DataPassesPerLhcPeriodOverviewModel extends OverviewPageModel {
6775
}
6876

6977
/**
70-
* Returns data pass name filter model
71-
* @return {TextTokensFilterModel} data pass name filter model
72-
*/
73-
get nameFilterModel() {
74-
return this._nameFilterModel;
75-
}
76-
77-
/**
78-
* Register a new filter model
79-
* @param {FilterModel} filterModel the filter model to register
80-
* @return {void}
81-
* @private
78+
* Return the filtering model
79+
*
80+
* @return {FilteringModel} the filtering model
8281
*/
83-
_registerFilter(filterModel) {
84-
filterModel.visualChange$.bubbleTo(this);
85-
filterModel.observe(() => {
86-
this._pagination.silentlySetCurrentPage(1);
87-
this.load();
88-
});
82+
get filteringModel() {
83+
return this._filteringModel;
8984
}
9085

9186
/**
92-
* States whether any filter is active
93-
* @return {boolean} true if any filter is active
87+
* Checks if any filter value has been modified from their default (empty)
88+
* @return {Boolean} If any filter is active
9489
*/
9590
isAnyFilterActive() {
96-
return !this._nameFilterModel.isEmpty();
91+
return this._filteringModel.isAnyFilterActive();
9792
}
9893
}

0 commit comments

Comments
 (0)