UNPKG

@adaptabletools/adaptable

Version:

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

50 lines (49 loc) 1.98 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 { 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.CommentsEdit({ comment, cellAddress: address })); } deleteComment(comment, address) { this.dispatchAction(CommentRedux.CommentsDelete({ commentUuid: comment.Uuid, cellAddress: address })); } addComment(commentText, address) { this.dispatchAction(CommentRedux.CommentsAdd({ comment: commentText ? ObjectFactory.CreateAdaptableComment(commentText, this.getAdaptableApi()) : null, cellAddress: address, })); } addCommentThread(commentThread) { if (!commentThread.Uuid) { AdaptableHelper.addAdaptableObjectPrimitives(commentThread); } this.dispatchAction(CommentRedux.CommentsCellAdd({ commentThread: commentThread })); } deleteCommentThread(cellAddress) { this.dispatchAction(CommentRedux.CommentsCellDelete({ cellAddress })); } setComments(cellComments) { this.dispatchAction(CommentRedux.CommentsSet({ commentThread: cellComments })); } clearComments() { this.setComments([]); } hideCommentsPopup() { this.getAdaptableInternalApi().getAnnotationsService().hidePopup(); } }