Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Support passing current term from tag search to create dialog

Michael Shamooncd72ed2cec82
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.html b/src-ui/src/app/components/common/input/tags/tags.component.html
index 677b9f4d1..5500930bb 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.html
+++ b/src-ui/src/app/components/common/input/tags/tags.component.html
@@ -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>&nbsp;
</ng-container>
-
-
+
+
</small>
</div>
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.ts b/src-ui/src/app/components/common/input/tags/tags.component.ts
index f77d0570d..336341bc3 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.ts
+++ b/src-ui/src/app/components/common/input/tags/tags.component.ts
@@ -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
+ }
+
}