UNPKG

my-test123

Version:
75 lines 3.19 kB
import { Component, Input, ViewEncapsulation } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; import * as CommentActions from './../../actions/comment.actions'; var WorkItemCommentWrapperComponent = /** @class */ (function () { function WorkItemCommentWrapperComponent(store) { this.store = store; this.workItem = null; this.comments = []; this.eventListeners = []; this.spaceSource = this.store .select('listPage') .select('space') .filter(function (s) { return !!s; }); this.collaboratorSource = this.store .select('listPage') .select('collaborators') .filter(function (c) { return !!c.length; }); this.commentSource = this.store .select('detailPage') .select('comments'); } Object.defineProperty(WorkItemCommentWrapperComponent.prototype, "workItemSetter", { set: function (workItem) { this.workItem = workItem; this.store.dispatch(new CommentActions.Get(workItem.commentLink)); }, enumerable: true, configurable: true }); WorkItemCommentWrapperComponent.prototype.ngOnInit = function () { var _this = this; Observable.combineLatest(this.spaceSource, this.collaboratorSource).take(1).subscribe(function (_a) { var spaceSource = _a[0], collaboratorSource = _a[1]; _this.eventListeners.push(_this.commentSource.subscribe(function (comments) { _this.comments = comments.slice(); })); }); }; WorkItemCommentWrapperComponent.prototype.ngOnDestroy = function () { this.eventListeners.forEach(function (e) { return e.unsubscribe(); }); }; WorkItemCommentWrapperComponent.prototype.createComment = function (event) { var payload = { url: this.workItem.commentLink, comment: event }; this.store.dispatch(new CommentActions.Add(payload)); }; WorkItemCommentWrapperComponent.prototype.updateComment = function (comment) { this.store.dispatch(new CommentActions.Update(comment)); }; WorkItemCommentWrapperComponent.prototype.deleteComment = function (event) { this.store.dispatch(new CommentActions.Delete(event)); }; WorkItemCommentWrapperComponent.decorators = [ { type: Component, args: [{ encapsulation: ViewEncapsulation.None, selector: 'work-item-comment-wrapper', template: require('./work-item-comment-wrapper.component.html'), },] }, ]; /** @nocollapse */ WorkItemCommentWrapperComponent.ctorParameters = function () { return [ { type: Store, }, ]; }; WorkItemCommentWrapperComponent.propDecorators = { 'loggedIn': [{ type: Input },], 'loggedInUser': [{ type: Input },], 'workItemSetter': [{ type: Input, args: ['workItem',] },], }; return WorkItemCommentWrapperComponent; }()); export { WorkItemCommentWrapperComponent }; //# sourceMappingURL=work-item-comment-wrapper.component.js.map