mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-5177] Search-header execute when enter is pressed (#5840)
* [ADF-5177] Filter execute on enter key down * [ADF-5177] Add unit test
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
<div (click)="onMenuClick($event)" class="adf-filter-container">
|
<div (click)="onMenuClick($event)" class="adf-filter-container">
|
||||||
<div class="adf-filter-title">{{ 'SEARCH.SEARCH_HEADER.TITLE' | translate }}</div>
|
<div class="adf-filter-title">{{ 'SEARCH.SEARCH_HEADER.TITLE' | translate }}</div>
|
||||||
<adf-search-widget-container
|
<adf-search-widget-container
|
||||||
|
(keydown.enter)="onApply()"
|
||||||
[id]="category?.id"
|
[id]="category?.id"
|
||||||
[selector]="category?.component?.selector"
|
[selector]="category?.component?.selector"
|
||||||
[settings]="category?.component?.settings">
|
[settings]="category?.component?.settings">
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button mat-button color="primary"
|
<button mat-button color="primary"
|
||||||
id="apply-filter-button"
|
id="apply-filter-button"
|
||||||
class="adf-filter-apply-button" (click)="onApplyButtonClick()">
|
class="adf-filter-apply-button" (click)="onApply()">
|
||||||
{{ 'SEARCH.SEARCH_HEADER.APPLY' | translate | uppercase }}
|
{{ 'SEARCH.SEARCH_HEADER.APPLY' | translate | uppercase }}
|
||||||
</button>
|
</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
@@ -84,7 +84,7 @@ describe('SearchHeaderComponent', () => {
|
|||||||
expect(element).not.toBeUndefined();
|
expect(element).not.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit the node paging received from the queryBuilder after the filter gets applied', async (done) => {
|
it('should emit the node paging received from the queryBuilder after the Apply button is clicked', async (done) => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
||||||
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
||||||
component.update.subscribe((newNodePaging) => {
|
component.update.subscribe((newNodePaging) => {
|
||||||
@@ -102,6 +102,24 @@ describe('SearchHeaderComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should emit the node paging received from the queryBuilder after the Enter key is pressed', async (done) => {
|
||||||
|
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
||||||
|
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
||||||
|
component.update.subscribe((newNodePaging) => {
|
||||||
|
expect(newNodePaging).toBe(fakeNodePaging);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('#filter-menu-button');
|
||||||
|
menuButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
component.widgetContainer.componentRef.instance.value = 'searchText';
|
||||||
|
const widgetContainer = fixture.debugElement.query(By.css('adf-search-widget-container'));
|
||||||
|
widgetContainer.triggerEventHandler('keydown.enter', {});
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
it('should execute a new query when the page size is changed', async (done) => {
|
it('should execute a new query when the page size is changed', async (done) => {
|
||||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
||||||
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
||||||
|
@@ -128,7 +128,7 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
onApplyButtonClick() {
|
onApply() {
|
||||||
// TODO Move this piece of code in the search text widget
|
// TODO Move this piece of code in the search text widget
|
||||||
if (this.widgetContainer.selector === 'text' && this.widgetContainer.componentRef.instance.value === '') {
|
if (this.widgetContainer.selector === 'text' && this.widgetContainer.componentRef.instance.value === '') {
|
||||||
this.clearHeader();
|
this.clearHeader();
|
||||||
|
Reference in New Issue
Block a user