1+ import { AggregationGroupView } from '@enonic/lib-admin-ui/aggregation/AggregationGroupView' ;
2+ import { Bucket } from '@enonic/lib-admin-ui/aggregation/Bucket' ;
3+ import { BucketAggregation } from '@enonic/lib-admin-ui/aggregation/BucketAggregation' ;
4+ import { BrowseFilterPanel } from '@enonic/lib-admin-ui/app/browse/filter/BrowseFilterPanel' ;
5+ import { TextSearchField } from '@enonic/lib-admin-ui/app/browse/filter/TextSearchField' ;
6+ import { AuthContext } from '@enonic/lib-admin-ui/auth/AuthContext' ;
7+ import { DivEl } from '@enonic/lib-admin-ui/dom/DivEl' ;
8+ import { Element } from '@enonic/lib-admin-ui/dom/Element' ;
19import { SearchInputValues } from '@enonic/lib-admin-ui/query/SearchInputValues' ;
2- import { StringHelper } from '@enonic/lib-admin-ui/util/StringHelper' ;
3- import Q from 'q' ;
410import { i18n } from '@enonic/lib-admin-ui/util/Messages' ;
5- import { Router } from '../../Router' ;
6- import { ContentServerEventsHandler } from '../../event/ContentServerEventsHandler' ;
7- import { ContentSummaryAndCompareStatus } from '../../content/ContentSummaryAndCompareStatus' ;
11+ import { cn } from '@enonic/ui' ;
12+ import Q from 'q' ;
13+ import {
14+ $contentFilterState ,
15+ addSelectedBucket ,
16+ deselectAllFilterBuckets ,
17+ getFilterSelection ,
18+ getFilterValue ,
19+ hasFilterSet ,
20+ hasFilterValueSet ,
21+ resetContentFilter
22+ } from '../../../v6/features/store/contentFilter.store' ;
23+ import { ContentId } from '../../content/ContentId' ;
824import { ContentQuery } from '../../content/ContentQuery' ;
9- import { AggregationGroupView } from '@enonic/lib-admin-ui/aggregation/AggregationGroupView' ;
10- import { BrowseFilterPanel } from '@enonic/lib-admin-ui/app/browse/filter/BrowseFilterPanel' ;
11- import { BucketAggregation } from '@enonic/lib-admin-ui/aggregation/BucketAggregation' ;
12- import { BucketAggregationView } from '@enonic/lib-admin-ui/aggregation/BucketAggregationView' ;
25+ import { ContentSummary } from '../../content/ContentSummary' ;
26+ import { ContentSummaryAndCompareStatus } from '../../content/ContentSummaryAndCompareStatus' ;
1327import { ContentServerChangeItem } from '../../event/ContentServerChangeItem' ;
28+ import { ContentServerEventsHandler } from '../../event/ContentServerEventsHandler' ;
1429import { ProjectContext } from '../../project/ProjectContext' ;
15- import { ContentSummary } from '../../content/ContentSummary' ;
16- import { ContentId } from '../../content/ContentId' ;
30+ import { Router } from '../../Router' ;
1731import { ContentBrowseFilterComponent } from '../../ui2/filter/ContentBrowseFilterComponent' ;
18- import { DependenciesSection } from './DependenciesSection' ;
19- import { ContentAggregation } from './ContentAggregation' ;
32+ import { Branch } from '../../versioning/Branch' ;
2033import { AggregationsDisplayNamesResolver } from './AggregationsDisplayNamesResolver' ;
21- import { ContentAggregationsFetcher } from './ContentAggregationsFetcher' ;
2234import { AggregationsQueryResult } from './AggregationsQueryResult' ;
23- import { Element } from '@enonic/lib-admin-ui/dom/Element' ;
24- import { DivEl } from '@enonic/lib-admin-ui/dom/DivEl' ;
25- import { ContentExportElement } from './ContentExportElement' ;
35+ import { ContentAggregation } from './ContentAggregation' ;
36+ import { ContentAggregationsFetcher } from './ContentAggregationsFetcher' ;
2637import { ContentDependency } from './ContentDependency' ;
27- import { TextSearchField } from '@enonic/lib-admin-ui/app/browse/filter/TextSearchField' ;
28- import { Branch } from '../../versioning/Branch' ;
29- import { AuthContext } from '@enonic/lib-admin-ui/auth/AuthContext' ;
30- import { cn } from '@enonic/ui' ;
38+ import { ContentExportElement } from './ContentExportElement' ;
39+ import { DependenciesSection } from './DependenciesSection'
3140
3241export class ContentBrowseFilterPanel < T extends ContentSummaryAndCompareStatus = ContentSummaryAndCompareStatus >
3342 extends BrowseFilterPanel < T > {
@@ -50,22 +59,16 @@ export class ContentBrowseFilterPanel<T extends ContentSummaryAndCompareStatus =
5059 this . aggregationsFetcher = this . createAggregationFetcher ( ) ;
5160 this . displayNamesResolver = new AggregationsDisplayNamesResolver ( ) ;
5261 this . dependenciesSection = new DependenciesSection ( ) ;
53- this . initElementsAndListeners ( ) ;
5462
5563 this . filterComponent = new ContentBrowseFilterComponent ( {
5664 bucketAggregations : [ ] ,
57- onChange : ( ) => {
58- this . search ( ) ;
59- } ,
60- onSelectionChange : ( ) => {
61- this . search ( ) ;
62- } ,
6365 filterableAggregations : this . getFilterableAggregations ( ) ,
6466 exportOptions : this . getExportOptions ( ) ,
6567 } ) ;
6668
6769 this . appendChild ( this . filterComponent ) ;
6870
71+ this . handleEvents ( ) ;
6972 this . getAndUpdateAggregations ( ) ;
7073 }
7174
@@ -89,19 +92,15 @@ export class ContentBrowseFilterPanel<T extends ContentSummaryAndCompareStatus =
8992 } ) ;
9093 }
9194
92- protected initElementsAndListeners ( ) {
93- if ( this . isExportAllowed ( ) ) {
94- this . exportElement = new ContentExportElement ( ) . setEnabled ( false ) . setTitle ( i18n ( 'action.export' ) ) as ContentExportElement ;
95- }
96-
97- this . handleEvents ( ) ;
98- }
99-
10095 protected handleEvents ( ) {
10196 this . onRendered ( ( ) => {
10297 super . appendChild ( this . elementsContainer ) ;
10398 } ) ;
10499
100+ $contentFilterState . listen ( ( ) => {
101+ this . search ( ) ;
102+ } ) ;
103+
105104 this . handleEventsForDependenciesSection ( ) ;
106105 }
107106
@@ -175,11 +174,6 @@ export class ContentBrowseFilterPanel<T extends ContentSummaryAndCompareStatus =
175174 ContentAggregation . MODIFIED_BY . toString ( ) ;
176175 }
177176
178- protected isExportAllowed ( ) : boolean {
179- // add more checks here if needed
180- return true ;
181- }
182-
183177 private removeDependencyItem ( ) {
184178 this . dependenciesSection . reset ( ) ;
185179 this . search ( ) ;
@@ -215,7 +209,7 @@ export class ContentBrowseFilterPanel<T extends ContentSummaryAndCompareStatus =
215209 }
216210
217211 private selectContentTypeBucket ( key : string ) : void {
218- this . filterComponent . selectBucketViewByKey ( ContentAggregation . CONTENT_TYPE , key ) ;
212+ addSelectedBucket ( ContentAggregation . CONTENT_TYPE , new Bucket ( key , 0 ) ) ;
219213 }
220214
221215 searchItemById ( id : ContentId ) : void {
@@ -252,26 +246,26 @@ export class ContentBrowseFilterPanel<T extends ContentSummaryAndCompareStatus =
252246 getSearchInputValues ( ) : SearchInputValues {
253247 const searchInputValues : SearchInputValues = new SearchInputValues ( ) ;
254248
255- searchInputValues . setAggregationSelections ( this . filterComponent . getSelectedBuckets ( ) ) ;
256- searchInputValues . setTextSearchFieldValue ( this . filterComponent . getValue ( ) ) ;
249+ searchInputValues . setAggregationSelections ( getFilterSelection ( ) ) ;
250+ searchInputValues . setTextSearchFieldValue ( getFilterValue ( ) ) ;
257251
258252 return searchInputValues ;
259253 }
260254
261255 hasFilterSet ( ) : boolean {
262- return this . filterComponent . hasSelectedBuckets ( ) || this . hasSearchStringSet ( ) ;
256+ return hasFilterSet ( ) ;
263257 }
264258
265259 hasSearchStringSet ( ) : boolean {
266- return ! StringHelper . isBlank ( this . filterComponent . getValue ( ) ) ;
260+ return hasFilterValueSet ( ) ;
267261 }
268262
269263 resetControls ( ) {
270- this . filterComponent . reset ( ) ;
264+ resetContentFilter ( ) ;
271265 }
272266
273267 deselectAll ( ) {
274- this . filterComponent . deselectAll ( ) ;
268+ deselectAllFilterBuckets ( ) ;
275269 }
276270
277271 updateHitsCounter ( hits : number ) {
0 commit comments