mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix: table view doesnt immediately display custom fields on app startup (#6600)
This commit is contained in:
parent
fae2399e46
commit
8ea3259fe7
@ -209,6 +209,7 @@ export class DocumentListComponent
|
||||
takeUntil(this.unsubscribeNotifier)
|
||||
)
|
||||
.subscribe((queryParams) => {
|
||||
this.updateDisplayCustomFields()
|
||||
if (queryParams.has('view')) {
|
||||
// loading a saved view on /documents
|
||||
this.loadViewConfig(parseInt(queryParams.get('view')))
|
||||
|
@ -591,4 +591,18 @@ describe('DocumentListViewService', () => {
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('should not filter out custom fields if settings not initialized', () => {
|
||||
const customFields = ['custom_field_1', 'custom_field_2']
|
||||
documentListViewService.displayFields = customFields as any
|
||||
settingsService.displayFieldsInitialized = false
|
||||
expect(documentListViewService.displayFields).toEqual(customFields)
|
||||
jest.spyOn(settingsService, 'allDisplayFields', 'get').mockReturnValue([
|
||||
{ id: DisplayField.ADDED, name: 'Added' },
|
||||
{ id: DisplayField.TITLE, name: 'Title' },
|
||||
{ id: 'custom_field_1', name: 'Custom Field 1' },
|
||||
] as any)
|
||||
settingsService.displayFieldsInitialized = true
|
||||
expect(documentListViewService.displayFields).toEqual(['custom_field_1'])
|
||||
})
|
||||
})
|
||||
|
@ -420,10 +420,13 @@ export class DocumentListViewService {
|
||||
if (!this.activeListViewState.displayFields) {
|
||||
fields = fields.filter((f) => f !== DisplayField.ADDED)
|
||||
}
|
||||
return fields.filter(
|
||||
(field) =>
|
||||
this.settings.allDisplayFields.find((f) => f.id === field) !== undefined
|
||||
)
|
||||
return this.settings.displayFieldsInitialized
|
||||
? fields.filter(
|
||||
(field) =>
|
||||
this.settings.allDisplayFields.find((f) => f.id === field) !==
|
||||
undefined
|
||||
)
|
||||
: fields
|
||||
}
|
||||
|
||||
set displayFields(fields: DisplayField[]) {
|
||||
|
@ -268,6 +268,7 @@ export class SettingsService {
|
||||
public get allDisplayFields(): Array<{ id: DisplayField; name: string }> {
|
||||
return this._allDisplayFields
|
||||
}
|
||||
public displayFieldsInitialized: boolean = false
|
||||
|
||||
constructor(
|
||||
rendererFactory: RendererFactory2,
|
||||
@ -361,7 +362,10 @@ export class SettingsService {
|
||||
}
|
||||
})
|
||||
)
|
||||
this.displayFieldsInitialized = true
|
||||
})
|
||||
} else {
|
||||
this.displayFieldsInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user