Skip to content

Commit

Permalink
Reset all filters on destroying a table or a card component (eclipse-…
Browse files Browse the repository at this point in the history
  • Loading branch information
sha4be authored Jul 25, 2024
1 parent de4083a commit ca3ac94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit<% i

<% if (options.enableRemoteDataHandling || options.hasSearchBar ) { %>
ngOnDestroy() {
<% if (options.hasSearchBar) { %>
this.filterService.searchString.setValue('');
<% if (options.hasSearchBar || options.isEnumQuickFilter || options.isDateQuickFilter) { %>
this.filterService.reset();
<% } %>

this.destroy$.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ export class <%= classify(name) %>FilterService {
<% } %>

<% if (options.hasSearchBar || options.isEnumQuickFilter || options.isDateQuickFilter) { %>
reset(): void {
const appliedFilters = [...this.activeFilters];

appliedFilters.forEach((filter) => {
this.resetFilter(filter)
})
}

/** Removes a specific filter. */
removeFilter(filter:FilterType) {
switch(filter.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ export class <%= classify(name) %>Component implements OnInit, AfterViewInit, Af

<% if (options.hasSearchBar || options.enableRemoteDataHandling) { %>
ngOnDestroy(): void {
<% if (options.hasSearchBar) { %>this.filterService.searchString.setValue('');<% } %>
<% if (options.hasSearchBar || options.isEnumQuickFilter || options.isDateQuickFilter) { %>
this.filterService.reset();
<% } %>
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
Expand Down

0 comments on commit ca3ac94

Please sign in to comment.