mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	searching for tags, spelling corrections fixes #74
This commit is contained in:
		@@ -1,7 +1,13 @@
 | 
			
		||||
<app-page-header title="Search results">
 | 
			
		||||
</app-page-header>
 | 
			
		||||
 | 
			
		||||
<p>Search string: <i>{{query}}</i></p>
 | 
			
		||||
<p>
 | 
			
		||||
    Search string: <i>{{query}}</i>
 | 
			
		||||
    <ng-container *ngIf="correctedQuery">
 | 
			
		||||
        - Did you mean "<a [routerLink]="" (click)="searchCorrectedQuery()">{{correctedQuery}}</a>"?
 | 
			
		||||
    </ng-container>
 | 
			
		||||
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
<div [class.result-content-searching]="searching" infiniteScroll (scrolled)="onScroll()">
 | 
			
		||||
    <p>{{resultCount}} result(s)</p>
 | 
			
		||||
@@ -10,4 +16,4 @@
 | 
			
		||||
        [details]="result.highlights">
 | 
			
		||||
 | 
			
		||||
</app-document-card-large>
 | 
			
		||||
</div>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
import { ActivatedRoute } from '@angular/router';
 | 
			
		||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		||||
import { SearchHit } from 'src/app/data/search-result';
 | 
			
		||||
import { SearchService } from 'src/app/services/rest/search.service';
 | 
			
		||||
 | 
			
		||||
@@ -9,7 +9,7 @@ import { SearchService } from 'src/app/services/rest/search.service';
 | 
			
		||||
  styleUrls: ['./search.component.scss']
 | 
			
		||||
})
 | 
			
		||||
export class SearchComponent implements OnInit {
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  results: SearchHit[] = []
 | 
			
		||||
 | 
			
		||||
  query: string = ""
 | 
			
		||||
@@ -22,7 +22,9 @@ export class SearchComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
  resultCount
 | 
			
		||||
 | 
			
		||||
  constructor(private searchService: SearchService, private route: ActivatedRoute) { }
 | 
			
		||||
  correctedQuery: string = null
 | 
			
		||||
 | 
			
		||||
  constructor(private searchService: SearchService, private route: ActivatedRoute, private router: Router) { }
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
    this.route.queryParamMap.subscribe(paramMap => {
 | 
			
		||||
@@ -31,7 +33,12 @@ export class SearchComponent implements OnInit {
 | 
			
		||||
      this.currentPage = 1
 | 
			
		||||
      this.loadPage()
 | 
			
		||||
    })
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  searchCorrectedQuery() {
 | 
			
		||||
    this.router.navigate(["search"], {queryParams: {query: this.correctedQuery}})
 | 
			
		||||
    this.correctedQuery = null
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  loadPage(append: boolean = false) {
 | 
			
		||||
@@ -44,12 +51,11 @@ export class SearchComponent implements OnInit {
 | 
			
		||||
      this.pageCount = result.page_count
 | 
			
		||||
      this.searching = false
 | 
			
		||||
      this.resultCount = result.count
 | 
			
		||||
      this.correctedQuery = result.corrected_query
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onScroll() {
 | 
			
		||||
    console.log(this.currentPage)
 | 
			
		||||
    console.log(this.pageCount)
 | 
			
		||||
    if (this.currentPage < this.pageCount) {
 | 
			
		||||
      this.currentPage += 1
 | 
			
		||||
      this.loadPage(true)
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,9 @@ export interface SearchResult {
 | 
			
		||||
  page?: number
 | 
			
		||||
  page_count?: number
 | 
			
		||||
 | 
			
		||||
  corrected_query?: string
 | 
			
		||||
 | 
			
		||||
  results?: SearchHit[]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user