|
|
@ -19,7 +19,9 @@ import { |
|
|
NotificationTargetConfigType, |
|
|
NotificationTargetConfigType, |
|
|
NotificationTargetConfigTypeTranslateMap, |
|
|
NotificationTargetConfigTypeTranslateMap, |
|
|
NotificationTargetType, |
|
|
NotificationTargetType, |
|
|
NotificationTargetTypeTranslationMap |
|
|
NotificationTargetTypeTranslationMap, |
|
|
|
|
|
SlackChanelType, |
|
|
|
|
|
SlackChanelTypesTranslateMap |
|
|
} from '@shared/models/notification.models'; |
|
|
} from '@shared/models/notification.models'; |
|
|
import { Component, Inject, OnDestroy } from '@angular/core'; |
|
|
import { Component, Inject, OnDestroy } from '@angular/core'; |
|
|
import { DialogComponent } from '@shared/components/dialog.component'; |
|
|
import { DialogComponent } from '@shared/components/dialog.component'; |
|
|
@ -54,6 +56,9 @@ export class TargetNotificationDialogComponent extends |
|
|
notificationTargetConfigType = NotificationTargetConfigType; |
|
|
notificationTargetConfigType = NotificationTargetConfigType; |
|
|
notificationTargetConfigTypes: NotificationTargetConfigType[] = Object.values(NotificationTargetConfigType); |
|
|
notificationTargetConfigTypes: NotificationTargetConfigType[] = Object.values(NotificationTargetConfigType); |
|
|
notificationTargetConfigTypeTranslateMap = NotificationTargetConfigTypeTranslateMap; |
|
|
notificationTargetConfigTypeTranslateMap = NotificationTargetConfigTypeTranslateMap; |
|
|
|
|
|
slackChanelTypes = Object.keys(SlackChanelType) as SlackChanelType[]; |
|
|
|
|
|
slackChanelTypesTranslateMap = SlackChanelTypesTranslateMap; |
|
|
|
|
|
|
|
|
entityType = EntityType; |
|
|
entityType = EntityType; |
|
|
isAdd = true; |
|
|
isAdd = true; |
|
|
|
|
|
|
|
|
@ -73,18 +78,38 @@ export class TargetNotificationDialogComponent extends |
|
|
|
|
|
|
|
|
this.targetNotificationForm = this.fb.group({ |
|
|
this.targetNotificationForm = this.fb.group({ |
|
|
name: [null, Validators.required], |
|
|
name: [null, Validators.required], |
|
|
type: [NotificationTargetType.PLATFORM_USERS], |
|
|
|
|
|
configuration: this.fb.group({ |
|
|
configuration: this.fb.group({ |
|
|
description: [null], |
|
|
type: [NotificationTargetType.PLATFORM_USERS], |
|
|
usersFilter: this.fb.group({ |
|
|
usersFilter: this.fb.group({ |
|
|
type: [NotificationTargetConfigType.ALL_USERS], |
|
|
type: [NotificationTargetConfigType.ALL_USERS], |
|
|
usersIds: [{value: null, disabled: true}, Validators.required], |
|
|
usersIds: [{value: null, disabled: true}, Validators.required], |
|
|
customerId: [{value: null, disabled: true}, Validators.required], |
|
|
customerId: [{value: null, disabled: true}, Validators.required], |
|
|
getCustomerIdFromOriginatorEntity: [{value: false, disabled: true}] |
|
|
getCustomerIdFromOriginatorEntity: [{value: false, disabled: true}] |
|
|
}) |
|
|
}), |
|
|
|
|
|
conversationType: [{value: SlackChanelType.DIRECT, disabled: true}], |
|
|
|
|
|
conversation: [{value: '', disabled: true}, Validators.required], |
|
|
|
|
|
description: [null] |
|
|
}) |
|
|
}) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.targetNotificationForm.get('configuration.type').valueChanges.pipe( |
|
|
|
|
|
takeUntil(this.destroy$) |
|
|
|
|
|
).subscribe((type: NotificationTargetType) => { |
|
|
|
|
|
this.targetNotificationForm.get('configuration').disable({emitEvent: false}); |
|
|
|
|
|
switch (type) { |
|
|
|
|
|
case NotificationTargetType.PLATFORM_USERS: |
|
|
|
|
|
this.targetNotificationForm.get('configuration.usersFilter').enable({emitEvent: false}); |
|
|
|
|
|
this.targetNotificationForm.get('configuration.usersFilter.type').updateValueAndValidity({onlySelf: true}); |
|
|
|
|
|
break; |
|
|
|
|
|
case NotificationTargetType.SLACK: |
|
|
|
|
|
this.targetNotificationForm.get('configuration.conversationType').enable({emitEvent: false}); |
|
|
|
|
|
this.targetNotificationForm.get('configuration.conversation').enable({emitEvent: false}); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
this.targetNotificationForm.get('configuration.type').enable({emitEvent: false}); |
|
|
|
|
|
this.targetNotificationForm.get('configuration.description').enable({emitEvent: false}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.targetNotificationForm.get('configuration.usersFilter.type').valueChanges.pipe( |
|
|
this.targetNotificationForm.get('configuration.usersFilter.type').valueChanges.pipe( |
|
|
takeUntil(this.destroy$) |
|
|
takeUntil(this.destroy$) |
|
|
).subscribe((type: NotificationTargetConfigType) => { |
|
|
).subscribe((type: NotificationTargetConfigType) => { |
|
|
@ -111,8 +136,7 @@ export class TargetNotificationDialogComponent extends |
|
|
|
|
|
|
|
|
if (isDefined(data.target)) { |
|
|
if (isDefined(data.target)) { |
|
|
this.targetNotificationForm.patchValue(data.target, {emitEvent: false}); |
|
|
this.targetNotificationForm.patchValue(data.target, {emitEvent: false}); |
|
|
this.targetNotificationForm.get('type').updateValueAndValidity({onlySelf: true}); |
|
|
this.targetNotificationForm.get('configuration.type').updateValueAndValidity({onlySelf: true}); |
|
|
this.targetNotificationForm.get('configuration.usersFilter.type').updateValueAndValidity({onlySelf: true}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -131,7 +155,7 @@ export class TargetNotificationDialogComponent extends |
|
|
if (isDefined(this.data.target)) { |
|
|
if (isDefined(this.data.target)) { |
|
|
formValue = Object.assign({}, this.data.target, formValue); |
|
|
formValue = Object.assign({}, this.data.target, formValue); |
|
|
} |
|
|
} |
|
|
formValue.configuration.type = formValue.type; |
|
|
formValue.type = formValue.configuration.type; |
|
|
this.notificationService.saveNotificationTarget(formValue).subscribe( |
|
|
this.notificationService.saveNotificationTarget(formValue).subscribe( |
|
|
(target) => this.dialogRef.close(target) |
|
|
(target) => this.dialogRef.close(target) |
|
|
); |
|
|
); |
|
|
|