remove sanitization

This commit is contained in:
mchouliara 2024-10-16 11:04:02 +03:00
parent 441af6b2d1
commit c2713a527d
2 changed files with 7 additions and 13 deletions

View File

@ -145,7 +145,7 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
prepareForm(data: NotificationTemplate) { prepareForm(data: NotificationTemplate) {
try { try {
this.editorModel = data ? new NotificationTemplateEditorModel(this.domSanitizer).fromModel(data) : new NotificationTemplateEditorModel(this.domSanitizer); this.editorModel = data ? new NotificationTemplateEditorModel().fromModel(data) : new NotificationTemplateEditorModel();
if (data) { if (data) {
if (data.value && data.value.subjectFieldOptions) { if (data.value && data.value.subjectFieldOptions) {

View File

@ -1,9 +1,8 @@
import { FormArray, FormControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { FormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { NotificationFieldInfo, NotificationFieldInfoPersist, NotificationFieldOptions, NotificationFieldOptionsPersist, NotificationTemplate, NotificationTemplateBodyText, NotificationTemplatePersist, NotificationTemplateValue, NotificationTemplateValuePersist } from '@notification-service/core/model/notification-template.model'; import { NotificationFieldInfo, NotificationFieldInfoPersist, NotificationFieldOptions, NotificationFieldOptionsPersist, NotificationTemplate, NotificationTemplatePersist, NotificationTemplateValue, NotificationTemplateValuePersist } from '@notification-service/core/model/notification-template.model';
import { BackendErrorValidator } from '@common/forms/validation/custom-validator'; import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Validation, ValidationContext } from '@common/forms/validation/validation-context'; import { Validation, ValidationContext } from '@common/forms/validation/validation-context';
import { Guid } from '@common/types/guid';
import { BaseEditorModel } from '@common/base/base-form-editor-model'; import { BaseEditorModel } from '@common/base/base-form-editor-model';
import { NotificationTemplateChannel } from '@notification-service/core/enum/notification-template-channel.enum'; import { NotificationTemplateChannel } from '@notification-service/core/enum/notification-template-channel.enum';
import { NotificationTemplateKind } from '@notification-service/core/enum/notification-template-kind.enum'; import { NotificationTemplateKind } from '@notification-service/core/enum/notification-template-kind.enum';
@ -11,20 +10,19 @@ import { NotificationType } from '@notification-service/core/enum/notification-t
import { EmailOverrideMode } from '@notification-service/core/enum/email-override-mode'; import { EmailOverrideMode } from '@notification-service/core/enum/email-override-mode';
import { NotificationDataType } from '@notification-service/core/enum/notification-data-type'; import { NotificationDataType } from '@notification-service/core/enum/notification-data-type';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { SecurityContext } from '@angular/core';
export class NotificationTemplateEditorModel extends BaseEditorModel implements NotificationTemplatePersist { export class NotificationTemplateEditorModel extends BaseEditorModel implements NotificationTemplatePersist {
channel: NotificationTemplateChannel; channel: NotificationTemplateChannel;
notificationType: NotificationType; notificationType: NotificationType;
kind: NotificationTemplateKind; kind: NotificationTemplateKind;
languageCode: string; languageCode: string;
value: NotificationTemplateValueEditorModel = new NotificationTemplateValueEditorModel(this.sanitizer); value: NotificationTemplateValueEditorModel = new NotificationTemplateValueEditorModel();
permissions: string[]; permissions: string[];
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(protected sanitizer: DomSanitizer) { super();} constructor() { super();}
public fromModel(item: NotificationTemplate): NotificationTemplateEditorModel { public fromModel(item: NotificationTemplate): NotificationTemplateEditorModel {
if(item){ if(item){
@ -33,7 +31,7 @@ export class NotificationTemplateEditorModel extends BaseEditorModel implements
this.notificationType = item.notificationType; this.notificationType = item.notificationType;
this.kind = item.kind; this.kind = item.kind;
if(item.languageCode && item.languageCode) this.languageCode = item.languageCode; if(item.languageCode && item.languageCode) this.languageCode = item.languageCode;
if (item.value) { this.value = new NotificationTemplateValueEditorModel(this.sanitizer, this.validationErrorModel).fromModel(item.value); } if (item.value) { this.value = new NotificationTemplateValueEditorModel(this.validationErrorModel).fromModel(item.value); }
} }
return this; return this;
@ -104,7 +102,6 @@ export class NotificationTemplateValueEditorModel implements NotificationTemplat
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor( constructor(
protected sanitizer: DomSanitizer,
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(), public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(),
) { } ) { }
@ -114,10 +111,7 @@ export class NotificationTemplateValueEditorModel implements NotificationTemplat
this.subjectKey = item.subjectKey; this.subjectKey = item.subjectKey;
if (item.subjectFieldOptions) this.subjectFieldOptions = new NotificationFieldOptionsEditorModel(this.validationErrorModel).fromModel(item.subjectFieldOptions); if (item.subjectFieldOptions) this.subjectFieldOptions = new NotificationFieldOptionsEditorModel(this.validationErrorModel).fromModel(item.subjectFieldOptions);
this.bodyText = item.bodyText.toString() this.bodyText = item.bodyText.toString()
// {
// design: item.bodyText?.design,
// html: item.bodyText?.html ?? item.bodyText.toString()// this.sanitizer.sanitize(SecurityContext.HTML, item.bodyText?.html ?? item.bodyText)
// }
this.bodyKey = item.bodyKey; this.bodyKey = item.bodyKey;
this.priorityKey = item.priorityKey; this.priorityKey = item.priorityKey;
this.allowAttachments = item.allowAttachments; this.allowAttachments = item.allowAttachments;