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 = {}) {
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);
},
});
}
}

11
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);
},
});
}
}

Loading…
Cancel
Save