Allow shorter search strings with Enter key

This commit is contained in:
Michael Shamoon 2022-03-18 23:30:26 -07:00
parent ff4538612e
commit 39daddef34
2 changed files with 17 additions and 6 deletions

View File

@ -8,7 +8,7 @@
<button *ngFor="let t of textFilterTargets" ngbDropdownItem [class.active]="textFilterTarget == t.id" (click)="changeTextFilterTarget(t.id)">{{t.name}}</button> <button *ngFor="let t of textFilterTargets" ngbDropdownItem [class.active]="textFilterTarget == t.id" (click)="changeTextFilterTarget(t.id)">{{t.name}}</button>
</div> </div>
</div> </div>
<input #textFilterInput class="form-control form-control-sm" type="text" [(ngModel)]="textFilter" [readonly]="textFilterTarget == 'fulltext-morelike'"> <input #textFilterInput class="form-control form-control-sm" type="text" [(ngModel)]="textFilter" (keyup.enter)="textFilterEnter()" [readonly]="textFilterTarget == 'fulltext-morelike'">
</div> </div>
</div> </div>
</div> </div>

View File

@ -427,11 +427,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
distinctUntilChanged(), distinctUntilChanged(),
filter((query) => !query.length || query.length > 2) filter((query) => !query.length || query.length > 2)
) )
.subscribe((text) => { .subscribe((text) => this.updateTextFilter(text))
this._textFilter = text
this.documentService.searchQuery = text
this.updateRules()
})
if (this._textFilter) this.documentService.searchQuery = this._textFilter if (this._textFilter) this.documentService.searchQuery = this._textFilter
} }
@ -476,6 +472,21 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
this.documentTypeSelectionModel.apply() this.documentTypeSelectionModel.apply()
} }
updateTextFilter(text) {
this._textFilter = text
this.documentService.searchQuery = text
this.updateRules()
}
textFilterEnter() {
const filterString = (
this.textFilterInput.nativeElement as HTMLInputElement
).value
if (filterString.length) {
this.updateTextFilter(filterString)
}
}
changeTextFilterTarget(target) { changeTextFilterTarget(target) {
if ( if (
this.textFilterTarget == TEXT_FILTER_TARGET_FULLTEXT_MORELIKE && this.textFilterTarget == TEXT_FILTER_TARGET_FULLTEXT_MORELIKE &&