Skip to content
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

[ACS-9010] Loading spinner is not shown on search results page when filtering for files or folders #10434

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
* limitations under the License.
*/

import { Subject, Observable, from, ReplaySubject, BehaviorSubject } from 'rxjs';
import { BehaviorSubject, from, Observable, ReplaySubject, Subject } from 'rxjs';
import { AppConfigService } from '@alfresco/adf-core';
import {
SearchRequest,
RequestFacetFields,
RequestSortDefinitionInner,
ResultSetPaging,
RequestHighlight,
RequestScope,
RequestSortDefinitionInner,
ResultSetPaging,
SEARCH_LANGUAGE,
SearchApi,
SEARCH_LANGUAGE
SearchRequest
} from '@alfresco/js-api';
import { SearchCategory } from '../models/search-category.interface';
import { FilterQuery } from '../models/filter-query.interface';
Expand Down Expand Up @@ -68,6 +68,9 @@ export abstract class BaseQueryBuilderService {
/* Stream that emits search forms */
searchForms = new ReplaySubject<SearchForm[]>(1);

/* Stream that emits void when change in filterQueries */
filterQueryUpdate = new Subject<void>();

/* Stream that emits the initial value for some or all search filters */
populateFilters = new BehaviorSubject<{ [key: string]: any }>({});

Expand Down Expand Up @@ -247,6 +250,7 @@ export abstract class BaseQueryBuilderService {
const existing = this.filterQueries.find((filterQuery) => filterQuery.query === query);
if (!existing) {
this.filterQueries.push({ query });
this.filterQueryUpdate.next();
}
}
}
Expand All @@ -259,6 +263,7 @@ export abstract class BaseQueryBuilderService {
removeFilterQuery(query: string): void {
if (query) {
this.filterQueries = this.filterQueries.filter((filterQuery) => filterQuery.query !== query);
this.filterQueryUpdate.next();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ describe('SearchQueryBuilder', () => {
expect(builder.filterQueries.length).toBe(2);
});

it('should call filterQueryUpdate after adding or removing filterQuery', () => {
const builder = createQueryBuilder();
spyOn(builder.filterQueryUpdate, 'next');
builder.addFilterQuery('q1');
builder.removeFilterQuery('q1');
expect(builder.filterQueryUpdate.next).toHaveBeenCalledTimes(2);
});

it('should fetch facet query from config', () => {
const config: SearchConfiguration = {
categories: [],
Expand Down
Loading