UNPKG

fabric8-planner

Version:
112 lines 4.68 kB
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { ModalService } from '../../services/modal.service'; import { WorkItemService } from './../../services/work-item.service'; var WorkItemCommentComponent = /** @class */ (function () { function WorkItemCommentComponent(workItemService, modalService, sanitizer) { this.workItemService = workItemService; this.modalService = modalService; this.sanitizer = sanitizer; 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 () { }; WorkItemCommentComponent.prototype.ngAfterViewInit = function () { var commentbox = document.querySelector('#wi-comment-add-comment'); if (!!commentbox) { commentbox.textContent = commentbox.dataset['placeholder']; commentbox.blur(); } }; 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; var newComment = { body: rawText }; if (event.hasOwnProperty('parentId')) { newComment['parentId'] = event.parentId; } callBack('', ''); this.create.emit(newComment); }; WorkItemCommentComponent.prototype.createChildComment = function (newComment) { this.create.emit(newComment); }; WorkItemCommentComponent.prototype.showPreview = function (event) { var _this = this; var rawText = event.rawText; var callBack = event.callBack; this.workItemService.renderMarkDown(rawText) .subscribe(function (renderedHtml) { callBack(rawText, _this.sanitizer.bypassSecurityTrustHtml(renderedHtml)); }); }; WorkItemCommentComponent.prototype.updateComment = function (comment) { this.update.emit(comment); }; 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, }, { type: DomSanitizer, }, ]; }; 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