add notification type UI dropdown
This commit is contained in:
parent
0e1a9c88b1
commit
065cd249c9
|
@ -18,6 +18,8 @@ public class NotificationTemplatePersist {
|
||||||
@ValidEnum
|
@ValidEnum
|
||||||
private NotificationTemplateChannel channel;
|
private NotificationTemplateChannel channel;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Valid
|
||||||
private UUID notificationType;
|
private UUID notificationType;
|
||||||
|
|
||||||
@ValidEnum
|
@ValidEnum
|
||||||
|
|
|
@ -102,17 +102,14 @@ public class NotificationServiceTemplateImpl implements NotificationTemplateServ
|
||||||
data = this.entityManager.find(NotificationTemplateEntity.class, model.getId());
|
data = this.entityManager.find(NotificationTemplateEntity.class, model.getId());
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), NotificationTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), NotificationTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||||
if (model.getNotificationType() != null){
|
|
||||||
data.setNotificationType(model.getNotificationType());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
data = new NotificationTemplateEntity();
|
data = new NotificationTemplateEntity();
|
||||||
data.setId(UUID.randomUUID());
|
data.setId(UUID.randomUUID());
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
data.setCreatedAt(Instant.now());
|
data.setCreatedAt(Instant.now());
|
||||||
data.setNotificationType(UUID.randomUUID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.setNotificationType(model.getNotificationType());
|
||||||
data.setChannel(model.getChannel());
|
data.setChannel(model.getChannel());
|
||||||
data.setKind(model.getKind());
|
data.setKind(model.getKind());
|
||||||
data.setLanguageId(model.getLanguageId());
|
data.setLanguageId(model.getLanguageId());
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
export enum NotificationType {
|
||||||
|
dmpInvitationExternalUser = '065deecd-21bb-44af-9983-e660fdf24bc4',
|
||||||
|
dmpInvitationExistingUser = '4904dea2-5079-46d3-83be-3a19c9ab45dc',
|
||||||
|
dmpModified = '4542262a-22f8-4baa-9db6-1c8e70ac1dbb',
|
||||||
|
dmpFinalised = '90db0b46-42de-bd89-aebf-6f27efeb256e',
|
||||||
|
descriptionModified = '4fdbfa80-7a71-4a69-b854-67cbb70648f1',
|
||||||
|
descriptionFinalised = '33790bad-94d4-488a-8ee2-7f6295ca18ea',
|
||||||
|
mergeAccountConfirmation = 'bfe68845-cb05-4c5a-a03d-29161a7c9660',
|
||||||
|
removeCredentialConfirmation = 'c9bc3f16-057e-4bba-8a5f-36bd835e5604',
|
||||||
|
dmpDeposit = '55736f7a-83ab-4190-af43-9d031a6f9612',
|
||||||
|
descriptionTemplateInvitation = '223bb607-efa1-4ce7-99ec-4beabfef9a8b'
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ import { DmpBlueprintType } from '../../common/enum/dmp-blueprint-type';
|
||||||
import { DmpStatus } from '../../common/enum/dmp-status';
|
import { DmpStatus } from '../../common/enum/dmp-status';
|
||||||
import { ValidationType } from '../../common/enum/validation-type';
|
import { ValidationType } from '../../common/enum/validation-type';
|
||||||
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
|
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
|
||||||
|
import { NotificationType } from '@app/core/common/enum/notification-type';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EnumUtils {
|
export class EnumUtils {
|
||||||
|
@ -316,4 +317,19 @@ export class EnumUtils {
|
||||||
case RecentActivityOrder.Status: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.STATUS');
|
case RecentActivityOrder.Status: return this.language.instant('TYPES.RECENT-ACTIVITY-ORDER.STATUS');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toNotificationTypeString(status: NotificationType): string {
|
||||||
|
switch (status) {
|
||||||
|
case NotificationType.dmpInvitationExternalUser: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DMP-INVITATION-EXTERNAL-USER');
|
||||||
|
case NotificationType.dmpInvitationExistingUser: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DMP-INVITATION-EXISTING-USER');
|
||||||
|
case NotificationType.dmpModified: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DMP-MODIFIED');
|
||||||
|
case NotificationType.dmpFinalised: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DMP-FINALISED');
|
||||||
|
case NotificationType.descriptionModified: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DESCRIPTION-MODIFIED');
|
||||||
|
case NotificationType.descriptionFinalised: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DESCRIPTION-FINALISED');
|
||||||
|
case NotificationType.mergeAccountConfirmation: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.MERGE-ACCOUNT-CONFIRMATION');
|
||||||
|
case NotificationType.removeCredentialConfirmation: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.REMOVE-CREDENTIAL-CONFIRMATION');
|
||||||
|
case NotificationType.dmpDeposit: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DMP-DEPOSIT');
|
||||||
|
case NotificationType.descriptionTemplateInvitation: return this.language.instant('TYPES.NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE.DESCRIPTION-TEMPLATE-INVITATION');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,16 @@
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.NOTIFICATION-TYPE' | translate}}</mat-label>
|
||||||
|
<mat-select [value] = "notificationType" (selectionChange)="selectedNotificationTypeChanged($event.value)" name="notificationType" required>
|
||||||
|
<mat-option *ngFor="let type of notificationTypeEnum" [value]="type">
|
||||||
|
{{enumUtils.toNotificationTypeString(type)}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.LANGUAGE' | translate}}</mat-label>
|
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.LANGUAGE' | translate}}</mat-label>
|
||||||
|
@ -49,7 +59,7 @@
|
||||||
{{enumUtils.toNotificationTemplateKindString(kind)}}
|
{{enumUtils.toNotificationTemplateKindString(kind)}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="formGroup.get('channel').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('kind').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
|
|
@ -33,6 +33,7 @@ import { MatChipEditedEvent, MatChipInputEvent } from '@angular/material/chips';
|
||||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||||
import { NotificationDataType } from '@app/core/common/enum/notification-data-type';
|
import { NotificationDataType } from '@app/core/common/enum/notification-data-type';
|
||||||
import { EmailOverrideMode } from '@app/core/common/enum/email-override-mode';
|
import { EmailOverrideMode } from '@app/core/common/enum/email-override-mode';
|
||||||
|
import { NotificationType } from '@app/core/common/enum/notification-type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-notification-template-editor',
|
selector: 'app-notification-template-editor',
|
||||||
|
@ -56,6 +57,8 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
|
||||||
languageCode: string;
|
languageCode: string;
|
||||||
subjectFormatting: { [key: string]: string } = {};
|
subjectFormatting: { [key: string]: string } = {};
|
||||||
bodyFormatting: { [key: string]: string } = {};
|
bodyFormatting: { [key: string]: string } = {};
|
||||||
|
notificationType: string;
|
||||||
|
public notificationTypeEnum = this.enumUtils.getEnumValues(NotificationType);
|
||||||
public notificationTemplateKindEnum = this.enumUtils.getEnumValues(NotificationTemplateKind);
|
public notificationTemplateKindEnum = this.enumUtils.getEnumValues(NotificationTemplateKind);
|
||||||
public notificationTemplateChannelEnum = this.enumUtils.getEnumValues(NotificationTemplateChannel);
|
public notificationTemplateChannelEnum = this.enumUtils.getEnumValues(NotificationTemplateChannel);
|
||||||
public notificationDataTypeEnum = this.enumUtils.getEnumValues(NotificationDataType);
|
public notificationDataTypeEnum = this.enumUtils.getEnumValues(NotificationDataType);
|
||||||
|
@ -121,6 +124,7 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
|
||||||
this.editorModel = data ? new NotificationTemplateEditorModel().fromModel(data) : new NotificationTemplateEditorModel();
|
this.editorModel = data ? new NotificationTemplateEditorModel().fromModel(data) : new NotificationTemplateEditorModel();
|
||||||
|
|
||||||
if(data){
|
if(data){
|
||||||
|
this.notificationType = data.notificationType.toString();
|
||||||
if(data.value && data.value.subjectFieldOptions){
|
if(data.value && data.value.subjectFieldOptions){
|
||||||
this.subjectFieldOptionsEnabled = true;
|
this.subjectFieldOptionsEnabled = true;
|
||||||
this.subjectMandatoryFields = data.value.subjectFieldOptions.mandatory;
|
this.subjectMandatoryFields = data.value.subjectFieldOptions.mandatory;
|
||||||
|
@ -220,6 +224,10 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
|
||||||
this.formService.validateAllFormFields(this.formGroup);
|
this.formService.validateAllFormFields(this.formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedNotificationTypeChanged(type: NotificationType){
|
||||||
|
this.formGroup.get('notificationType').patchValue(Guid.parse(type));
|
||||||
|
}
|
||||||
|
|
||||||
selectedLangChanged(code: string){
|
selectedLangChanged(code: string){
|
||||||
|
|
||||||
this.languageHttpService.getSingleWithCode(code, [nameof<Language>(x => x.id),nameof<Language>(x => x.code)])
|
this.languageHttpService.getSingleWithCode(code, [nameof<Language>(x => x.id),nameof<Language>(x => x.code)])
|
||||||
|
|
|
@ -57,7 +57,7 @@ export class NotificationTemplateEditorModel extends BaseEditorModel implements
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||||
baseValidationArray.push({ key: 'channel', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'channel')] });
|
baseValidationArray.push({ key: 'channel', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'channel')] });
|
||||||
baseValidationArray.push({ key: 'notificationType', validators: [BackendErrorValidator(this.validationErrorModel, 'notificationType')] });
|
baseValidationArray.push({ key: 'notificationType', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'notificationType')] });
|
||||||
baseValidationArray.push({ key: 'kind', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'kind')] });
|
baseValidationArray.push({ key: 'kind', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'kind')] });
|
||||||
baseValidationArray.push({ key: 'languageId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'languageId')] });
|
baseValidationArray.push({ key: 'languageId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'languageId')] });
|
||||||
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'value')] });
|
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'value')] });
|
||||||
|
|
|
@ -1331,6 +1331,7 @@
|
||||||
"NOTIFICATION-TEMPLATE-EDITOR": {
|
"NOTIFICATION-TEMPLATE-EDITOR": {
|
||||||
"NEW": "New Notification Template",
|
"NEW": "New Notification Template",
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
|
"NOTIFICATION-TYPE": "Notification Type",
|
||||||
"LANGUAGE": "Language",
|
"LANGUAGE": "Language",
|
||||||
"CHANNEL": "Channel",
|
"CHANNEL": "Channel",
|
||||||
"KIND": "Kind",
|
"KIND": "Kind",
|
||||||
|
@ -2260,6 +2261,18 @@
|
||||||
"NOT": "Not Override",
|
"NOT": "Not Override",
|
||||||
"ADDITIVE": "Additive",
|
"ADDITIVE": "Additive",
|
||||||
"REPLACE": "Replace"
|
"REPLACE": "Replace"
|
||||||
|
},
|
||||||
|
"NOTIFICATION-TEMPLATE-NOTIFICATION-TYPE": {
|
||||||
|
"DMP-INVITATION-EXTERNAL-USER": "DMP Invitation External User",
|
||||||
|
"DMP-INVITATION-EXISTING-USER": "DMP Invitation Existing User",
|
||||||
|
"DMP-MODIFIED": "DMP Modified",
|
||||||
|
"DMP-FINALISED": "DMP Finalised",
|
||||||
|
"DESCRIPTION-MODIFIED": "Description Modified",
|
||||||
|
"DESCRIPTION-FINALISED": "Description Finalised",
|
||||||
|
"MERGE-ACCOUNT-CONFIRMATION": "Merge Account Confirmation",
|
||||||
|
"REMOVE-CREDENTIAL-CONFIRMATION": "Remove Credential Confirmation",
|
||||||
|
"DMP-DEPOSIT": "DMP Deposit",
|
||||||
|
"DESCRIPTION-TEMPLATE-INVITATION": "Description Template Invitation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ADDRESEARCHERS-EDITOR": {
|
"ADDRESEARCHERS-EDITOR": {
|
||||||
|
|
Loading…
Reference in New Issue