diff --git a/src-ui/src/app/components/common/input/select/select.component.html b/src-ui/src/app/components/common/input/select/select.component.html index b5fb6f2ed..1bcdeda84 100644 --- a/src-ui/src/app/components/common/input/select/select.component.html +++ b/src-ui/src/app/components/common/input/select/select.component.html @@ -1,30 +1,45 @@
-
- - - - + + (change)="onChange(value)" + (search)="onSearch($event)" + (focus)="clearLastSearchTerm()" + (clear)="clearLastSearchTerm()" + (blur)="onBlur()"> - -
+ + + + +
+ +
+
{{hint}} Suggestions:  diff --git a/src-ui/src/app/components/common/input/select/select.component.ts b/src-ui/src/app/components/common/input/select/select.component.ts index 878254318..921e3606c 100644 --- a/src-ui/src/app/components/common/input/select/select.component.ts +++ b/src-ui/src/app/components/common/input/select/select.component.ts @@ -39,6 +39,8 @@ export class SelectComponent extends AbstractInputComponent { public addItemRef: (name) => void + private _lastSearchTerm: string + get allowCreateNew(): boolean { return this.createNew.observers.length > 0 } @@ -52,7 +54,28 @@ export class SelectComponent extends AbstractInputComponent { } addItem(name: string) { - this.createNew.next(name) + if (name) this.createNew.next(name) + else this.createNew.next(this._lastSearchTerm) + this.clearLastSearchTerm() + } + + clickNew() { + this.createNew.next(this._lastSearchTerm) + this.clearLastSearchTerm() + } + + clearLastSearchTerm() { + this._lastSearchTerm = null + } + + onSearch($event) { + this._lastSearchTerm = $event.term + } + + onBlur() { + setTimeout(() => { + this.clearLastSearchTerm() + }, 3000); } } 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 b8d4f074e..72c2cf1a5 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 @@ -1,7 +1,7 @@
-
+
+ (search)="onSearch($event)" + (focus)="clearLastSearchTerm()" + (clear)="clearLastSearchTerm()" + (blur)="onBlur()"> @@ -26,6 +29,14 @@
+ +
+ +
{{hint}} 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 2ab6a02b5..8db444ba3 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,9 +56,11 @@ export class TagsComponent implements OnInit, ControlValueAccessor { value: number[] tags: PaperlessTag[] - + public createTagRef: (name) => void + private _lastSearchTerm: string + getTag(id) { if (this.tags) { return this.tags.find(tag => tag.id == id) @@ -81,6 +83,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor { var modal = this.modalService.open(TagEditDialogComponent, {backdrop: 'static'}) modal.componentInstance.dialogMode = 'create' if (name) modal.componentInstance.object = { name: name } + else if (this._lastSearchTerm) modal.componentInstance.object = { name: this._lastSearchTerm } modal.componentInstance.success.subscribe(newTag => { this.tagService.listAll().subscribe(tags => { this.tags = tags.results @@ -103,4 +106,18 @@ export class TagsComponent implements OnInit, ControlValueAccessor { this.onChange(this.value) } + clearLastSearchTerm() { + this._lastSearchTerm = null + } + + onSearch($event) { + this._lastSearchTerm = $event.term + } + + onBlur() { + setTimeout(() => { + this.clearLastSearchTerm() + }, 3000); + } + } diff --git a/src-ui/src/styles.scss b/src-ui/src/styles.scss index 8c48dcddc..34f575a05 100644 --- a/src-ui/src/styles.scss +++ b/src-ui/src/styles.scss @@ -77,6 +77,8 @@ body { .ng-select-container { height: 100%; + border-top-right-radius: 0; + border-bottom-right-radius: 0; .ng-value-container .ng-input { top: 10px;