Skip to content

Commit 3507ba0

Browse files
author
Guust
committed
add lhcFills filter to the filteringmodel
1 parent b5e7148 commit 3507ba0

File tree

2 files changed

+27
-35
lines changed

2 files changed

+27
-35
lines changed

lib/public/views/Logs/ActiveColumns/logsActiveColumns.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { formatRunsList } from '../../Runs/format/formatRunsList.js';
2424
import { profiles } from '../../../components/common/table/profiles.js';
2525
import { textFilter } from '../../../components/Filters/common/filters/textFilter.js';
2626
import { formatLhcFillsList } from '../../LhcFills/format/formatLhcFillsList.js';
27-
import { lhcFillsFilter } from '../../../components/Filters/LogsFilter/lhcFill.js';
2827
import { formatTagsList } from '../../Tags/format/formatTagsList.js';
2928
import { rawTextFilter } from '../../../components/Filters/common/filters/rawTextFilter.js';
3029

@@ -157,7 +156,7 @@ export const logsActiveColumns = {
157156
* @param {FilteringModel} logOverviewModel.filteringModel filtering model
158157
* @return {Component} the filter component
159158
*/
160-
filter: ({ filteringModel }) => tagFilter(filteringModel.get('listingTagsFilterModel')),
159+
filter: ({ filteringModel }) => tagFilter(filteringModel.get('tags')),
161160
balloon: true,
162161
profiles: [profiles.none, 'embeded'],
163162
},
@@ -210,7 +209,7 @@ export const logsActiveColumns = {
210209
filter: ({ filteringModel }) => rawTextFilter(
211210
filteringModel.get('environments'),
212211
{
213-
id: 'runsFilterText',
212+
id: 'environmentFilterText',
214213
classes: ['w-75', 'mt1'],
215214
placeholder: 'e.g. Dxi029djX, TDI59So3d...',
216215
},
@@ -224,7 +223,22 @@ export const logsActiveColumns = {
224223
sortable: false,
225224
size: 'w-10',
226225
format: formatLhcFillsList,
227-
filter: lhcFillsFilter,
226+
227+
/**
228+
* LhcFills filter component
229+
*
230+
* @param {LogsOverviewModel} logOverviewModel the logs overview model
231+
* @param {FilteringModel} logOverviewModel.filteringModel filtering model
232+
* @return {Component} the filter component
233+
*/
234+
filter: ({ filteringModel }) => rawTextFilter(
235+
filteringModel.get('lhcFills'),
236+
{
237+
id: 'lhcFillsFilterText',
238+
classes: ['w-75', 'mt1'],
239+
placeholder: 'e.g. 11392, 11383, 7625',
240+
},
241+
),
228242
balloon: true,
229243
profiles: [profiles.none, 'embeded'],
230244
},

lib/public/views/Logs/Overview/LogsOverviewModel.js

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ export class LogsOverviewModel extends Observable {
4141
authorFilter: new AuthorFilterModel(),
4242
titleFilter: new RawTextFilterModel(),
4343
contentFilter: new RawTextFilterModel(),
44-
listingTagsFilterModel: new TagFilterModel(tagsProvider.items$),
44+
tags: new TagFilterModel(tagsProvider.items$),
4545
run: new RawTextFilterModel(),
4646
environments: new RawTextFilterModel(),
47+
lhcFills: new RawTextFilterModel(),
4748
});
4849

4950
this._filteringModel.observe(() => this._applyFilters());
@@ -125,8 +126,6 @@ export class LogsOverviewModel extends Observable {
125126
this.runFilterOperation = 'AND';
126127
this.environmentFilterOperation = 'AND';
127128
this.lhcFillFilterOperation = 'AND';
128-
this.lhcFillFilterValues = [];
129-
this._lhcFillFilterRawValue = '';
130129

131130
this._pagination.reset();
132131

@@ -144,7 +143,6 @@ export class LogsOverviewModel extends Observable {
144143
!this._filteringModel.isAnyFilterActive()
145144
|| this.createdFilterFrom !== ''
146145
|| this.createdFilterTo !== ''
147-
|| this.lhcFillFilterValues.length !== 0
148146
);
149147
}
150148

@@ -198,27 +196,6 @@ export class LogsOverviewModel extends Observable {
198196
return this._lhcFillFilterRawValue;
199197
}
200198

201-
/**
202-
* Add a lhcFill to the filter
203-
* @param {string} rawLhcFills The LHC fills to be added to the filter criteria
204-
* @returns {void}
205-
*/
206-
setLhcFillsFilter(rawLhcFills) {
207-
this._lhcFillFilterRawValue = rawLhcFills;
208-
209-
// Split the lhc fills string by comma or whitespace, remove falsy values like empty strings, and convert to int
210-
const lhcFills = rawLhcFills
211-
.split(/[ ,]+/)
212-
.filter(Boolean)
213-
.map((fillNumberStr) => parseInt(fillNumberStr.trim(), 10));
214-
215-
// Allow empty lhcFills only if raw lhcFills is an empty string
216-
if (lhcFills.length > 0 || rawLhcFills.length === 0) {
217-
this.lhcFillFilterValues = lhcFills;
218-
this._applyFilters();
219-
}
220-
}
221-
222199
/**
223200
* Returns the current minimum creation datetime
224201
* @returns {Integer} The current minimum creation datetime
@@ -327,9 +304,10 @@ export class LogsOverviewModel extends Observable {
327304
const titleFilter = this._filteringModel.get('titleFilter');
328305
const contentFilter = this._filteringModel.get('contentFilter');
329306
const authorFilter = this._filteringModel.get('authorFilter');
330-
const listingTagsFilterModel = this._filteringModel.get('listingTagsFilterModel');
307+
const tags = this._filteringModel.get('tags');
331308
const run = this._filteringModel.get('run');
332309
const environments = this._filteringModel.get('environments');
310+
const lhcFills = this._filteringModel.get('lhcFills');
333311

334312
return {
335313
...!titleFilter.isEmpty && {
@@ -349,9 +327,9 @@ export class LogsOverviewModel extends Observable {
349327
'filter[created][to]':
350328
new Date(`${this.createdFilterTo.replace(/\//g, '-')}T23:59:59.999`).getTime(),
351329
},
352-
...!listingTagsFilterModel.isEmpty && {
353-
'filter[tags][values]': listingTagsFilterModel.selected.join(),
354-
'filter[tags][operation]': listingTagsFilterModel.combinationOperator,
330+
...!tags.isEmpty && {
331+
'filter[tags][values]': tags.selected.join(),
332+
'filter[tags][operation]': tags.combinationOperator,
355333
},
356334
...!run.isEmpty && {
357335
'filter[run][values]': run.normalized,
@@ -361,8 +339,8 @@ export class LogsOverviewModel extends Observable {
361339
'filter[environments][values]': environments.normalized,
362340
'filter[environments][operation]': this.environmentFilterOperation.toLowerCase(),
363341
},
364-
...this.lhcFillFilterValues.length > 0 && {
365-
'filter[lhcFills][values]': this.lhcFillFilterValues.join(),
342+
...!lhcFills.isEmpty && {
343+
'filter[lhcFills][values]': lhcFills.normalized,
366344
'filter[lhcFills][operation]': this.lhcFillFilterOperation.toLowerCase(),
367345
},
368346
...sortOn && sortDirection && {

0 commit comments

Comments
 (0)