mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Support passing current term from tag search to create dialog
This commit is contained in:
		| @@ -8,7 +8,8 @@ | ||||
|       [clearSearchOnAdd]="true" | ||||
|       [hideSelected]="true" | ||||
|       (change)="onChange(value)" | ||||
|       (blur)="onTouched()"> | ||||
|       (search)="onSearch($event)" | ||||
|       (focus)="onFocus()"> | ||||
|  | ||||
|       <ng-template ng-label-tmp let-item="item"> | ||||
|         <span class="tag-wrap tag-wrap-delete" (click)="removeTag(item.id)"> | ||||
| @@ -39,8 +40,8 @@ | ||||
|     <ng-container *ngFor="let tag of getSuggestions()"> | ||||
|       <a (click)="addTag(tag.id)" [routerLink]="">{{tag.name}}</a>  | ||||
|     </ng-container> | ||||
|      | ||||
|      | ||||
|  | ||||
|  | ||||
|   </small> | ||||
|  | ||||
| </div> | ||||
|   | ||||
| @@ -56,6 +56,8 @@ export class TagsComponent implements OnInit, ControlValueAccessor { | ||||
|  | ||||
|   tags: PaperlessTag[] | ||||
|  | ||||
|   private _lastSearchTerm: string | ||||
|  | ||||
|   getTag(id) { | ||||
|     if (this.tags) { | ||||
|       return this.tags.find(tag => tag.id == id) | ||||
| @@ -77,6 +79,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor { | ||||
|   createTag() { | ||||
|     var modal = this.modalService.open(TagEditDialogComponent, {backdrop: 'static'}) | ||||
|     modal.componentInstance.dialogMode = 'create' | ||||
|     if (this._lastSearchTerm) modal.componentInstance.object = { name: this._lastSearchTerm } | ||||
|     modal.componentInstance.success.subscribe(newTag => { | ||||
|       this.tagService.listAll().subscribe(tags => { | ||||
|         this.tags = tags.results | ||||
| @@ -84,6 +87,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor { | ||||
|         this.onChange(this.value) | ||||
|       }) | ||||
|     }) | ||||
|     modal.result.then(() => { | ||||
|       this._lastSearchTerm = null | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   getSuggestions() { | ||||
| @@ -99,4 +105,12 @@ export class TagsComponent implements OnInit, ControlValueAccessor { | ||||
|     this.onChange(this.value) | ||||
|   } | ||||
|  | ||||
|   onFocus() { | ||||
|     this._lastSearchTerm = null | ||||
|   } | ||||
|  | ||||
|   onSearch($event) { | ||||
|     this._lastSearchTerm = $event.term | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon