UNPKG

my-test123

Version:
253 lines 12.2 kB
import { FilterService } from './../../services/filter.service'; import { ActivatedRoute } from '@angular/router'; import { Component, Input, ViewChild, ViewEncapsulation } from '@angular/core'; import { Broadcaster, Logger, Notifications } from 'ngx-base'; import { AuthenticationService } from 'ngx-login-client'; import { Spaces } from 'ngx-fabric8-wit'; import { GroupTypesService } from '../../services/group-types.service'; import { IterationService } from '../../services/iteration.service'; import { WorkItemDataService } from './../../services/work-item-data.service'; import { WorkItemService } from '../../services/work-item.service'; var IterationComponent = /** @class */ (function () { function IterationComponent(log, auth, broadcaster, filterService, groupTypesService, iterationService, notifications, route, spaces, workItemDataService, workItemService) { this.log = log; this.auth = auth; this.broadcaster = broadcaster; this.filterService = filterService; this.groupTypesService = groupTypesService; this.iterationService = iterationService; this.notifications = notifications; this.route = route; this.spaces = spaces; this.workItemDataService = workItemDataService; this.workItemService = workItemService; this.takeFromInput = false; this.iterations = []; this.collection = []; this.sidePanelOpen = true; this.witGroup = ''; this.authUser = null; this.loggedIn = true; this.editEnabled = false; this.isBacklogSelected = true; this.barchatValue = 70; this.allIterations = []; this.eventListeners = []; this.activeIterations = []; this.menuList = []; this.spaceId = ''; this.spaceSubscription = null; } IterationComponent.prototype.ngOnInit = function () { var _this = this; this.listenToEvents(); this.loggedIn = this.auth.isLoggedIn(); this.getAndfilterIterations(); this.editEnabled = true; this.selectedIteration = {}; this.spaceSubscription = this.spaces.current.subscribe(function (space) { if (space) { console.log('[IterationComponent] New Space selected: ' + space.attributes.name); _this.spaceId = space.id; _this.editEnabled = true; _this.getAndfilterIterations(); } else { console.log('[IterationComponent] Space deselected.'); _this.editEnabled = false; _this.allIterations = []; _this.activeIterations = []; } }); if (this.groupTypesService.getCurrentGroupName() === this.witGroup) this.checkUrl(); else this.clearSelected(); }; IterationComponent.prototype.ngOnChanges = function () { if (this.takeFromInput) { // do not display the root iteration on the iteration panel. this.allIterations = []; for (var i = 0; i < this.iterations.length; i++) { if (!this.iterationService.isRootIteration(this.iterations[i].attributes.parent_path)) { this.allIterations.push(this.iterations[i]); } } this.clusterIterations(); this.treeIterations = this.iterationService.getTopLevelIterations(this.allIterations); } }; 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', this.filterService.equal_notation, this.witGroup); //Query for space var space_query = this.filterService.queryBuilder('space', this.filterService.equal_notation, this.spaceId); //Query for iteration var iteration_query = this.filterService.queryBuilder('iteration', this.filterService.equal_notation, iterationId); //Join type and space query var first_join = this.filterService.queryJoiner({}, this.filterService.and_notation, space_query); var second_join = this.filterService.queryJoiner(first_join, this.filterService.and_notation, type_query); var third_join = this.filterService.queryJoiner(second_join, this.filterService.and_notation, iteration_query); //this.setGroupType(witGroup); //second_join gives json object return this.filterService.jsonToQuery(third_join); }; IterationComponent.prototype.getAndfilterIterations = function () { var _this = this; if (this.takeFromInput) { // do not display the root iteration on the iteration panel. this.allIterations = []; for (var i = 0; i < this.iterations.length; i++) { if (!this.iterationService.isRootIteration(this.iterations[i].attributes.parent_path)) { this.allIterations.push(this.iterations[i]); } } this.clusterIterations(); } else { this.iterationService.getIterations() .subscribe(function (iterations) { // do not display the root iteration on the iteration panel. _this.allIterations = []; for (var i = 0; i < iterations.length; i++) { if (!_this.iterationService.isRootIteration(iterations[i].attributes.parent_path)) { _this.allIterations.push(iterations[i]); } } _this.clusterIterations(); }, function (e) { console.log('Some error has occured', e); }); } }; IterationComponent.prototype.clusterIterations = function () { this.activeIterations = this.allIterations.filter(function (iteration) { return iteration.attributes.active_status === true; }); }; IterationComponent.prototype.resolvedName = function (iteration) { return iteration.attributes.resolved_parent_path + '/' + iteration.attributes.name; }; //This function is called after the iteration modal closes. IterationComponent.prototype.onCreateOrupdateIteration = function (iteration) { var index = this.allIterations.findIndex(function (it) { return it.id === iteration.id; }); if (index >= 0) { this.allIterations[index] = iteration; //if iteration is a child iteration update that content var parent_1 = this.iterationService.getDirectParent(iteration, this.allIterations); if (parent_1 != undefined) { var parentIndex = this.allIterations.findIndex(function (i) { return i.id === parent_1.id; }); var childIndex = this.allIterations[parentIndex].children.findIndex(function (child) { return child.id === iteration.id; }); this.allIterations[parentIndex].children[childIndex] = iteration; } } else { this.allIterations.splice(this.allIterations.length, 0, iteration); //Check if the new iteration has a parent if (!this.iterationService.isTopLevelIteration(iteration)) { var parent_2 = this.iterationService.getDirectParent(iteration, this.allIterations); var parentIndex = this.allIterations.findIndex(function (i) { return i.id === parent_2.id; }); if (!this.allIterations[parentIndex].children) { this.allIterations[parentIndex].children = []; this.allIterations[parentIndex].hasChildren = true; } this.allIterations[parentIndex].children.push(iteration); } var childIterations = this.iterationService.checkForChildIterations(iteration, this.allIterations); if (childIterations.length > 0) { this.allIterations[this.allIterations.length].hasChildren = true; this.allIterations[this.allIterations.length].children = childIterations; } } this.treeIterations = this.iterationService.getTopLevelIterations(this.allIterations); this.clusterIterations(); this.iterationService.emitCreateIteration(iteration); }; 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; })); this.eventListeners.push(this.groupTypesService.groupTypeSelected.subscribe(function (wiTypeCollection) { // console.log('listener for groupTypeSelected1', this.groupTypesService.getCurrentGroupName()); // console.log('listener for groupTypeSelected2', this.witGroup); // if( this.groupTypesService.getCurrentGroupName() !== this.witGroup ) // this.clearSelected(); // else // this.checkUrl(); })); }; IterationComponent.prototype.setGuidedTypeWI = function (iteration) { this.selectedIteration = iteration; this.groupTypesService.setCurrentGroupType(this.collection, 'Execution'); }; IterationComponent.prototype.clearSelected = function () { this.selectedIteration = {}; }; IterationComponent.prototype.checkUrl = function () { var queryParams = this.route.snapshot.queryParams; var urlArray = this.route.snapshot.queryParams['q'].split('iteration:'); if (urlArray.length > 1) { var ind = urlArray[1].indexOf(' $AND '); var iterationId_1 = ''; if (ind >= 0) { iterationId_1 = urlArray[1].substring(0, ind); } else { iterationId_1 = urlArray[1].replace(')', ''); } var iteration = this.iterations.find(function (i) { return i.id === iterationId_1; }); this.setGuidedTypeWI(iteration); } }; 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: GroupTypesService, }, { type: IterationService, }, { type: Notifications, }, { type: ActivatedRoute, }, { type: Spaces, }, { type: WorkItemDataService, }, { type: WorkItemService, }, ]; }; IterationComponent.propDecorators = { 'takeFromInput': [{ type: Input },], 'iterations': [{ type: Input },], 'collection': [{ type: Input },], 'sidePanelOpen': [{ type: Input },], 'witGroup': [{ type: Input },], 'modal': [{ type: ViewChild, args: ['modal',] },], }; return IterationComponent; }()); export { IterationComponent }; //# sourceMappingURL=iterations-panel.component.js.map