mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-04-21 07:19:26 +00:00
Add a reset filters
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
i18n-info
|
||||
>
|
||||
<div class="btn-toolbar col col-md-auto align-items-center gap-2">
|
||||
@if (isFiltered) {
|
||||
<button class="btn btn-link py-0" (click)="resetFilters()">
|
||||
<i-bs width="1em" height="1em" name="x"></i-bs><small i18n>Reset filters</small>
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-sm btn-outline-secondary me-2" (click)="clearSelection()" [hidden]="selectedTasks.size === 0">
|
||||
<i-bs name="x" class="me-1"></i-bs><ng-container i18n>Clear selection</ng-container>
|
||||
</button>
|
||||
|
||||
@@ -249,6 +249,24 @@ describe('TasksComponent', () => {
|
||||
).toBe(PaperlessTaskTriggerSource.EmailConsume)
|
||||
})
|
||||
|
||||
it('should reset all active filters together', () => {
|
||||
component.setSection(TaskSection.InProgress)
|
||||
component.setTaskType(PaperlessTaskType.SanityCheck)
|
||||
component.setTriggerSource(PaperlessTaskTriggerSource.System)
|
||||
component.filterText = 'system'
|
||||
jest.advanceTimersByTime(150)
|
||||
|
||||
expect(component.isFiltered).toBe(true)
|
||||
|
||||
component.resetFilters()
|
||||
|
||||
expect(component.selectedSection).toBe(ALL_TASK_SECTIONS)
|
||||
expect(component.selectedTaskType).toBe(ALL_FILTER_VALUE)
|
||||
expect(component.selectedTriggerSource).toBe(ALL_FILTER_VALUE)
|
||||
expect(component.filterText).toBe('')
|
||||
expect(component.isFiltered).toBe(false)
|
||||
})
|
||||
|
||||
it('should expose stable task type options and disable empty ones', () => {
|
||||
expect(component.taskTypeOptions.map((option) => option.value)).toContain(
|
||||
PaperlessTaskType.TrainClassifier
|
||||
|
||||
@@ -215,6 +215,15 @@ export class TasksComponent
|
||||
)
|
||||
}
|
||||
|
||||
get isFiltered(): boolean {
|
||||
return (
|
||||
this.selectedSection !== ALL_TASK_SECTIONS ||
|
||||
this.selectedTaskType !== ALL_FILTER_VALUE ||
|
||||
this.selectedTriggerSource !== ALL_FILTER_VALUE ||
|
||||
this._filterText.length > 0
|
||||
)
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.tasksService.reload()
|
||||
timer(5000, 5000)
|
||||
@@ -431,6 +440,14 @@ export class TasksComponent
|
||||
this._filterText = ''
|
||||
}
|
||||
|
||||
public resetFilters() {
|
||||
this.selectedSection = ALL_TASK_SECTIONS
|
||||
this.selectedTaskType = ALL_FILTER_VALUE
|
||||
this.selectedTriggerSource = ALL_FILTER_VALUE
|
||||
this.resetFilter()
|
||||
this.clearSelection()
|
||||
}
|
||||
|
||||
filterInputKeyup(event: KeyboardEvent) {
|
||||
if (event.key == 'Enter') {
|
||||
this._filterText = (event.target as HTMLInputElement).value
|
||||
|
||||
Reference in New Issue
Block a user