mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	auto-select list filter field & clear on close
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
|   <div class="btn-group" ngbDropdown role="group"> | ||||
|   <div class="btn-group" ngbDropdown role="group" (openChange)="dropdownOpenChange($event)"> | ||||
|   <button class="btn btn-outline-primary btn-sm" id="dropdown{{title}}" ngbDropdownToggle>{{title}}</button> | ||||
|   <div class="dropdown-menu quick-filter shadow" ngbDropdownMenu attr.aria-labelledby="dropdown{{title}}"> | ||||
|     <div class="list-group list-group-flush"> | ||||
|       <input class="list-group-item form-control form-control-sm" type="text" [(ngModel)]="filterText" placeholder="Filter {{title}}"> | ||||
|       <input class="list-group-item form-control form-control-sm" type="text" [(ngModel)]="filterText" placeholder="Filter {{title}}" #filterTextInput> | ||||
|       <ng-container *ngIf="(items | filter: filterText).length > 0"> | ||||
|         <button class="list-group-item list-group-item-action d-flex align-items-center" role="menuitem" *ngFor="let item of items | filter: filterText; let i = index" (click)="toggleItem(item)"> | ||||
|           <div class="selected-icon mr-1"> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||||
| import { Component, EventEmitter, Input, OnInit, Output, ElementRef, ViewChild } from '@angular/core'; | ||||
| import { FilterRuleType, FILTER_RULE_TYPES } from 'src/app/data/filter-rule-type'; | ||||
| import { ObjectWithId } from 'src/app/data/object-with-id'; | ||||
|  | ||||
| @@ -17,6 +17,8 @@ export class FilterDropdownComponent implements OnInit { | ||||
|   @Output() | ||||
|   toggle = new EventEmitter() | ||||
|  | ||||
|   @ViewChild('filterTextInput') filterTextInput: ElementRef | ||||
|  | ||||
|   items: ObjectWithId[] = [] | ||||
|   itemsActive: ObjectWithId[] = [] | ||||
|   title: string | ||||
| @@ -29,7 +31,17 @@ export class FilterDropdownComponent implements OnInit { | ||||
|     this.display = filterRuleType.datatype | ||||
|   } | ||||
|  | ||||
|   toggleItem(item: ObjectWithId) { | ||||
|   toggleItem(item: ObjectWithId): void { | ||||
|     this.toggle.emit(item) | ||||
|   } | ||||
|  | ||||
|   dropdownOpenChange(open: boolean): void { | ||||
|     if (open) { | ||||
|       setTimeout(() => { | ||||
|         this.filterTextInput.nativeElement.focus(); | ||||
|       }, 0); | ||||
|     } else { | ||||
|       this.filterText = '' | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon