UNPKG

my-test123

Version:
141 lines 5.95 kB
import { WorkItemService } from './../../services/work-item.service'; import { CommentLink } from '../../models/comment'; import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Comment, CommentAttributes } from '../../models/comment'; import { ModalService } from '../../services/modal.service'; var WorkItemCommentComponent = /** @class */ (function () { function WorkItemCommentComponent(workItemService, modalService) { this.workItemService = workItemService; this.modalService = modalService; this.loadingComments = true; this.create = new EventEmitter(); this.update = new EventEmitter(); this.delete = new EventEmitter(); this.isCollapsedComments = false; this.commentEditable = false; this.selectedCommentId = ''; } WorkItemCommentComponent.prototype.ngOnInit = function () { this.createCommentObject(); }; WorkItemCommentComponent.prototype.ngAfterViewInit = function () { var commentbox = document.querySelector("#wi-comment-add-comment"); if (!!commentbox) { commentbox.textContent = commentbox.dataset['placeholder']; commentbox.blur(); } }; WorkItemCommentComponent.prototype.createCommentObject = function () { this.comment = new Comment(); this.comment.type = 'comments'; this.comment.attributes = new CommentAttributes(); this.comment.links = new CommentLink(); }; ; WorkItemCommentComponent.prototype.openComment = function (id) { if (this.loggedIn) { this.selectedCommentId = id; this.commentEditable = true; } }; WorkItemCommentComponent.prototype.createComment = function (event) { var rawText = event.rawText; var callBack = event.callBack; this.comment.attributes.body = rawText; this.comment.attributes.markup = 'Markdown'; this.create.emit(this.comment); callBack('', ''); this.createCommentObject(); }; WorkItemCommentComponent.prototype.showPreview = function (event) { var rawText = event.rawText; var callBack = event.callBack; this.workItemService.renderMarkDown(rawText) .subscribe(function (renderedHtml) { callBack(rawText, renderedHtml); }); }; WorkItemCommentComponent.prototype.updateComment = function (event, comment) { var _this = this; var rawText = event.rawText; var callBack = event.callBack; var newCommentBody = rawText; comment.attributes.body = newCommentBody; comment.attributes.markup = 'Markdown'; this.workItemService .updateComment(comment) .subscribe(function (updatedComment) { _this.update.emit(updatedComment); callBack(updatedComment.attributes.body, updatedComment.attributes['body.rendered']); _this.createCommentObject(); }, function (error) { console.log(error); }); }; WorkItemCommentComponent.prototype.confirmCommentDelete = function (comment) { var _this = this; this.convictedComment = comment; this.modalService.openModal('Delete Comment', 'Are you sure you want to delete this comment?', 'Delete', 'deleteComment') .first() .subscribe(function (actionKey) { if (actionKey === 'deleteComment') _this.deleteComment(); }); }; WorkItemCommentComponent.prototype.deleteComment = function () { this.delete.emit(this.convictedComment); this.createCommentObject(); }; WorkItemCommentComponent.prototype.onCommentEdit = function ($event, inpId, saveBtnId) { this.preventDef($event); // console.log(document.getElementById(saveBtnId).cla); if (document.getElementById(inpId).innerHTML.trim() === '') { document.getElementById(saveBtnId).classList.add('disabled'); } else { document.getElementById(saveBtnId).classList.remove('disabled'); } }; WorkItemCommentComponent.prototype.closeCommentEditing = function () { this.selectedCommentId = ''; }; WorkItemCommentComponent.prototype.resetCommentDraft = function (event) { if (event === void 0) { event = null; } var commentbox = event.target, placeholder = event.target.dataset.placeholder; if (event.type === 'focus' && commentbox.textContent === placeholder) { commentbox.classList.remove("placeholder"); commentbox.textContent = ''; } else if (event.type === 'blur' && commentbox.textContent === '') { commentbox.classList.add("placeholder"); commentbox.textContent = placeholder; } }; WorkItemCommentComponent.prototype.preventDef = function (event) { event.preventDefault(); }; WorkItemCommentComponent.decorators = [ { type: Component, args: [{ selector: 'alm-work-item-comment', template: require('./work-item-comment.component.html'), styles: [require('./work-item-comment.component.css').toString()], },] }, ]; /** @nocollapse */ WorkItemCommentComponent.ctorParameters = function () { return [ { type: WorkItemService, }, { type: ModalService, }, ]; }; WorkItemCommentComponent.propDecorators = { 'loadingComments': [{ type: Input },], 'comments': [{ type: Input },], 'loggedIn': [{ type: Input },], 'loggedInUser': [{ type: Input },], 'create': [{ type: Output },], 'update': [{ type: Output },], 'delete': [{ type: Output },], }; return WorkItemCommentComponent; }()); export { WorkItemCommentComponent }; //# sourceMappingURL=work-item-comment.component.js.map