Skip to content

Commit 6ca2dbd

Browse files
jcorrea97alinelariguet
authored andcommitted
fix(dynamic-search): limpa campo de busca rápida
limpa campo de busca rápida após pesquisa da busca avançada fixes DTHFUI-6660
1 parent 9ff2721 commit 6ca2dbd

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

projects/templates/src/lib/components/po-page-dynamic-search/po-page-dynamic-search.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<po-page-list
2+
#poPageList
23
[p-actions]="actions"
34
[p-breadcrumb]="breadcrumb"
45
[p-disclaimer-group]="disclaimerGroup"
@@ -10,7 +11,7 @@
1011
[p-filters]="filters"
1112
[p-keep-filters]="keepFilters"
1213
[p-literals]="advancedFilterLiterals"
13-
(p-search-event)="onAdvancedSearch($event)"
14+
(p-search-event)="onAdvancedSearch($event, true)"
1415
>
1516
</po-advanced-filter>
1617

projects/templates/src/lib/components/po-page-dynamic-search/po-page-dynamic-search.component.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,30 @@ describe('PoPageDynamicSearchComponent:', () => {
246246
expect(component['convertToFilters']).toHaveBeenCalledWith(filters);
247247
});
248248

249+
it(`onAdvancedSearch: should call 'clearInputSearch' if isAdvancedSearch is true`, () => {
250+
const fakeThis = {
251+
setDisclaimers: () => ['test'],
252+
_disclaimerGroup: {
253+
disclaimers: ['test']
254+
},
255+
setFilters: () => {},
256+
advancedSearch: {
257+
emit: () => {}
258+
},
259+
poPageList: {
260+
clearInputSearch: () => {}
261+
}
262+
};
263+
const filteredItems = { filter: 'fakeFilter', optionsService: 'fakeOptionsService' };
264+
const isAdvancedSearch = true;
265+
266+
spyOn(fakeThis.poPageList, 'clearInputSearch');
267+
268+
component.onAdvancedSearch.call(fakeThis, filteredItems, isAdvancedSearch);
269+
270+
expect(fakeThis.poPageList.clearInputSearch).toHaveBeenCalled();
271+
});
272+
249273
it(`setFilters: should update filters value if the objects are compatible`, () => {
250274
const filterThatWillBeApplied = { city: 'Ontario' };
251275
const formattedFilters = [{ property: 'city', value: 'Ontario' }];

projects/templates/src/lib/components/po-page-dynamic-search/po-page-dynamic-search.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
PoLanguageService,
99
PoPageFilter,
1010
PoDisclaimerGroupRemoveAction,
11-
PoComboOption
11+
PoComboOption,
12+
PoPageListComponent
1213
} from '@po-ui/ng-components';
1314

1415
import { capitalizeFirstLetter, getBrowserLanguage } from '../../utils/util';
@@ -44,6 +45,7 @@ type UrlOrPoCustomizationFunction = string | (() => PoPageDynamicSearchOptions);
4445
})
4546
export class PoPageDynamicSearchComponent extends PoPageDynamicSearchBaseComponent implements OnInit, OnDestroy {
4647
@ViewChild(PoAdvancedFilterComponent, { static: true }) poAdvancedFilter: PoAdvancedFilterComponent;
48+
@ViewChild(PoPageListComponent, { static: true }) poPageList: PoPageListComponent;
4749

4850
private loadSubscription: Subscription;
4951

@@ -147,14 +149,18 @@ export class PoPageDynamicSearchComponent extends PoPageDynamicSearchBaseCompone
147149
this.poAdvancedFilter.open();
148150
}
149151

150-
onAdvancedSearch(filteredItems) {
152+
onAdvancedSearch(filteredItems, isAdvancedSearch?) {
151153
const { filter, optionsService } = filteredItems;
152154

153155
this._disclaimerGroup.disclaimers = this.setDisclaimers(filter, optionsService);
154156

155157
this.setFilters(filter);
156158

157159
this.advancedSearch.emit(filter);
160+
161+
if (isAdvancedSearch) {
162+
this.poPageList.clearInputSearch();
163+
}
158164
}
159165

160166
private getDisclaimersWithoutQuickSearch() {

0 commit comments

Comments
 (0)