-
Notifications
You must be signed in to change notification settings - Fork 277
[MNT-25408]: updates changing search config logic; exposes stream for active filters #11386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
61ba6f1
403b990
7c68650
6d83f12
d466b9b
a2f1899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,20 +73,44 @@ export abstract class BaseQueryBuilderService { | |
| /* Stream that emits the initial value for some or all search filters */ | ||
| populateFilters = new BehaviorSubject<{ [key: string]: any }>({}); | ||
|
|
||
| /* Stream that emits every time queryFragments change */ | ||
| queryFragmentsUpdate = new BehaviorSubject<{ [key: string]: any }>({}); | ||
|
|
||
| /* Stream that emits every time userFacetBuckets change */ | ||
| userFacetBucketsUpdate = new BehaviorSubject<{ [key: string]: FacetFieldBucket[] }>({}); | ||
|
|
||
| categories: SearchCategory[] = []; | ||
| queryFragments: { [id: string]: string } = {}; | ||
| filterQueries: FilterQuery[] = []; | ||
| filterRawParams: { [key: string]: any } = {}; | ||
| paging: { maxItems?: number; skipCount?: number } = null; | ||
| sorting: SearchSortingDefinition[] = []; | ||
| sortingOptions: SearchSortingDefinition[] = []; | ||
|
|
||
| private encodedQuery: string; | ||
| private scope: RequestScope; | ||
| private selectedConfiguration: number; | ||
| private _userQuery = ''; | ||
| private _queryFragments: { [id: string]: string } = {}; | ||
|
|
||
| private readonly queryFragmentsHandler: ProxyHandler<{ [key: string]: any }> = { | ||
| set: (target: { [key: string]: any }, property: string, value: any) => { | ||
| target[property as keyof typeof target] = value; | ||
| this.queryFragmentsUpdate.next(this._queryFragments); | ||
| return true; | ||
| } | ||
| }; | ||
|
|
||
| protected userFacetBuckets: { [key: string]: FacetFieldBucket[] } = {}; | ||
|
|
||
| get queryFragments(): { [key: string]: any } { | ||
AleksanderSklorz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return this._queryFragments; | ||
| } | ||
|
|
||
| set queryFragments(value: { [key: string]: any }) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things:
Would it have sense to use one of those types?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AleksanderSklorz , minding that it's a library and type might be other than string, "unknown" would be the right choice. I've checked and all over the code inside of ADF we just once assign undefined there instead of string and that wouldn't be a problem. The problem I see is that we cannot just change it to 'unknown' because it would be a breaking change - some consumers would need type narrowing now, so I believe it should be supported by a sort of migration guide. Probably it should be a dedicated ticket for that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me ask Michał what steps we should do in that case. @MichalKinas can you help us make decision? You can check that comment and open comments below which are related
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unknow may throw some TS issues when compared with any other type so I would avoid it in that case, since it can take some other types except of string I think any usage would be justified here, we can think of suppresing the eslint warning there too |
||
| this._queryFragments = this.createQueryFragmentsProxy(value); | ||
| this.queryFragmentsUpdate.next(this._queryFragments); | ||
| } | ||
|
|
||
| get userQuery(): string { | ||
| return this._userQuery; | ||
| } | ||
|
|
@@ -108,6 +132,7 @@ export abstract class BaseQueryBuilderService { | |
| protected readonly alfrescoApiService: AlfrescoApiService | ||
| ) { | ||
| this.resetToDefaults(); | ||
| this._queryFragments = this.createQueryFragmentsProxy({}); | ||
| } | ||
|
|
||
| public abstract loadConfiguration(): SearchConfiguration | SearchConfiguration[]; | ||
|
|
@@ -146,10 +171,10 @@ export abstract class BaseQueryBuilderService { | |
| const currentConfig = this.loadConfiguration(); | ||
| if (Array.isArray(currentConfig) && currentConfig[index] !== undefined) { | ||
| this.selectedConfiguration = index; | ||
| this.configUpdated.next(currentConfig[index]); | ||
| this.searchForms.next(this.getSearchFormDetails()); | ||
| this.resetSearchOptions(); | ||
| this.setUpSearchConfiguration(currentConfig[index]); | ||
| this.configUpdated.next(currentConfig[index]); | ||
| this.update(); | ||
| } | ||
| } | ||
|
|
@@ -216,6 +241,7 @@ export abstract class BaseQueryBuilderService { | |
| buckets.push(bucket); | ||
| } | ||
| this.userFacetBuckets[field] = buckets; | ||
| this.userFacetBucketsUpdate.next(this.userFacetBuckets); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -239,6 +265,7 @@ export abstract class BaseQueryBuilderService { | |
| if (field && bucket) { | ||
| const buckets = this.userFacetBuckets[field] || []; | ||
| this.userFacetBuckets[field] = buckets.filter((facetBucket) => facetBucket.label !== bucket.label); | ||
| this.userFacetBucketsUpdate.next(this.userFacetBuckets); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -615,4 +642,8 @@ export abstract class BaseQueryBuilderService { | |
| queryParamsHandling: 'merge' | ||
| }); | ||
| } | ||
|
|
||
| private createQueryFragmentsProxy(target: { [key: string]: any }): { [key: string]: any } { | ||
AleksanderSklorz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return new Proxy(target, this.queryFragmentsHandler); | ||
| } | ||
| } | ||

Uh oh!
There was an error while loading. Please reload this page.