mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	error messages for invalid search queries
This commit is contained in:
		| @@ -89,86 +89,95 @@ | |||||||
|   [rotate]="true" aria-label="Default pagination"></ngb-pagination> |   [rotate]="true" aria-label="Default pagination"></ngb-pagination> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <div *ngIf="displayMode == 'largeCards'"> | <ng-container *ngIf="list.error ; else documentListNoError"> | ||||||
|   <app-document-card-large [selected]="list.isSelected(d)" (toggleSelected)="toggleSelected(d, $event)" *ngFor="let d of list.documents; trackBy: trackByDocumentId" [document]="d" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)" (clickDocumentType)="clickDocumentType($event)" (clickMoreLike)="clickMoreLike(d.id)"> |   <div class="alert alert-danger" role="alert">Error while loading documents: {{list.error}}</div> | ||||||
|   </app-document-card-large> | </ng-container> | ||||||
| </div> |  | ||||||
|  |  | ||||||
| <table class="table table-sm border shadow-sm" *ngIf="displayMode == 'details'"> | <ng-template #documentListNoError> | ||||||
|   <thead> |  | ||||||
|     <th></th> |  | ||||||
|     <th class="d-none d-lg-table-cell" |  | ||||||
|       sortable="archive_serial_number" |  | ||||||
|       [currentSortField]="list.sortField" |  | ||||||
|       [currentSortReverse]="list.sortReverse" |  | ||||||
|       (sort)="onSort($event)" |  | ||||||
|       i18n>ASN</th> |  | ||||||
|     <th class="d-none d-md-table-cell" |  | ||||||
|       sortable="correspondent__name" |  | ||||||
|       [currentSortField]="list.sortField" |  | ||||||
|       [currentSortReverse]="list.sortReverse" |  | ||||||
|       (sort)="onSort($event)" |  | ||||||
|       i18n>Correspondent</th> |  | ||||||
|     <th |  | ||||||
|       sortable="title" |  | ||||||
|       [currentSortField]="list.sortField" |  | ||||||
|       [currentSortReverse]="list.sortReverse" |  | ||||||
|       (sort)="onSort($event)" |  | ||||||
|       i18n>Title</th> |  | ||||||
|     <th class="d-none d-xl-table-cell" |  | ||||||
|       sortable="document_type__name" |  | ||||||
|       [currentSortField]="list.sortField" |  | ||||||
|       [currentSortReverse]="list.sortReverse" |  | ||||||
|       (sort)="onSort($event)" |  | ||||||
|       i18n>Document type</th> |  | ||||||
|     <th |  | ||||||
|       sortable="created" |  | ||||||
|       [currentSortField]="list.sortField" |  | ||||||
|       [currentSortReverse]="list.sortReverse" |  | ||||||
|       (sort)="onSort($event)" |  | ||||||
|       i18n>Created</th> |  | ||||||
|     <th class="d-none d-xl-table-cell" |  | ||||||
|       sortable="added" |  | ||||||
|       [currentSortField]="list.sortField" |  | ||||||
|       [currentSortReverse]="list.sortReverse" |  | ||||||
|       (sort)="onSort($event)" |  | ||||||
|       i18n>Added</th> |  | ||||||
|   </thead> |  | ||||||
|   <tbody> |  | ||||||
|     <tr *ngFor="let d of list.documents; trackBy: trackByDocumentId" (click)="toggleSelected(d, $event)" [ngClass]="list.isSelected(d) ? 'table-row-selected' : ''"> |  | ||||||
|       <td> |  | ||||||
|         <div class="custom-control custom-checkbox"> |  | ||||||
|           <input type="checkbox" class="custom-control-input" id="docCheck{{d.id}}" [checked]="list.isSelected(d)" (click)="toggleSelected(d, $event)"> |  | ||||||
|           <label class="custom-control-label" for="docCheck{{d.id}}"></label> |  | ||||||
|         </div> |  | ||||||
|       </td> |  | ||||||
|       <td class="d-none d-lg-table-cell"> |  | ||||||
|         {{d.archive_serial_number}} |  | ||||||
|       </td> |  | ||||||
|       <td class="d-none d-md-table-cell"> |  | ||||||
|         <ng-container *ngIf="d.correspondent"> |  | ||||||
|           <a [routerLink]="" (click)="clickCorrespondent(d.correspondent);$event.stopPropagation()" title="Filter by correspondent">{{(d.correspondent$ | async)?.name}}</a> |  | ||||||
|         </ng-container> |  | ||||||
|       </td> |  | ||||||
|       <td> |  | ||||||
|         <a routerLink="/documents/{{d.id}}" title="Edit document" style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a> |  | ||||||
|         <app-tag [tag]="t" *ngFor="let t of d.tags$ | async" class="ml-1" clickable="true" linkTitle="Filter by tag" (click)="clickTag(t.id);$event.stopPropagation()"></app-tag> |  | ||||||
|       </td> |  | ||||||
|       <td class="d-none d-xl-table-cell"> |  | ||||||
|         <ng-container *ngIf="d.document_type"> |  | ||||||
|           <a [routerLink]="" (click)="clickDocumentType(d.document_type);$event.stopPropagation()" title="Filter by document type">{{(d.document_type$ | async)?.name}}</a> |  | ||||||
|         </ng-container> |  | ||||||
|       </td> |  | ||||||
|       <td> |  | ||||||
|         {{d.created | customDate}} |  | ||||||
|       </td> |  | ||||||
|       <td class="d-none d-xl-table-cell"> |  | ||||||
|         {{d.added | customDate}} |  | ||||||
|       </td> |  | ||||||
|     </tr> |  | ||||||
|   </tbody> |  | ||||||
| </table> |  | ||||||
|  |  | ||||||
| <div class="m-n2 row row-cols-paperless-cards" *ngIf="displayMode == 'smallCards'"> |   <div *ngIf="displayMode == 'largeCards'"> | ||||||
|   <app-document-card-small [selected]="list.isSelected(d)" (toggleSelected)="toggleSelected(d, $event)" [document]="d" *ngFor="let d of list.documents; trackBy: trackByDocumentId" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)" (clickDocumentType)="clickDocumentType($event)"></app-document-card-small> |     <app-document-card-large [selected]="list.isSelected(d)" (toggleSelected)="toggleSelected(d, $event)" *ngFor="let d of list.documents; trackBy: trackByDocumentId" [document]="d" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)" (clickDocumentType)="clickDocumentType($event)" (clickMoreLike)="clickMoreLike(d.id)"> | ||||||
| </div> |     </app-document-card-large> | ||||||
|  |   </div> | ||||||
|  |    | ||||||
|  |   <table class="table table-sm border shadow-sm" *ngIf="displayMode == 'details'"> | ||||||
|  |     <thead> | ||||||
|  |       <th></th> | ||||||
|  |       <th class="d-none d-lg-table-cell" | ||||||
|  |         sortable="archive_serial_number" | ||||||
|  |         [currentSortField]="list.sortField" | ||||||
|  |         [currentSortReverse]="list.sortReverse" | ||||||
|  |         (sort)="onSort($event)" | ||||||
|  |         i18n>ASN</th> | ||||||
|  |       <th class="d-none d-md-table-cell" | ||||||
|  |         sortable="correspondent__name" | ||||||
|  |         [currentSortField]="list.sortField" | ||||||
|  |         [currentSortReverse]="list.sortReverse" | ||||||
|  |         (sort)="onSort($event)" | ||||||
|  |         i18n>Correspondent</th> | ||||||
|  |       <th | ||||||
|  |         sortable="title" | ||||||
|  |         [currentSortField]="list.sortField" | ||||||
|  |         [currentSortReverse]="list.sortReverse" | ||||||
|  |         (sort)="onSort($event)" | ||||||
|  |         i18n>Title</th> | ||||||
|  |       <th class="d-none d-xl-table-cell" | ||||||
|  |         sortable="document_type__name" | ||||||
|  |         [currentSortField]="list.sortField" | ||||||
|  |         [currentSortReverse]="list.sortReverse" | ||||||
|  |         (sort)="onSort($event)" | ||||||
|  |         i18n>Document type</th> | ||||||
|  |       <th | ||||||
|  |         sortable="created" | ||||||
|  |         [currentSortField]="list.sortField" | ||||||
|  |         [currentSortReverse]="list.sortReverse" | ||||||
|  |         (sort)="onSort($event)" | ||||||
|  |         i18n>Created</th> | ||||||
|  |       <th class="d-none d-xl-table-cell" | ||||||
|  |         sortable="added" | ||||||
|  |         [currentSortField]="list.sortField" | ||||||
|  |         [currentSortReverse]="list.sortReverse" | ||||||
|  |         (sort)="onSort($event)" | ||||||
|  |         i18n>Added</th> | ||||||
|  |     </thead> | ||||||
|  |     <tbody> | ||||||
|  |       <tr *ngFor="let d of list.documents; trackBy: trackByDocumentId" (click)="toggleSelected(d, $event)" [ngClass]="list.isSelected(d) ? 'table-row-selected' : ''"> | ||||||
|  |         <td> | ||||||
|  |           <div class="custom-control custom-checkbox"> | ||||||
|  |             <input type="checkbox" class="custom-control-input" id="docCheck{{d.id}}" [checked]="list.isSelected(d)" (click)="toggleSelected(d, $event)"> | ||||||
|  |             <label class="custom-control-label" for="docCheck{{d.id}}"></label> | ||||||
|  |           </div> | ||||||
|  |         </td> | ||||||
|  |         <td class="d-none d-lg-table-cell"> | ||||||
|  |           {{d.archive_serial_number}} | ||||||
|  |         </td> | ||||||
|  |         <td class="d-none d-md-table-cell"> | ||||||
|  |           <ng-container *ngIf="d.correspondent"> | ||||||
|  |             <a [routerLink]="" (click)="clickCorrespondent(d.correspondent);$event.stopPropagation()" title="Filter by correspondent">{{(d.correspondent$ | async)?.name}}</a> | ||||||
|  |           </ng-container> | ||||||
|  |         </td> | ||||||
|  |         <td> | ||||||
|  |           <a routerLink="/documents/{{d.id}}" title="Edit document" style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a> | ||||||
|  |           <app-tag [tag]="t" *ngFor="let t of d.tags$ | async" class="ml-1" clickable="true" linkTitle="Filter by tag" (click)="clickTag(t.id);$event.stopPropagation()"></app-tag> | ||||||
|  |         </td> | ||||||
|  |         <td class="d-none d-xl-table-cell"> | ||||||
|  |           <ng-container *ngIf="d.document_type"> | ||||||
|  |             <a [routerLink]="" (click)="clickDocumentType(d.document_type);$event.stopPropagation()" title="Filter by document type">{{(d.document_type$ | async)?.name}}</a> | ||||||
|  |           </ng-container> | ||||||
|  |         </td> | ||||||
|  |         <td> | ||||||
|  |           {{d.created | customDate}} | ||||||
|  |         </td> | ||||||
|  |         <td class="d-none d-xl-table-cell"> | ||||||
|  |           {{d.added | customDate}} | ||||||
|  |         </td> | ||||||
|  |       </tr> | ||||||
|  |     </tbody> | ||||||
|  |   </table> | ||||||
|  |    | ||||||
|  |   <div class="m-n2 row row-cols-paperless-cards" *ngIf="displayMode == 'smallCards'"> | ||||||
|  |     <app-document-card-small [selected]="list.isSelected(d)" (toggleSelected)="toggleSelected(d, $event)" [document]="d" *ngFor="let d of list.documents; trackBy: trackByDocumentId" (clickTag)="clickTag($event)" (clickCorrespondent)="clickCorrespondent($event)" (clickDocumentType)="clickDocumentType($event)"></app-document-card-small> | ||||||
|  |   </div> | ||||||
|  |    | ||||||
|  |  | ||||||
|  | </ng-template> | ||||||
|   | |||||||
| @@ -1,9 +1,7 @@ | |||||||
| import { Route } from '@angular/compiler/src/core'; |  | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { ActivatedRoute, Router } from '@angular/router'; | import { ActivatedRoute, Router } from '@angular/router'; | ||||||
| import { Observable } from 'rxjs'; | import { Observable } from 'rxjs'; | ||||||
| import { cloneFilterRules, FilterRule } from '../data/filter-rule'; | import { cloneFilterRules, FilterRule } from '../data/filter-rule'; | ||||||
| import { FILTER_FULLTEXT_MORELIKE, FILTER_FULLTEXT_QUERY } from '../data/filter-rule-type'; |  | ||||||
| import { PaperlessDocument } from '../data/paperless-document'; | import { PaperlessDocument } from '../data/paperless-document'; | ||||||
| import { PaperlessSavedView } from '../data/paperless-saved-view'; | import { PaperlessSavedView } from '../data/paperless-saved-view'; | ||||||
| import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'; | import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'; | ||||||
| @@ -40,6 +38,7 @@ interface ListViewState { | |||||||
| export class DocumentListViewService { | export class DocumentListViewService { | ||||||
|  |  | ||||||
|   isReloading: boolean = false |   isReloading: boolean = false | ||||||
|  |   error: string = null | ||||||
|  |  | ||||||
|   rangeSelectionAnchorIndex: number |   rangeSelectionAnchorIndex: number | ||||||
|   lastRangeSelectionToIndex: number |   lastRangeSelectionToIndex: number | ||||||
| @@ -103,6 +102,7 @@ export class DocumentListViewService { | |||||||
|  |  | ||||||
|   reload(onFinish?) { |   reload(onFinish?) { | ||||||
|     this.isReloading = true |     this.isReloading = true | ||||||
|  |     this.error = null | ||||||
|     let activeListViewState = this.activeListViewState |     let activeListViewState = this.activeListViewState | ||||||
|  |  | ||||||
|     this.documentService.listFiltered( |     this.documentService.listFiltered( | ||||||
| @@ -126,6 +126,8 @@ export class DocumentListViewService { | |||||||
|             // this happens when applying a filter: the current page might not be available anymore due to the reduced result set. |             // this happens when applying a filter: the current page might not be available anymore due to the reduced result set. | ||||||
|             activeListViewState.currentPage = 1 |             activeListViewState.currentPage = 1 | ||||||
|             this.reload() |             this.reload() | ||||||
|  |           } else { | ||||||
|  |             this.error = error.error | ||||||
|           } |           } | ||||||
|         }) |         }) | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler