@@ -20,6 +20,7 @@ import { AuthorFilterModel } from '../../../components/Filters/LogsFilter/author
2020import { PaginationModel } from '../../../components/Pagination/PaginationModel.js' ;
2121import { getRemoteDataSlice } from '../../../utilities/fetch/getRemoteDataSlice.js' ;
2222import { tagsProvider } from '../../../services/tag/tagsProvider.js' ;
23+ import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js' ;
2324
2425/**
2526 * Model representing handlers for log entries page
@@ -36,6 +37,12 @@ export class LogsOverviewModel extends Observable {
3637 constructor ( model , excludeAnonymous = false ) {
3738 super ( ) ;
3839
40+ this . _filteringModel = new FilteringModel ( {
41+ authorFilter : new AuthorFilterModel ( ) ,
42+ titleFilter : new FilterInputModel ( ) ,
43+ contentFilter : new FilterInputModel ( ) ,
44+ } ) ;
45+
3946 // Sub-models
4047 this . _listingTagsFilterModel = new TagFilterModel ( tagsProvider . items$ ) ;
4148 this . _listingTagsFilterModel . observe ( ( ) => this . _applyFilters ( ) ) ;
@@ -49,16 +56,6 @@ export class LogsOverviewModel extends Observable {
4956 this . _pagination . observe ( ( ) => this . fetchLogs ( ) ) ;
5057 this . _pagination . itemsPerPageSelector$ . observe ( ( ) => this . notify ( ) ) ;
5158
52- // Filtering models
53- this . _authorFilter = new AuthorFilterModel ( ) ;
54- this . _registerFilter ( this . _authorFilter ) ;
55-
56- this . _titleFilter = new FilterInputModel ( ) ;
57- this . _registerFilter ( this . _titleFilter ) ;
58-
59- this . _contentFilter = new FilterInputModel ( ) ;
60- this . _registerFilter ( this . _contentFilter ) ;
61-
6259 this . _logs = RemoteData . NotAsked ( ) ;
6360
6461 const updateDebounceTime = ( ) => {
@@ -67,7 +64,7 @@ export class LogsOverviewModel extends Observable {
6764 model . appConfiguration$ . observe ( ( ) => updateDebounceTime ( ) ) ;
6865 updateDebounceTime ( ) ;
6966
70- excludeAnonymous && this . _authorFilter . update ( '!Anonymous' ) ;
67+ excludeAnonymous && this . _filteringModel . get ( 'authorFilter' ) . update ( '!Anonymous' ) ;
7168
7269 this . reset ( false ) ;
7370 }
@@ -119,10 +116,7 @@ export class LogsOverviewModel extends Observable {
119116 * @return {undefined }
120117 */
121118 reset ( fetch = true ) {
122- this . titleFilter . reset ( ) ;
123- this . contentFilter . reset ( ) ;
124- this . authorFilter . reset ( ) ;
125-
119+ this . _filteringModel . reset ( ) ;
126120 this . createdFilterFrom = '' ;
127121 this . createdFilterTo = '' ;
128122
@@ -153,9 +147,7 @@ export class LogsOverviewModel extends Observable {
153147 */
154148 isAnyFilterActive ( ) {
155149 return (
156- ! this . _titleFilter . isEmpty
157- || ! this . _contentFilter . isEmpty
158- || ! this . _authorFilter . isEmpty
150+ ! this . _filteringModel . isAnyFilterActive ( )
159151 || this . createdFilterFrom !== ''
160152 || this . createdFilterTo !== ''
161153 || ! this . listingTagsFilterModel . isEmpty
@@ -289,6 +281,15 @@ export class LogsOverviewModel extends Observable {
289281 }
290282 }
291283
284+ /**
285+ * Return the model managing all filters
286+ *
287+ * @return {FilteringModel } the filtering model
288+ */
289+ get filteringModel ( ) {
290+ return this . _filteringModel ;
291+ }
292+
292293 /**
293294 * Return the model handling the filtering on tags
294295 *
@@ -375,16 +376,18 @@ export class LogsOverviewModel extends Observable {
375376 _getFilterQueryParams ( ) {
376377 const sortOn = this . _overviewSortModel . appliedOn ;
377378 const sortDirection = this . _overviewSortModel . appliedDirection ;
378-
379+ const titleFilter = this . _filteringModel . get ( 'titleFilter' ) ;
380+ const contentFilter = this . _filteringModel . get ( 'contentFilter' ) ;
381+ const authorFilter = this . _filteringModel . get ( 'authorFilter' ) ;
379382 return {
380- ...! this . _titleFilter . isEmpty && {
381- 'filter[title]' : this . _titleFilter . value ,
383+ ...! titleFilter . isEmpty && {
384+ 'filter[title]' : titleFilter . value ,
382385 } ,
383- ...! this . _contentFilter . isEmpty && {
384- 'filter[content]' : this . _contentFilter . value ,
386+ ...! contentFilter . isEmpty && {
387+ 'filter[content]' : contentFilter . value ,
385388 } ,
386- ...! this . _authorFilter . isEmpty && {
387- 'filter[author]' : this . _authorFilter . value ,
389+ ...! authorFilter . isEmpty && {
390+ 'filter[author]' : authorFilter ,
388391 } ,
389392 ...this . createdFilterFrom && {
390393 'filter[created][from]' :
0 commit comments