Merge pull request #8470 from vvlladd28/bug/notification/preview-error
Fixed error when we review in send notification
This commit is contained in:
		
						commit
						dfa32952fc
					
				@ -16,7 +16,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  NotificationDeliveryMethod,
 | 
					  NotificationDeliveryMethod,
 | 
				
			||||||
  NotificationDeliveryMethodTranslateMap,
 | 
					 | 
				
			||||||
  NotificationRequest,
 | 
					  NotificationRequest,
 | 
				
			||||||
  NotificationRequestPreview,
 | 
					  NotificationRequestPreview,
 | 
				
			||||||
  NotificationTarget,
 | 
					  NotificationTarget,
 | 
				
			||||||
@ -72,9 +71,6 @@ export class SentNotificationDialogComponent extends
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  notificationRequestForm: FormGroup;
 | 
					  notificationRequestForm: FormGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  notificationDeliveryMethods = Object.keys(NotificationDeliveryMethod) as NotificationDeliveryMethod[];
 | 
					 | 
				
			||||||
  notificationDeliveryMethodTranslateMap = NotificationDeliveryMethodTranslateMap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  selectedIndex = 0;
 | 
					  selectedIndex = 0;
 | 
				
			||||||
  preview: NotificationRequestPreview = null;
 | 
					  preview: NotificationRequestPreview = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -84,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>,
 | 
				
			||||||
@ -130,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();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -337,15 +336,20 @@ export class SentNotificationDialogComponent extends
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  refreshAllowDeliveryMethod() {
 | 
					  refreshAllowDeliveryMethod() {
 | 
				
			||||||
    this.notificationService.getAvailableDeliveryMethods({ignoreLoading: true}).subscribe(allowMethods => {
 | 
					    this.notificationService.getAvailableDeliveryMethods({ignoreLoading: true}).subscribe(allowMethods => {
 | 
				
			||||||
 | 
					      this.allowNotificationDeliveryMethods = allowMethods;
 | 
				
			||||||
 | 
					      this.updateDeliveryMethodsDisableState();
 | 
				
			||||||
 | 
					      this.showRefresh = (this.notificationDeliveryMethods.length !== allowMethods.length);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  private updateDeliveryMethodsDisableState() {
 | 
				
			||||||
    this.notificationDeliveryMethods.forEach(method => {
 | 
					    this.notificationDeliveryMethods.forEach(method => {
 | 
				
			||||||
        if (allowMethods.includes(method)) {
 | 
					      if (this.allowNotificationDeliveryMethods.includes(method)) {
 | 
				
			||||||
        this.getDeliveryMethodsTemplatesControl(method).enable({emitEvent: true});
 | 
					        this.getDeliveryMethodsTemplatesControl(method).enable({emitEvent: true});
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        this.getDeliveryMethodsTemplatesControl(method).disable({emitEvent: true});
 | 
					        this.getDeliveryMethodsTemplatesControl(method).disable({emitEvent: true});
 | 
				
			||||||
        this.getDeliveryMethodsTemplatesControl(method).setValue(false, {emitEvent: true}); //used for notify again
 | 
					        this.getDeliveryMethodsTemplatesControl(method).setValue(false, {emitEvent: true}); //used for notify again
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
      this.showRefresh = (this.notificationDeliveryMethods.length !== allowMethods.length);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -190,7 +190,7 @@ export abstract class TemplateConfiguration<T, R = any> extends DialogComponent<
 | 
				
			|||||||
  protected getNotificationTemplateValue(): NotificationTemplate {
 | 
					  protected getNotificationTemplateValue(): NotificationTemplate {
 | 
				
			||||||
    const template: NotificationTemplate = deepClone(this.templateNotificationForm.value);
 | 
					    const template: NotificationTemplate = deepClone(this.templateNotificationForm.value);
 | 
				
			||||||
    this.notificationDeliveryMethods.forEach(method => {
 | 
					    this.notificationDeliveryMethods.forEach(method => {
 | 
				
			||||||
      if (template.configuration.deliveryMethodsTemplates[method].enabled) {
 | 
					      if (template.configuration.deliveryMethodsTemplates[method]?.enabled) {
 | 
				
			||||||
        Object.assign(template.configuration.deliveryMethodsTemplates[method], this.deliveryMethodFormsMap.get(method).value, {method});
 | 
					        Object.assign(template.configuration.deliveryMethodsTemplates[method], this.deliveryMethodFormsMap.get(method).value, {method});
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        delete template.configuration.deliveryMethodsTemplates[method];
 | 
					        delete template.configuration.deliveryMethodsTemplates[method];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user