Fix: table view doesnt immediately display custom fields on app startup (#6600)

This commit is contained in:
shamoon 2024-05-07 08:30:34 -07:00 committed by GitHub
parent fae2399e46
commit 8ea3259fe7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 4 deletions

View File

@ -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')))

View File

@ -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'])
})
})

View File

@ -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[]) {

View File

@ -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
}
}