Browse Source

Fix disabled state in rule page.

pull/816/head
Sebastian 4 years ago
parent
commit
54c5c467d2
  1. 46
      frontend/app/features/rules/pages/rule/rule-page.component.ts
  2. 11
      frontend/app/shared/components/app-form.component.ts

46
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 = {}) { 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); this.currentAction = { form, type, values };
form.load(values); this.currentAction.form.setEnabled(this.isEditable);
}
this.currentAction = { form, type, values }; this.currentAction.form.load(values);
} }
public selectTrigger(type: string, 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); this.currentTrigger = { form, type, values };
form.load(values); this.currentTrigger.form.setEnabled(this.isEditable);
}
this.currentTrigger = { form, type, values }; this.currentTrigger.form.load(values);
} }
public resetAction() { public resetAction() {
@ -136,19 +140,25 @@ export class RulePageComponent extends ResourceOwner implements OnInit {
if (this.rule) { if (this.rule) {
this.rulesState.update(this.rule, request) this.rulesState.update(this.rule, request)
.subscribe(() => { .subscribe({
this.submitCompleted(); next: () => {
}, error => { this.submitCompleted();
this.submitFailed(error); },
error: error => {
this.submitFailed(error);
},
}); });
} else { } else {
this.rulesState.create(request) this.rulesState.create(request)
.subscribe(rule => { .subscribe({
this.submitCompleted(); next: rule => {
this.submitCompleted();
this.router.navigate([rule.id], { relativeTo: this.route.parent, replaceUrl: true });
}, error => { this.router.navigate([rule.id], { relativeTo: this.route.parent, replaceUrl: true });
this.submitFailed(error); },
error: error => {
this.submitFailed(error);
},
}); });
} }
} }

11
frontend/app/shared/components/app-form.component.ts

@ -40,10 +40,13 @@ export class AppFormComponent {
const request = { ...value, template: this.template }; const request = { ...value, template: this.template };
this.appsStore.create(request) this.appsStore.create(request)
.subscribe(() => { .subscribe({
this.emitComplete(); next: () => {
}, error => { this.emitComplete();
this.createForm.submitFailed(error); },
error: error => {
this.createForm.submitFailed(error);
},
}); });
} }
} }

Loading…
Cancel
Save