mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-11 17:17:26 +01:00
Refactor to use ng-select addTag function
This commit is contained in:
parent
9514e79bfb
commit
026c213ea4
5 changed files with 32 additions and 69 deletions
|
|
@ -16,6 +16,7 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||
|
||||
constructor() {
|
||||
super()
|
||||
this.addItemRef = this.addItem.bind(this)
|
||||
}
|
||||
|
||||
@Input()
|
||||
|
|
@ -36,9 +37,9 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||
@Output()
|
||||
createNew = new EventEmitter<string>()
|
||||
|
||||
private _lastSearchTerm: string
|
||||
public addItemRef: (name) => void
|
||||
|
||||
showPlusButton(): boolean {
|
||||
get allowCreateNew(): boolean {
|
||||
return this.createNew.observers.length > 0
|
||||
}
|
||||
|
||||
|
|
@ -50,23 +51,8 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||
}
|
||||
}
|
||||
|
||||
clickNew() {
|
||||
this.createNew.next(this._lastSearchTerm)
|
||||
this.clearLastSearchTerm()
|
||||
}
|
||||
|
||||
clearLastSearchTerm() {
|
||||
this._lastSearchTerm = null
|
||||
}
|
||||
|
||||
onSearch($event) {
|
||||
this._lastSearchTerm = $event.term
|
||||
}
|
||||
|
||||
onBlur() {
|
||||
setTimeout(() => {
|
||||
this.clearLastSearchTerm()
|
||||
}, 3000);
|
||||
addItem(name: string) {
|
||||
this.createNew.next(name)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue