UI: Fixed incorrect updated allow delivery method disable state
This commit is contained in:
parent
cbaaee657a
commit
64ed2646cc
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
NotificationDeliveryMethod,
|
NotificationDeliveryMethod,
|
||||||
NotificationDeliveryMethodTranslateMap,
|
|
||||||
NotificationRequest,
|
NotificationRequest,
|
||||||
NotificationRequestPreview,
|
NotificationRequestPreview,
|
||||||
NotificationTarget,
|
NotificationTarget,
|
||||||
@ -81,6 +80,8 @@ export class SentNotificationDialogComponent extends
|
|||||||
|
|
||||||
private authUser: AuthUser = getCurrentAuthUser(this.store);
|
private authUser: AuthUser = getCurrentAuthUser(this.store);
|
||||||
|
|
||||||
|
private allowNotificationDeliveryMethods: Array<NotificationDeliveryMethod>;
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
protected dialogRef: MatDialogRef<SentNotificationDialogComponent, NotificationRequest>,
|
protected dialogRef: MatDialogRef<SentNotificationDialogComponent, NotificationRequest>,
|
||||||
@ -127,6 +128,7 @@ export class SentNotificationDialogComponent extends
|
|||||||
} else {
|
} else {
|
||||||
this.notificationRequestForm.get('templateId').disable({emitEvent: false});
|
this.notificationRequestForm.get('templateId').disable({emitEvent: false});
|
||||||
this.notificationRequestForm.get('template').enable({emitEvent: false});
|
this.notificationRequestForm.get('template').enable({emitEvent: false});
|
||||||
|
this.updateDeliveryMethodsDisableState();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -334,15 +336,20 @@ export class SentNotificationDialogComponent extends
|
|||||||
|
|
||||||
refreshAllowDeliveryMethod() {
|
refreshAllowDeliveryMethod() {
|
||||||
this.notificationService.getAvailableDeliveryMethods({ignoreLoading: true}).subscribe(allowMethods => {
|
this.notificationService.getAvailableDeliveryMethods({ignoreLoading: true}).subscribe(allowMethods => {
|
||||||
this.notificationDeliveryMethods.forEach(method => {
|
this.allowNotificationDeliveryMethods = allowMethods;
|
||||||
if (allowMethods.includes(method)) {
|
this.updateDeliveryMethodsDisableState();
|
||||||
this.getDeliveryMethodsTemplatesControl(method).enable({emitEvent: true});
|
|
||||||
} else {
|
|
||||||
this.getDeliveryMethodsTemplatesControl(method).disable({emitEvent: true});
|
|
||||||
this.getDeliveryMethodsTemplatesControl(method).setValue(false, {emitEvent: true}); //used for notify again
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.showRefresh = (this.notificationDeliveryMethods.length !== allowMethods.length);
|
this.showRefresh = (this.notificationDeliveryMethods.length !== allowMethods.length);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateDeliveryMethodsDisableState() {
|
||||||
|
this.notificationDeliveryMethods.forEach(method => {
|
||||||
|
if (this.allowNotificationDeliveryMethods.includes(method)) {
|
||||||
|
this.getDeliveryMethodsTemplatesControl(method).enable({emitEvent: true});
|
||||||
|
} else {
|
||||||
|
this.getDeliveryMethodsTemplatesControl(method).disable({emitEvent: true});
|
||||||
|
this.getDeliveryMethodsTemplatesControl(method).setValue(false, {emitEvent: true}); //used for notify again
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user