Fix: ensure create dialog uses correct attribute type (#13221)

This commit is contained in:
shamoon
2026-07-23 16:22:27 +00:00
committed by GitHub
parent 50c88dab7a
commit cd3c162e6e
2 changed files with 27 additions and 7 deletions
@@ -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', () => {
@@ -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
}