import { Component, OnInit } from '@angular/core'; import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; import { CommentModalState, CommentModalType } from '../../../../utils'; @Component({ selector: 'esp-comments-modal', templateUrl: './comments.modal.html', styleUrls: ['./comments.modal.scss'], }) export class CommentsModalComponent { private commentDeleted = false; data: { id: string; config: any; i18n: any; routeId: string; descriptionId: string; locationId: string; typeOfModal: any; date: any; state: CommentModalState; filter: any; onAdd: (comment: string) => void; type: CommentModalType; onClose?: (commentDeleted: boolean) => void; deleteAll: boolean; // if passed true, the user will have the capability to delete all comments headerCommentCapability: boolean; // if passed true, the user will have the capability to adding comments on header level gridCommentCapability: boolean; // if passed true, the user will have the capability to add comments on the grid cell level // filter should be like {id: 'fghjkl', date: new Date() , ...} // so that it can be used in filtering the comment list and also in adding comments with an id. }; commentState = CommentModalState; commentType = CommentModalType; constructor(public bsModalRef: BsModalRef) {} onClose(): void { this.bsModalRef.hide(); this.triggerCloseCallBack(); } onAddComment(comment: string) { if (this.data.onAdd) { this.data.onAdd(comment); } } onCancelComment() { this.bsModalRef.hide(); this.triggerCloseCallBack(); // this.data = { ...this.data, state: CommentModalState.LIST }; } onDeleteComment() { this.commentDeleted = true; } private triggerCloseCallBack() { if (this.data.onClose) { this.data.onClose(this.commentDeleted); } } }