UNPKG

fabric8-planner

Version:
201 lines 8.48 kB
import { Component, Input, ViewChild, ViewEncapsulation } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { filter, tap } from 'rxjs/operators'; import { Broadcaster, Logger, Notifications } from 'ngx-base'; import { AuthenticationService } from 'ngx-login-client'; import { IterationQuery } from '../../models/iteration.model'; import { IterationService } from '../../services/iteration.service'; import { AND, EQUAL } from '../../services/query-keys'; import { WorkItemService } from '../../services/work-item.service'; import { FilterService } from './../../services/filter.service'; // ngrx stuff import { select, Store } from '@ngrx/store'; import * as IterationActions from './../../actions/iteration.actions'; var IterationComponent = /** @class */ (function () { function IterationComponent(log, auth, broadcaster, filterService, iterationService, notifications, route, workItemService, store, iterationQuery) { var _this = this; this.log = log; this.auth = auth; this.broadcaster = broadcaster; this.filterService = filterService; this.iterationService = iterationService; this.notifications = notifications; this.route = route; this.workItemService = workItemService; this.store = store; this.iterationQuery = iterationQuery; this.takeFromInput = false; this.iterations = []; this.collection = []; this.sidePanelOpen = true; this.showTree = ''; this.showCompleted = ''; this.infotipText = ''; this.authUser = null; this.loggedIn = true; this.editEnabled = false; this.barchatValue = 70; this.eventListeners = []; this.treeIterations = this.iterationQuery.getIterationForTree() .pipe(filter(function (i) { return !!i.length; }), tap(function (i) { if (!_this.startedCheckingURL) { _this.checkURL(); } })); this.activeIterations = this.iterationQuery.getActiveIterations(); this.spaceId = ''; this.startedCheckingURL = false; this.spaceSubscription = null; } IterationComponent.prototype.ngOnInit = function () { var _this = this; this.listenToEvents(); this.loggedIn = this.auth.isLoggedIn(); this.editEnabled = true; this.spaceSubscription = this.store .pipe(select('planner'), select('space')) .subscribe(function (space) { if (space) { console.log('[IterationComponent] New Space selected: ' + space.attributes.name); console.log('collection is ', _this.collection); _this.spaceId = space.id; _this.editEnabled = true; } else { console.log('[IterationComponent] Space deselected.'); _this.editEnabled = false; } }); }; IterationComponent.prototype.ngOnChanges = function () { }; IterationComponent.prototype.ngOnDestroy = function () { // prevent memory leak when component is destroyed this.spaceSubscription.unsubscribe(); this.eventListeners.forEach(function (subscriber) { return subscriber.unsubscribe(); }); }; IterationComponent.prototype.constructURL = function (iterationId) { //Query for work item type group var type_query = this.filterService.queryBuilder('typegroup.name', EQUAL, this.witGroup.name); //Query for iteration var iteration_query = this.filterService.queryBuilder('iteration', EQUAL, iterationId); //Join type and space query var first_join = this.filterService.queryJoiner({}, AND, type_query); var second_join = this.filterService.queryJoiner(first_join, AND, iteration_query); //this.setGroupType(witGroup); //second_join gives json object return this.filterService.jsonToQuery(second_join); }; IterationComponent.prototype.constructURLforBoard = function (iterationId) { //Query for work item type group var type_query = this.filterService.queryBuilder('boardContextId', EQUAL, this.witGroup.id); //Query for iteration var iteration_query = this.filterService.queryBuilder('iteration', EQUAL, iterationId); // join type and iteration query var first_join = this.filterService.queryJoiner({}, AND, type_query); var second_join = this.filterService.queryJoiner(first_join, AND, iteration_query); return this.filterService.jsonToQuery(second_join); }; IterationComponent.prototype.addRemoveQueryParams = function (iterationId) { if (this.context === 'board') { return { q: this.constructURLforBoard(iterationId) }; } if (this.showCompleted && this.showTree) { return { q: this.constructURL(iterationId), showTree: this.showTree, showCompleted: this.showCompleted }; } else if (this.showTree) { return { q: this.constructURL(iterationId), showTree: this.showTree }; } else if (this.showCompleted) { return { q: this.constructURL(iterationId), showCompleted: this.showCompleted }; } else { return { q: this.constructURL(iterationId) }; } }; IterationComponent.prototype.kebabMenuClick = function (event) { event.stopPropagation(); }; IterationComponent.prototype.onEdit = function (iteration) { this.modal.openCreateUpdateModal('update', iteration); }; IterationComponent.prototype.onClose = function (iteration) { this.modal.openCreateUpdateModal('close', iteration); }; IterationComponent.prototype.onCreateChild = function (iteration) { this.modal.openCreateUpdateModal('createChild', iteration); }; IterationComponent.prototype.listenToEvents = function () { var _this = this; this.eventListeners.push(this.broadcaster.on('logout') .subscribe(function (message) { _this.loggedIn = false; _this.authUser = null; })); }; IterationComponent.prototype.checkURL = function () { var _this = this; this.startedCheckingURL = true; this.eventListeners.push(this.route.queryParams.subscribe(function (val) { if (val.hasOwnProperty('q')) { var selectedIterationID = _this.filterService.getConditionFromQuery(val.q, 'iteration'); if (selectedIterationID !== undefined) { _this.store.dispatch(new IterationActions.Select(selectedIterationID)); } else { _this.store.dispatch(new IterationActions.Select()); } } })); }; IterationComponent.decorators = [ { type: Component, args: [{ encapsulation: ViewEncapsulation.None, selector: 'fab-planner-iteration', template: require('./iterations-panel.component.html'), styles: [require('./iterations-panel.component.css').toString()] },] }, ]; /** @nocollapse */ IterationComponent.ctorParameters = function () { return [ { type: Logger, }, { type: AuthenticationService, }, { type: Broadcaster, }, { type: FilterService, }, { type: IterationService, }, { type: Notifications, }, { type: ActivatedRoute, }, { type: WorkItemService, }, { type: Store, }, { type: IterationQuery, }, ]; }; IterationComponent.propDecorators = { 'takeFromInput': [{ type: Input },], 'iterations': [{ type: Input },], 'collection': [{ type: Input },], 'sidePanelOpen': [{ type: Input },], 'witGroup': [{ type: Input },], 'showTree': [{ type: Input },], 'showCompleted': [{ type: Input },], 'infotipText': [{ type: Input },], 'context': [{ type: Input },], 'modal': [{ type: ViewChild, args: ['modal',] },], }; return IterationComponent; }()); export { IterationComponent }; //# sourceMappingURL=iterations-panel.component.js.map