UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

51 lines (50 loc) 2.01 kB
import * as CommentRedux from '../../Redux/ActionsReducers/CommentsRedux'; import { ApiBase } from './ApiBase'; import ObjectFactory from '../../Utilities/ObjectFactory'; import AdaptableHelper from '../../Utilities/Helpers/AdaptableHelper'; import { CommentsInternalApi } from '../Internal/CommentsInternalApi'; export class CommentsApiImpl extends ApiBase { internalApi; constructor(_adaptable) { super(_adaptable); this.internalApi = new CommentsInternalApi(_adaptable); } getCommentThreadForCell(address) { return CommentRedux.GetCellCommentSelector(this.getAdaptableState().Comment, address); } getAllComments() { return this.getAdaptableState().Comment.CommentThreads ?? []; } editComment(comment, address) { this.dispatchAction(CommentRedux.CommentEdit({ comment, cellAddress: address })); } deleteComment(comment, address) { this.dispatchAction(CommentRedux.CommentsDelete({ commentUuid: comment.Uuid, cellAddress: address })); } addComment(commentText, address) { this.dispatchAction(CommentRedux.CommentAdd({ comment: commentText ? ObjectFactory.CreateAdaptableComment(commentText, this.getAdaptableApi()) : null, cellAddress: address, })); } addCommentThread(commentThread) { if (!commentThread.Uuid) { AdaptableHelper.addAdaptableObjectPrimitives(commentThread); } this.dispatchAction(CommentRedux.CommentThreadAdd({ commentThread: commentThread })); } deleteCommentThread(cellAddress) { this.dispatchAction(CommentRedux.CommentThreadDelete({ cellAddress })); } setComments(commentThreads) { this.dispatchAction(CommentRedux.CommentThreadsLoad({ commentThreads: commentThreads })); } clearComments() { this.setComments([]); } hideCommentsPopup() { this.getAdaptableInternalApi().getAnnotationsService().hidePopup(); } }