Fix empty object causes error new workflow
This commit is contained in:
parent
627b01f971
commit
cc4eca40ab
@ -34,7 +34,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div ngbAccordion [closeOthers]="true">
|
||||
@for (trigger of object.triggers; track trigger; let i = $index){
|
||||
@for (trigger of object?.triggers; track trigger; let i = $index){
|
||||
<div ngbAccordionItem>
|
||||
<div ngbAccordionHeader>
|
||||
<button ngbAccordionButton>{{i + 1}}. {{getTriggerTypeOptionName(triggerFields.controls[i].value.type)}}
|
||||
@ -76,7 +76,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div ngbAccordion [closeOthers]="true" cdkDropList (cdkDropListDropped)="onActionDrop($event)">
|
||||
@for (action of object.actions; track action; let i = $index){
|
||||
@for (action of object?.actions; track action; let i = $index){
|
||||
<div ngbAccordionItem cdkDrag [formGroup]="actionFields.controls[i]">
|
||||
<div ngbAccordionHeader>
|
||||
<button ngbAccordionButton><ng-container i18n>Action</ng-container> {{i + 1}}
|
||||
|
@ -166,13 +166,22 @@ describe('ConsumptionTemplateEditDialogComponent', () => {
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should support create and edit modes', () => {
|
||||
it('should support create and edit modes, support adding triggers and actions on new workflow', () => {
|
||||
component.dialogMode = EditDialogMode.CREATE
|
||||
const createTitleSpy = jest.spyOn(component, 'getCreateTitle')
|
||||
const editTitleSpy = jest.spyOn(component, 'getEditTitle')
|
||||
fixture.detectChanges()
|
||||
expect(createTitleSpy).toHaveBeenCalled()
|
||||
expect(editTitleSpy).not.toHaveBeenCalled()
|
||||
expect(component.object).toBeUndefined()
|
||||
component.addAction()
|
||||
expect(component.object).not.toBeUndefined()
|
||||
expect(component.object.actions).toHaveLength(1)
|
||||
component.object = undefined
|
||||
component.addTrigger()
|
||||
expect(component.object).not.toBeUndefined()
|
||||
expect(component.object.triggers).toHaveLength(1)
|
||||
|
||||
component.dialogMode = EditDialogMode.EDIT
|
||||
fixture.detectChanges()
|
||||
expect(editTitleSpy).toHaveBeenCalled()
|
||||
|
@ -230,6 +230,9 @@ export class WorkflowEditDialogComponent
|
||||
}
|
||||
|
||||
addTrigger() {
|
||||
if (!this.object) {
|
||||
this.object = Object.assign({}, this.objectForm.value)
|
||||
}
|
||||
this.object.triggers.push({
|
||||
type: WorkflowTriggerType.Consumption,
|
||||
sources: [],
|
||||
@ -253,6 +256,9 @@ export class WorkflowEditDialogComponent
|
||||
}
|
||||
|
||||
addAction() {
|
||||
if (!this.object) {
|
||||
this.object = Object.assign({}, this.objectForm.value)
|
||||
}
|
||||
this.object.actions.push({
|
||||
type: WorkflowActionType.Assignment,
|
||||
assign_title: null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user