@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
55 lines (54 loc) • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommentsApiImpl = void 0;
const tslib_1 = require("tslib");
const CommentRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/CommentsRedux"));
const ApiBase_1 = require("./ApiBase");
const ObjectFactory_1 = tslib_1.__importDefault(require("../../Utilities/ObjectFactory"));
const AdaptableHelper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/AdaptableHelper"));
const CommentsInternalApi_1 = require("../Internal/CommentsInternalApi");
class CommentsApiImpl extends ApiBase_1.ApiBase {
constructor(_adaptable) {
super(_adaptable);
this.internalApi = new CommentsInternalApi_1.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_1.default.CreateAdaptableComment(commentText, this.getAdaptableApi())
: null,
cellAddress: address,
}));
}
addCommentThread(commentThread) {
if (!commentThread.Uuid) {
AdaptableHelper_1.default.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();
}
}
exports.CommentsApiImpl = CommentsApiImpl;