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

[DURACOM-301] fix facets search bar appearing if last page was full #3616

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -17,7 +17,9 @@
</a>
</div>
</div>
<ds-filter-input-suggestions [suggestions]="(filterSearchResults$ | async)"
<ds-filter-input-suggestions
*ngIf="(isLastPage$ | async) === false"
[suggestions]="(filterSearchResults$ | async)"
[placeholder]="'search.filters.filter.' + filterConfig.name + '.placeholder' | translate"
[label]="'search.filters.filter.' + filterConfig.name + '.label' | translate"
[action]="currentUrl"
Expand All @@ -26,6 +28,5 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="(isAvailableForShowSearchText | async) === false"
ngDefaultControl></ds-filter-input-suggestions>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
*/
isLastPage$: BehaviorSubject<boolean> = new BehaviorSubject(false);

/**
* Emits true if show the search text
*/
isAvailableForShowSearchText: BehaviorSubject<boolean> = new BehaviorSubject(false);
/**
* The value of the input field that is used to query for possible values for this filter
*/
Expand Down Expand Up @@ -293,8 +289,6 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
getFirstSucceededRemoteDataPayload(),
tap((facetValues: FacetValues) => {
this.isLastPage$.next(hasNoValue(facetValues?.next));
const hasLimitFacets = facetValues?.page?.length < facetValues?.facetLimit;
this.isAvailableForShowSearchText.next(hasLimitFacets && hasNoValue(facetValues?.next));
}),
)),
map((newFacetValues: FacetValues) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
</a>
</div>
</div>
<ds-filter-input-suggestions [suggestions]="(filterSearchResults$ | async)"
<ds-filter-input-suggestions
*ngIf="(isLastPage$ | async) === false"
[suggestions]="(filterSearchResults$ | async)"
[placeholder]="'search.filters.filter.' + filterConfig.name + '.placeholder' | translate"
[label]="'search.filters.filter.' + filterConfig.name + '.label' | translate"
[action]="currentUrl"
Expand All @@ -26,7 +28,6 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="(isAvailableForShowSearchText | async) === false"
ngDefaultControl
></ds-filter-input-suggestions>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ describe('SearchHierarchyFilterComponent', () => {
showVocabularyTreeLink = fixture.debugElement.query(By.css(`a#show-${testSearchFilter}-tree`));
}

describe('if the last page of facet values has been reached', () => {
beforeEach(() => {
spyOn(vocabularyService, 'searchTopEntries').and.returnValue(observableOf(new RemoteData(
undefined, 0, 0, RequestEntryState.Success, undefined, buildPaginatedList(new PageInfo(), []), 200,
)));
init();
});

it('should not show the search bar', () => {
comp.isLastPage$ = new BehaviorSubject(true);
fixture.detectChanges();
const textSearchBar = fixture.debugElement.query(By.css('ds-filter-input-suggestions'));
expect(textSearchBar).toBeNull();
});
});

describe('if the vocabulary doesn\'t exist', () => {

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
</a>
</div>
</div>
<ds-filter-input-suggestions [suggestions]="(filterSearchResults$ | async)"
<ds-filter-input-suggestions
*ngIf="(isLastPage$ | async) === false"
[suggestions]="(filterSearchResults$ | async)"
[placeholder]="'search.filters.filter.' + filterConfig.name + '.placeholder' | translate"
[label]="'search.filters.filter.' + filterConfig.name + '.label' | translate"
[action]="currentUrl"
Expand All @@ -26,6 +28,5 @@
(submitSuggestion)="onSubmit($event)"
(clickSuggestion)="onClick($event)"
(findSuggestions)="findSuggestions($event)"
*ngIf="(isAvailableForShowSearchText | async) === false"
ngDefaultControl></ds-filter-input-suggestions>
</div>
Loading