mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-30 15:45:58 +00:00
Fix: ensure create dialog uses correct attribute type (#13221)
This commit is contained in:
+24
-1
@@ -18,6 +18,7 @@ import {
|
||||
DocumentAttributesComponent,
|
||||
DocumentAttributesSectionKind,
|
||||
} from './document-attributes.component'
|
||||
import { ManagementListComponent } from './management-list/management-list.component'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-dummy-section',
|
||||
@@ -170,10 +171,32 @@ describe('DocumentAttributesComponent', () => {
|
||||
expect(component.activeManagementList).toBeNull()
|
||||
|
||||
component.activeNavID.set(1)
|
||||
const managementList = Object.create(ManagementListComponent.prototype)
|
||||
component.activeOutlet = {
|
||||
componentInstance: managementList,
|
||||
} as any
|
||||
expect(component.activeSection.kind).toBe(
|
||||
DocumentAttributesSectionKind.ManagementList
|
||||
)
|
||||
expect(component.activeManagementList).toBeDefined()
|
||||
expect(component.activeManagementList).toBe(managementList)
|
||||
})
|
||||
|
||||
it('should use the current component instance when the outlet is reused', () => {
|
||||
jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
|
||||
component.activeNavID.set(1)
|
||||
const firstManagementList = Object.create(ManagementListComponent.prototype)
|
||||
const secondManagementList = Object.create(
|
||||
ManagementListComponent.prototype
|
||||
)
|
||||
component.activeOutlet = {
|
||||
componentInstance: firstManagementList,
|
||||
} as any
|
||||
|
||||
expect(component.activeManagementList).toBe(firstManagementList)
|
||||
|
||||
component.activeOutlet.componentInstance = secondManagementList
|
||||
|
||||
expect(component.activeManagementList).toBe(secondManagementList)
|
||||
})
|
||||
|
||||
it('should return activeCustomFields correctly', () => {
|
||||
|
||||
+3
-6
@@ -132,11 +132,8 @@ export class DocumentAttributesComponent implements OnInit, OnDestroy {
|
||||
]
|
||||
|
||||
@ViewChild('activeOutlet', { read: NgComponentOutlet })
|
||||
set activeOutlet(outlet: NgComponentOutlet | undefined) {
|
||||
this.activeComponent.set(outlet?.componentInstance ?? null)
|
||||
}
|
||||
activeOutlet: NgComponentOutlet
|
||||
|
||||
readonly activeComponent = signal<unknown>(null)
|
||||
readonly activeNavID = signal<number>(null)
|
||||
|
||||
get visibleSections(): DocumentAttributesSection[] {
|
||||
@@ -161,14 +158,14 @@ export class DocumentAttributesComponent implements OnInit, OnDestroy {
|
||||
this.activeSection?.kind !== DocumentAttributesSectionKind.ManagementList
|
||||
)
|
||||
return null
|
||||
const instance = this.activeComponent()
|
||||
const instance = this.activeOutlet?.componentInstance
|
||||
return instance instanceof ManagementListComponent ? instance : null
|
||||
}
|
||||
|
||||
get activeCustomFields(): CustomFieldsComponent | null {
|
||||
if (this.activeSection?.kind !== DocumentAttributesSectionKind.CustomFields)
|
||||
return null
|
||||
const instance = this.activeComponent()
|
||||
const instance = this.activeOutlet?.componentInstance
|
||||
return instance instanceof CustomFieldsComponent ? instance : null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user