mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Fix: cleanup saved view references on custom field deletion, auto-refresh views, show error on saved view save (#9225)
This commit is contained in:
@@ -376,7 +376,7 @@ describe('DocumentListComponent', () => {
|
||||
expect(documentListService.selected.size).toEqual(3)
|
||||
})
|
||||
|
||||
it('should support saving an edited view', () => {
|
||||
it('should support saving a view', () => {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
name: 'Saved View 10',
|
||||
@@ -414,6 +414,30 @@ describe('DocumentListComponent', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('should handle error on view saving', () => {
|
||||
component.list.activateSavedView({
|
||||
id: 10,
|
||||
name: 'Saved View 10',
|
||||
sort_field: 'added',
|
||||
sort_reverse: true,
|
||||
filter_rules: [
|
||||
{
|
||||
rule_type: FILTER_HAS_TAGS_ANY,
|
||||
value: '20',
|
||||
},
|
||||
],
|
||||
})
|
||||
const toastErrorSpy = jest.spyOn(toastService, 'showError')
|
||||
jest
|
||||
.spyOn(savedViewService, 'patch')
|
||||
.mockReturnValueOnce(throwError(() => new Error('Error saving view')))
|
||||
component.saveViewConfig()
|
||||
expect(toastErrorSpy).toHaveBeenCalledWith(
|
||||
'Failed to save view "Saved View 10".',
|
||||
expect.any(Error)
|
||||
)
|
||||
})
|
||||
|
||||
it('should support edited view saving as', () => {
|
||||
const view: SavedView = {
|
||||
id: 10,
|
||||
|
@@ -377,12 +377,20 @@ export class DocumentListComponent
|
||||
this.savedViewService
|
||||
.patch(savedView)
|
||||
.pipe(first())
|
||||
.subscribe((view) => {
|
||||
this.unmodifiedSavedView = view
|
||||
this.toastService.showInfo(
|
||||
$localize`View "${this.list.activeSavedViewTitle}" saved successfully.`
|
||||
)
|
||||
this.unmodifiedFilterRules = this.list.filterRules
|
||||
.subscribe({
|
||||
next: (view) => {
|
||||
this.unmodifiedSavedView = view
|
||||
this.toastService.showInfo(
|
||||
$localize`View "${this.list.activeSavedViewTitle}" saved successfully.`
|
||||
)
|
||||
this.unmodifiedFilterRules = this.list.filterRules
|
||||
},
|
||||
error: (err) => {
|
||||
this.toastService.showError(
|
||||
$localize`Failed to save view "${this.list.activeSavedViewTitle}".`,
|
||||
err
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import { DocumentListViewService } from 'src/app/services/document-list-view.ser
|
||||
import { PermissionsService } from 'src/app/services/permissions.service'
|
||||
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
|
||||
@@ -50,7 +51,8 @@ export class CustomFieldsComponent
|
||||
private toastService: ToastService,
|
||||
private documentListViewService: DocumentListViewService,
|
||||
private settingsService: SettingsService,
|
||||
private documentService: DocumentService
|
||||
private documentService: DocumentService,
|
||||
private savedViewService: SavedViewService
|
||||
) {
|
||||
super()
|
||||
}
|
||||
@@ -115,6 +117,7 @@ export class CustomFieldsComponent
|
||||
this.customFieldsService.clearCache()
|
||||
this.settingsService.initializeDisplayFields()
|
||||
this.documentService.reload()
|
||||
this.savedViewService.reload()
|
||||
this.reload()
|
||||
},
|
||||
error: (e) => {
|
||||
|
Reference in New Issue
Block a user