mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #616 from paperless-ngx/fix-save-vew-modal-errors
fix some api error displaying
This commit is contained in:
commit
bf7002d0ae
@ -100,7 +100,7 @@
|
|||||||
<ng-container *ngTemplateOutlet="pagination"></ng-container>
|
<ng-container *ngTemplateOutlet="pagination"></ng-container>
|
||||||
|
|
||||||
<ng-container *ngIf="list.error ; else documentListNoError">
|
<ng-container *ngIf="list.error ; else documentListNoError">
|
||||||
<div class="alert alert-danger" role="alert">Error while loading documents: {{list.error}}</div>
|
<div class="alert alert-danger" role="alert"><ng-container i18n>Error while loading documents</ng-container>: {{list.error}}</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-template #documentListNoError>
|
<ng-template #documentListNoError>
|
||||||
|
@ -243,8 +243,12 @@ export class DocumentListComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
$localize`View "${savedView.name}" created successfully.`
|
$localize`View "${savedView.name}" created successfully.`
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (httpError) => {
|
||||||
modal.componentInstance.error = error.error
|
let error = httpError.error
|
||||||
|
if (error.filter_rules) {
|
||||||
|
error.filter_rules = error.filter_rules.map((r) => r.value)
|
||||||
|
}
|
||||||
|
modal.componentInstance.error = error
|
||||||
modal.componentInstance.buttonsEnabled = true
|
modal.componentInstance.buttonsEnabled = true
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
<app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
|
<app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
|
||||||
<app-input-check i18n-title title="Show in sidebar" formControlName="showInSideBar"></app-input-check>
|
<app-input-check i18n-title title="Show in sidebar" formControlName="showInSideBar"></app-input-check>
|
||||||
<app-input-check i18n-title title="Show on dashboard" formControlName="showOnDashboard"></app-input-check>
|
<app-input-check i18n-title title="Show on dashboard" formControlName="showOnDashboard"></app-input-check>
|
||||||
|
<div *ngIf="error?.filter_rules" class="alert alert-danger" role="alert">
|
||||||
|
<h6 class="alert-heading" i18n>Filter rules error occurred while saving this view</h6>
|
||||||
|
<ng-container i18n>The error returned was</ng-container>:<br/>
|
||||||
|
{{ error.filter_rules }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-outline-dark" (click)="cancel()" i18n [disabled]="!buttonsEnabled">Cancel</button>
|
<button type="button" class="btn btn-outline-dark" (click)="cancel()" i18n [disabled]="!buttonsEnabled">Cancel</button>
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
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'
|
||||||
import { DocumentService } from './rest/document.service'
|
import { DocumentService, DOCUMENT_SORT_FIELDS } from './rest/document.service'
|
||||||
import { SettingsService, SETTINGS_KEYS } from './settings.service'
|
import { SettingsService, SETTINGS_KEYS } from './settings.service'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,7 +160,21 @@ export class DocumentListViewService {
|
|||||||
activeListViewState.currentPage = 1
|
activeListViewState.currentPage = 1
|
||||||
this.reload()
|
this.reload()
|
||||||
} else {
|
} else {
|
||||||
this.error = error.error
|
let errorMessage
|
||||||
|
if (Object.keys(error.error).length > 0) {
|
||||||
|
// e.g. { archive_serial_number: Array<string> }
|
||||||
|
errorMessage = Object.keys(error.error)
|
||||||
|
.map((fieldName) => {
|
||||||
|
const fieldError: Array<string> = error.error[fieldName]
|
||||||
|
return `${
|
||||||
|
DOCUMENT_SORT_FIELDS.find((f) => f.field == fieldName)?.name
|
||||||
|
}: ${fieldError[0]}`
|
||||||
|
})
|
||||||
|
.join(', ')
|
||||||
|
} else {
|
||||||
|
errorMessage = error.error
|
||||||
|
}
|
||||||
|
this.error = errorMessage
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user