diff --git a/frontend/app/features/rules/pages/rule/rule-page.component.ts b/frontend/app/features/rules/pages/rule/rule-page.component.ts index 78ddd8157..e0c82e3e9 100644 --- a/frontend/app/features/rules/pages/rule/rule-page.component.ts +++ b/frontend/app/features/rules/pages/rule/rule-page.component.ts @@ -86,21 +86,25 @@ export class RulePageComponent extends ResourceOwner implements OnInit { } public selectAction(type: string, values = {}) { - const form = new ActionForm(this.supportedActions[type], type); + if (this.currentAction?.type !== type) { + const form = new ActionForm(this.supportedActions[type], type); - form.setEnabled(this.isEditable); - form.load(values); + this.currentAction = { form, type, values }; + this.currentAction.form.setEnabled(this.isEditable); + } - this.currentAction = { form, type, values }; + this.currentAction.form.load(values); } public selectTrigger(type: string, values = {}) { - const form = new TriggerForm(type); + if (this.currentTrigger?.type !== type) { + const form = new TriggerForm(type); - form.setEnabled(this.isEditable); - form.load(values); + this.currentTrigger = { form, type, values }; + this.currentTrigger.form.setEnabled(this.isEditable); + } - this.currentTrigger = { form, type, values }; + this.currentTrigger.form.load(values); } public resetAction() { @@ -136,19 +140,25 @@ export class RulePageComponent extends ResourceOwner implements OnInit { if (this.rule) { this.rulesState.update(this.rule, request) - .subscribe(() => { - this.submitCompleted(); - }, error => { - this.submitFailed(error); + .subscribe({ + next: () => { + this.submitCompleted(); + }, + error: error => { + this.submitFailed(error); + }, }); } else { this.rulesState.create(request) - .subscribe(rule => { - this.submitCompleted(); - - this.router.navigate([rule.id], { relativeTo: this.route.parent, replaceUrl: true }); - }, error => { - this.submitFailed(error); + .subscribe({ + next: rule => { + this.submitCompleted(); + + this.router.navigate([rule.id], { relativeTo: this.route.parent, replaceUrl: true }); + }, + error: error => { + this.submitFailed(error); + }, }); } } diff --git a/frontend/app/shared/components/app-form.component.ts b/frontend/app/shared/components/app-form.component.ts index 826d10a22..5881faf45 100644 --- a/frontend/app/shared/components/app-form.component.ts +++ b/frontend/app/shared/components/app-form.component.ts @@ -40,10 +40,13 @@ export class AppFormComponent { const request = { ...value, template: this.template }; this.appsStore.create(request) - .subscribe(() => { - this.emitComplete(); - }, error => { - this.createForm.submitFailed(error); + .subscribe({ + next: () => { + this.emitComplete(); + }, + error: error => { + this.createForm.submitFailed(error); + }, }); } }