Wired reset filters filter button in filter builder

closes https://github.com/TryGhost/Team/issues/964

Wires the "Reset" button in filter builder to clear all filters easily and see the original full list of members.
This commit is contained in:
Rishabh 2021-08-13 18:00:17 +05:30
parent f23e8bc801
commit 084380d155
4 changed files with 14 additions and 9 deletions

View File

@ -75,6 +75,7 @@
<div class="gh-filter-builder-footer">
<button
class="gh-btn"
{{on "click" this.resetFilter}}
>
<span>Reset all</span>
</button>

View File

@ -190,4 +190,9 @@ export default class GhMembersFilterLabsComponent extends Component {
const query = this.generateNqlFilter(this.filters);
this.args.onApplyFilter(query, this.filters);
}
@action
resetFilter() {
this.args.onResetFilter();
}
}

View File

@ -216,16 +216,14 @@ export default class MembersController extends Controller {
@action
applyFilter(filterStr, filters) {
this.filters = filters.filter((filter) => {
return filter.type !== 'name_email';
});
this.filters = filters;
this.filterParam = filterStr || null;
this.searchParam = null;
filters.forEach((filter) => {
if (filter.type === 'name_email' && filter.value) {
this.searchParam = filter.value;
}
});
}
@action
resetFilter() {
this.filters = A([]);
this.filterParam = null;
}
@action

View File

@ -32,6 +32,7 @@
{{#if (feature "membersFiltering")}}
<GhMembersFilterLabs
@onApplyFilter={{this.applyFilter}}
@onResetFilter={{this.resetFilter}}
@onLabelEdit={{this.editLabel}}
/>
{{/if}}