UNPKG

my-test123

Version:
913 lines 44.6 kB
import { FilterService } from '../../services/filter.service'; import { AreaService } from '../../services/area.service'; import { Component, ElementRef, ViewChild, ViewChildren, Renderer2 } from '@angular/core'; import { Router, ActivatedRoute, NavigationStart } from '@angular/router'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { cloneDeep } from 'lodash'; import { IterationService } from '../../services/iteration.service'; import { Observable } from 'rxjs/Observable'; import { Broadcaster, NotificationType, Notifications } from 'ngx-base'; import { Spaces } from 'ngx-fabric8-wit'; import { AuthenticationService, UserService } from 'ngx-login-client'; import { DragulaService } from 'ng2-dragula'; import { UrlService } from './../../services/url.service'; import { WorkItemService } from '../../services/work-item.service'; import { WorkItemDataService } from './../../services/work-item-data.service'; import { CollaboratorService } from '../../services/collaborator.service'; import { LabelService } from '../../services/label.service'; import { GroupTypesService } from '../../services/group-types.service'; var PlannerBoardComponent = /** @class */ (function () { function PlannerBoardComponent(auth, broadcaster, collaboratorService, notifications, router, workItemService, groupTypesService, workItemDataService, dragulaService, iterationService, labelService, userService, urlService, spaces, areaService, filterService, route, renderer) { var _this = this; this.auth = auth; this.broadcaster = broadcaster; this.collaboratorService = collaboratorService; this.notifications = notifications; this.router = router; this.workItemService = workItemService; this.groupTypesService = groupTypesService; this.workItemDataService = workItemDataService; this.dragulaService = dragulaService; this.iterationService = iterationService; this.labelService = labelService; this.userService = userService; this.urlService = urlService; this.spaces = spaces; this.areaService = areaService; this.filterService = filterService; this.route = route; this.renderer = renderer; this.filters = []; this.lanes = []; this.pageSize = 20; this.loggedIn = false; this.contentItemHeight = 85; this.allUsers = []; this.iterations = []; this.workItemTypes = []; this.readyToInit = false; this.areas = []; this.eventListeners = []; this.showDialog = false; this.dragulaEventListeners = []; this.allowedFilterParams = ['iteration']; this.urlListener = null; this.existingQueryParams = {}; this.quickAddContext = []; this.initialGroup = []; this.wiSubscription = null; this.labels = []; this.uiLockedAll = false; this.uiLockedBoard = true; this.uiLockedSidebar = false; this.groupTypes = []; this.sidePanelOpen = true; var bag = this.dragulaService.find('wi-bag'); this.dragulaEventListeners.push(this.dragulaService.drag.subscribe(function (value) { _this.onDrag(value.slice(1)); }), this.dragulaService.drop .map(function (value) { return value.slice(1); }) .filter(function (value) { return !value[1].classList.contains('f8-itr') && !value[1].classList.contains('iteration-header'); }).subscribe(function (args) { return _this.onDrop(args); }), this.dragulaService.over .map(function (value) { return value.slice(1); }) .filter(function (value) { return value[1].classList.contains('f8-board__card'); }) .subscribe(function (args) { return _this.onOver(args); }), this.dragulaService.out.subscribe(function (value) { _this.onOut(value.slice(1)); })); if (bag !== undefined) { this.dragulaService.destroy('wi-bag'); } } PlannerBoardComponent.prototype.ngOnInit = function () { var _this = this; // If there is an iteration on the URL // Setting the value to currentIteration // BehaviorSubject so that we can compare // on update the value on URL var queryParams = this.route.snapshot.queryParams; if (Object.keys(queryParams).indexOf('iteration') > -1) { this.currentIteration = new BehaviorSubject(queryParams['iteration']); } else { this.currentIteration = new BehaviorSubject(null); } if (Object.keys(queryParams).indexOf('workitemtype') > -1) { this.currentWIType = new BehaviorSubject(queryParams['workitemtype']); } else { this.currentWIType = new BehaviorSubject(null); } this.listenToEvents(); this.loggedIn = this.auth.isLoggedIn(); this.spaceSubscription = this.spaces.current.subscribe(function (space) { if (space) { console.log('[WorkItemBoardComponent] New Space selected: ' + space.attributes.name); _this.initStuff(); } else { console.log('[WorkItemBoardComponent] Space deselected'); _this.lanes = []; _this.workItemTypes = []; } }); this.filterService.getFilters().subscribe(function (filters) { return filters.forEach(function (f) { return _this.filters.push(f.attributes.key); }); }); }; PlannerBoardComponent.prototype.ngAfterViewChecked = function () { if (this.toolbarHeight) { var toolbarHt = this.toolbarHeight.nativeElement.offsetHeight; var hdrHeight = void 0; if (document.getElementsByClassName('navbar-pf').length > 0) { hdrHeight = document.getElementsByClassName('navbar-pf')[0].offsetHeight; } var expHeight = 0; if (document.getElementsByClassName('experimental-bar').length > 0) { expHeight = document.getElementsByClassName('experimental-bar')[0].offsetHeight; } var targetHeight = window.innerHeight - toolbarHt - hdrHeight - expHeight; this.renderer.setStyle(this.boardContainer.nativeElement, 'height', targetHeight + "px"); var targetContHeight = window.innerHeight - hdrHeight - expHeight; this.renderer.setStyle(this.containerHeight.nativeElement, 'height', targetContHeight + "px"); if (document.getElementsByTagName('body')) { document.getElementsByTagName('body')[0].style.overflow = "hidden"; } } }; PlannerBoardComponent.prototype.ngOnDestroy = function () { console.log('Destroying all the listeners in board component'); if (this.wiSubscription !== null) this.wiSubscription.unsubscribe(); this.eventListeners.forEach(function (subscriber) { return subscriber.unsubscribe(); }); this.dragulaEventListeners.forEach(function (subscriber) { return subscriber.unsubscribe(); }); if (this.urlListener) { this.urlListener.unsubscribe(); this.urlListener = null; } document.getElementsByTagName('body')[0].style.overflow = "auto"; }; PlannerBoardComponent.prototype.initStuff = function () { var _this = this; this.uiLockedBoard = true; Observable.combineLatest(this.iterationService.getIterations(), // this.collaboratorService.getCollaborators(), this.workItemService.getWorkItemTypes(), this.areaService.getAreas(), this.labelService.getLabels(), this.userService.getUser().catch(function (err) { return Observable.of({}); }), this.currentIteration, this.groupTypesService.getGroupTypes()) .subscribe(function (_a) { var iterations = _a[0], wiTypes = _a[1], areas = _a[2], labels = _a[3], loggedInUser = _a[4], currentIteration = _a[5], groupTypes = _a[6]; _this.iterations = iterations; _this.workItemTypes = wiTypes; _this.readyToInit = true; _this.areas = areas; _this.labels = labels; _this.loggedInUser = loggedInUser; _this.groupTypes = groupTypes; // Resolve iteration filter on the first load of board view // If there is an existing iteration query params already // Set the filter service with iteration filter if (currentIteration !== null) { var filterIteration = _this.iterations.find(function (it) { return it.attributes.resolved_parent_path + '/' + it.attributes.name === currentIteration.toString(); }); if (filterIteration) { _this.filterService.setFilterValues('iteration', filterIteration.id); } } else { _this.filterService.clearFilters(['iteration']); } // Set lanes _this.prepareLanes(); _this.uiLockedBoard = false; }); }; PlannerBoardComponent.prototype.getWorkItems = function (pageSize, mainLane, payload) { var _this = this; var lane = cloneDeep(mainLane); var exp = { expression: this.filterService.queryJoiner(cloneDeep(payload.expression), this.filterService.and_notation, this.filterService.queryBuilder('state', this.filterService.equal_notation, lane.option)) }; return this.workItemService.getWorkItems2(pageSize, exp) .map(function (workItemResp) { var workItems = workItemResp.workItems; _this.included = workItemResp.included; var cardValue = []; _this.workItemDataService.setItems(workItems); lane.workItems = _this.workItemService.resolveWorkItems(workItems, _this.iterations, [], _this.workItemTypes, _this.labels, _this.included); lane.cardValue = lane.workItems.map(function (item) { return { id: item.attributes['system.number'], type: item.relationships.baseType.data.attributes['icon'], title: item.attributes['system.title'], avatar: '', hasLink: true, link: "./../detail/" + item.attributes['system.number'], menuItem: [{ id: 'card_associate_iteration', value: 'Associate with iteration...' }, { id: 'card_open', value: 'Open', link: "./../detail/" + item.attributes['system.number'] }, { id: 'card_move_to_backlog', value: 'Move to backlog' }], extraData: { selfLink: item.links.self, version: item.attributes['version'], UUID: item.id, labels: item.relationships.labels.data } }; }); lane.nextLink = workItemResp.nextLink; return lane; }); }; PlannerBoardComponent.prototype.createCardItem = function (workItems) { var lane; var cardValues = []; workItems = this.workItemService.resolveWorkItems(workItems, this.iterations, [], this.workItemTypes, this.labels); var _loop_1 = function (i) { lane = this_1.lanes.find(function (lane) { return lane.option === workItems[i].attributes['system.state']; }); cardValues.push({ id: workItems[i].attributes['system.number'], type: workItems[i].relationships.baseType.data.attributes['icon'], title: workItems[i].attributes['system.title'], avatar: (function () { if (workItems[i].relationships.assignees.data) return workItems[i].relationships.assignees.data[0].attributes['imageURL']; else return ''; })(), hasLink: true, link: "./../detail/" + workItems[i].attributes['system.number'], menuItem: [{ id: 'card_associate_iteration', value: 'Associate with iteration...' }, { id: 'card_open', value: 'Open', link: "./../detail/" + workItems[i].attributes['system.number'] }, { id: 'card_move_to_backlog', value: 'Move to backlog' }], extraData: { selfLink: workItems[i].links.self, version: workItems[i].attributes['version'], UUID: workItems[i].id, labels: workItems[i].relationships.labels.data } }); lane.cardValue = cardValues.concat(lane.cardValue); }; var this_1 = this; for (var i = 0; i < workItems.length; i++) { _loop_1(i); } }; PlannerBoardComponent.prototype.updateCardItem = function (workItem) { this.workItemService.resolveType(workItem); var lane = this.lanes.find(function (lane) { return lane.option === workItem.attributes['system.state']; }); var cardItem = lane.cardValue.find(function (item) { return item.id === workItem.attributes['system.number']; }); cardItem.title = workItem.attributes['system.title']; cardItem.type = workItem.relationships.baseType.data.attributes['icon']; cardItem.extraData['version'] = workItem.attributes['version']; this.workItemService.resolveAssignees(workItem.relationships.assignees) .subscribe(function (assignees) { workItem.relationships.assignees.data = assignees; cardItem.avatar = (function () { if (workItem.relationships.assignees.data.length > 0) return workItem.relationships.assignees.data[0].attributes['imageURL']; else return ''; })(); }); }; PlannerBoardComponent.prototype.cardMenuClick = function (menuId, itemNumber, lane) { this.workItem = lane.workItems.find(function (item) { return item.attributes['system.number'] === itemNumber; }); if (menuId === 'card_associate_iteration') { this.associateIterationModal.open(); } else if (menuId === 'card_move_to_backlog') { this.onMoveToBacklog(); } }; PlannerBoardComponent.prototype.onMoveToBacklog = function () { var _this = this; //set this work item's iteration to None //send a patch request this.workItem.relationships.iteration = {}; this.workItemService .update(this.workItem) .switchMap(function (item) { return _this.iterationService.getIteration(item.relationships.iteration) .map(function (iteration) { item.relationships.iteration.data = iteration; return item; }); }) .subscribe(function (workItem) { _this.workItem.relationships.iteration = workItem.relationships.iteration; _this.workItem.attributes['version'] = workItem.attributes['version']; _this.updateCardItem(workItem); _this.workItemDataService.setItem(workItem); try { _this.notifications.message({ message: workItem.attributes['system.title'] + ' has been moved to the Backlog.', type: NotificationType.SUCCESS }); } catch (e) { console.log('Error displaying notification. Iteration was moved to Backlog.'); } }, function (err) { try { _this.notifications.message({ message: _this.workItem.attributes['system.title'] + ' could not be moved to the Backlog.', type: NotificationType.DANGER }); } catch (e) { console.log('Error displaying notification. Error moving Iteration to Backlog.'); } }); }; PlannerBoardComponent.prototype.prepareLanes = function () { var _this = this; this.lanes = []; var lanes = ['new', 'open', 'in progress', 'resolved', 'closed']; lanes.forEach(function (value, index) { _this.lanes.push({ option: value, workItems: [], nextLink: null }); }); }; /** * Called from each lane * @param event * @param lane */ PlannerBoardComponent.prototype.initWiItems = function ($event, lane) { this.pageSize = $event.pageSize; // Subscribe only once // When the first lane is ready // we have the page size if (this.urlListener === null) { this.listenToUrlParams(); } // Once all the lanes inititated, apply the filters to load work items if (lane.option === this.lanes[this.lanes.length - 1].option) { this.filterService.applyFilter(); } }; PlannerBoardComponent.prototype.fetchMoreWiItems = function (lane) { var _this = this; console.log('More for ' + lane.option); if (lane.nextLink) { var resolveFromIndex_1 = lane.workItems.length; this.workItemService.getMoreWorkItems(lane.nextLink) .map(function (workItemResp) { lane.workItems = lane.workItems.concat(_this.workItemService.resolveWorkItems(workItemResp.workItems, _this.iterations, [], _this.workItemTypes, _this.labels, workItemResp.included)); lane.cardValue = lane.cardValue.concat(workItemResp.workItems.map(function (item) { return { id: item.attributes['system.number'], type: item.relationships.baseType.data.attributes['icon'], title: item.attributes['system.title'], avatar: '', hasLink: true, link: "./../detail/" + item.attributes['system.number'], menuItem: [{ id: 'card_associate_iteration', value: 'Associate with iteration...' }, { id: 'card_open', value: 'Open', link: "./../detail/" + item.attributes['system.number'] }, { id: 'card_move_to_backlog', value: 'Move to backlog' }], extraData: { selfLink: item.links.self, version: item.attributes['version'], UUID: item.id, labels: item.relationships.labels.data } }; })); lane.nextLink = workItemResp.nextLink; return resolveFromIndex_1; }) .map(function (indexFrom) { var itemsToTakeCare = cloneDeep(lane.workItems); var usersToFetch = []; itemsToTakeCare.splice(0, indexFrom); itemsToTakeCare .filter(function (item) { return item.relationships.assignees.data && item.relationships.assignees.data.length; }) .forEach(function (item) { item.relationships.assignees.data.forEach(function (user) { if (usersToFetch.indexOf(user.links.self) === -1) { usersToFetch.push(user.links.self); } }); }); return usersToFetch; }) .flatMap(function (usersToFetch) { return _this.workItemService.getUsersByURLs(usersToFetch); }) .do(function (users) { var _loop_2 = function (w_index) { // Resolve assignee here if (Object.keys(lane.workItems[w_index].relationships.assignees).length && lane.workItems[w_index].relationships.assignees.data.length) { lane.workItems[w_index].relationships.assignees.data.forEach(function (assignee, a_index) { lane.workItems[w_index].relationships.assignees.data[a_index] = users.find(function (u) { return u.id === assignee.id; }); lane.cardValue[w_index].avatar = lane.workItems[w_index].relationships.assignees.data[a_index].attributes['imageURL']; }); } }; for (var w_index = resolveFromIndex_1; w_index < lane.workItems.length; w_index++) { _loop_2(w_index); } }) .subscribe(); } else { console.log('No More for ' + lane.option); } }; PlannerBoardComponent.prototype.onCreateWorkItem = function (workItem) { var resolveItem = this.workItemService.resolveWorkItems([workItem], this.iterations, [], this.workItemTypes, this.labels); var lane = this.lanes.find(function (lane) { return lane.option === workItem.attributes['system.state']; }); lane.workItems = resolveItem.concat(lane.workItems); this.createCardItem([workItem]); }; // gotoDetail(workItem: WorkItem) { // let link = trimEnd(this.router.url.split('detail')[0], '/') + '/detail/' + workItem.id; // this.router.navigateByUrl(link); // } PlannerBoardComponent.prototype.openDetail = function (event) { event.stopPropagation(); }; PlannerBoardComponent.prototype.confirmDelete = function (event) { event.stopPropagation(); this.dialog = { 'title': 'Confirm deletion of Work Item', 'message': 'Are you sure you want to delete Work Item - ' + this.workItem.attributes['system.title'] + ' ?', 'actionButtons': [ { 'title': 'Confirm', 'value': 1, 'default': false }, { 'title': 'Cancel', 'value': 0, 'default': true } ] }; this.showDialog = true; }; PlannerBoardComponent.prototype.onButtonClick = function (val) { // callback from the confirm delete dialog if (val == 1) { this.onDelete(null); } this.showDialog = false; }; PlannerBoardComponent.prototype.onDelete = function (event) { if (event) event.stopPropagation(); this.workItemService.delete(this.workItem) .subscribe(function () { console.log('Deleted'); }); }; PlannerBoardComponent.prototype.onTouchstart = function (event) { event.preventDefault(); }; PlannerBoardComponent.prototype.onDrag = function (args) { var el = args[0], source = args[1]; console.log('board component on drag'); }; PlannerBoardComponent.prototype.getWI = function (workItemNumber, lane) { //let lane = this.lanes.find((lane) => lane.option === workItem.attributes['system.state']); var _workItem = lane.workItems.find(function (item) { return item.attributes['system.number'] === workItemNumber; }); var _cardItem = lane.cardValue.find(function (item) { return item.id === workItemNumber; }); this.workItem = cloneDeep(_workItem); this.cardItem = cloneDeep(_cardItem); }; PlannerBoardComponent.prototype.isSelected = function (wi) { return this.workItem == wi; }; PlannerBoardComponent.prototype.onDrop = function (args) { console.log('board component on drop', args); var el = args[0], target = args[1], source = args[2], sibling = args[3]; target.parentElement.parentElement.classList.remove('active-lane'); var state = target.parentElement.parentElement.getAttribute('data-state'); var adjElm = null; var prevElId = '0'; try { prevElId = el.previousElementSibling.getAttribute('data-id'); } catch (e) { } this.changeLane(this.workItem.attributes['system.state'], state, this.workItem, prevElId); if (el.previousElementSibling) { adjElm = el.previousElementSibling; this.changeState(state, el.getAttribute('data-id'), adjElm.getAttribute('data-UUID'), 'below'); } else if (el.nextElementSibling) { adjElm = el.nextElementSibling; this.changeState(state, el.getAttribute('data-id'), adjElm.getAttribute('data-UUID'), 'above'); } else { this.changeState(state, el.getAttribute('data-id'), null, 'above'); } }; PlannerBoardComponent.prototype.onOver = function (args) { var el = args[0], container = args[1], source = args[2]; var containerClassList = container.parentElement.parentElement.classList; var laneSection = document.getElementsByClassName('board-lane-column'); for (var i = 0; i < laneSection.length; i++) { laneSection[i].classList.remove('active-lane'); } containerClassList.add('active-lane'); el.classList.remove('hide'); }; PlannerBoardComponent.prototype.onOut = function (args) { var el = args[0], container = args[1], source = args[2]; source.parentElement.parentElement.classList.remove('active-lane'); }; PlannerBoardComponent.prototype.activeOnList = function (timeOut) { var _this = this; if (timeOut === void 0) { timeOut = 0; } setTimeout(function () { _this.broadcaster.broadcast('activeWorkItem', _this.workItem.id); }, timeOut); }; PlannerBoardComponent.prototype.changeState = function (option, elId, adjElmId, direction) { var _this = this; if (adjElmId === void 0) { adjElmId = null; } var prevState = this.workItem.attributes['system.state']; this.workItem.attributes['system.state'] = option; var lane = this.lanes.find(function (lane) { return lane.option === _this.workItem.attributes['system.state']; }); if (this.workItem.id) { this.workItemService .update(this.workItem) .subscribe(function (workItem) { var wItem = lane.workItems.find(function (item) { return item.id === workItem.id; }); wItem.attributes['version'] = workItem.attributes['version']; _this.updateCardItem(workItem); _this.workItemDataService.setItem(workItem); if (wItem.relationships.iteration) { // Item closed for an iteration if (wItem.attributes['system.state'] !== 'closed' && prevState === 'closed') { _this.broadcaster.broadcast('wi_change_state_it', [{ iterationId: wItem.relationships.iteration.data.id, closedItem: +1 }]); } // Item opened for an iteration if (wItem.attributes['system.state'] === 'closed' && prevState !== 'closed') { _this.broadcaster.broadcast('wi_change_state_it', [{ iterationId: wItem.relationships.iteration.data.id, closedItem: -1 }]); } } _this.activeOnList(); if (adjElmId !== null) { _this.workItemService.reOrderWorkItem(wItem, adjElmId, direction) .subscribe(function (workitem) { _this.workItemDataService.setItem(workItem); lane.workItems.find(function (item) { return item.id === workItem.id; }).attributes['version'] = workitem.attributes['version']; lane.workItems.find(function (item) { return item.id === workItem.id; }).attributes['system.order'] = workitem.attributes['system.order']; _this.updateCardItem(workitem); }); } }); } }; PlannerBoardComponent.prototype.changeLane = function (oldState, newState, workItem, prevIdEl) { if (prevIdEl === void 0) { prevIdEl = null; } var oldLane = this.lanes.find(function (lane) { return lane.option === oldState; }); var newLane = this.lanes.find(function (lane) { return lane.option === newState; }); var index = oldLane.workItems.findIndex(function (item) { return item.id === workItem.id; }); var _index = oldLane.cardValue.findIndex(function (item) { return item.id === workItem.attributes['system.number']; }); oldLane.workItems.splice(index, 1); oldLane.cardValue.splice(_index, 1); if (prevIdEl !== null) { var newIndex = newLane.workItems.findIndex(function (item) { return item.attributes['system.number'] == prevIdEl; }); var _newIndex = newLane.cardValue.findIndex(function (item) { return item.id == prevIdEl; }); if (newIndex > -1 && _newIndex > -1) { newIndex += 1; _newIndex += 1; newLane.workItems.splice(newIndex, 0, workItem); newLane.cardValue.splice(_newIndex, 0, this.cardItem); } else { newLane.workItems.splice(0, 0, workItem); newLane.cardValue.splice(0, 0, this.cardItem); } } else { newLane.workItems.push(workItem); newLane.cardValue.push(this.cardItem); } }; PlannerBoardComponent.prototype.listenToEvents = function () { var _this = this; this.eventListeners.push(this.broadcaster.on('wi_change_state') .subscribe(function (data) { _this.changeLane(data[0].oldState, data[0].newState, data[0].workItem); })); this.eventListeners.push(this.workItemService.editWIObservable.subscribe(function (updatedItem) { var lane = _this.lanes.find(function (lane) { return lane.option === updatedItem.attributes['system.state']; }); var index = lane.workItems.findIndex(function (item) { return item.id == updatedItem.id; }); var cardItem = lane.cardValue.find(function (item) { return item.id == updatedItem.attributes['system.number']; }); _this.workItemDataService.setItem(updatedItem); if (_this.filterService.doesMatchCurrentFilter(updatedItem)) { if (index > -1) { lane.workItems[index] = updatedItem; _this.updateCardItem(updatedItem); } else { lane.workItems.splice(0, 0, updatedItem); _this.createCardItem([updatedItem]); } } else { lane.workItems.splice(index, 1); lane.cardValue.splice(index, 1); } })); this.eventListeners.push(Observable.combineLatest(this.filterService.filterChange, this.route.queryParams).subscribe(function (_a) { var filters = _a[0], params = _a[1]; if (_this.wiSubscription !== null) { _this.wiSubscription.unsubscribe(); } _this.wiSubscription = _this.spaces.current.switchMap(function (space) { var appliedFilters = _this.filterService.getAppliedFilters(true); // remove the filter item from the filters for (var f = 0; f < appliedFilters.length; f++) { if (appliedFilters[f].paramKey == 'filter[parentexists]') { appliedFilters.splice(f, 1); } } // TODO Filter temp // Take all the applied filters and prepare an object to make the query string var newFilterObj = {}; appliedFilters.forEach(function (item) { newFilterObj[item.id] = item.value; }); var payload = {}; if (_this.route.snapshot.queryParams['q']) { var urlString = _this.route.snapshot.queryParams['q'] .replace(' ', '') .replace('$AND', ' ') .replace('$OR', ' ') .replace('(', '') .replace(')', ''); var temp_arr = urlString.split(' '); for (var i = 0; i < temp_arr.length; i++) { var arr = temp_arr[i].split(':'); //check if it belongs in filter array if (_this.filters.indexOf(arr[0]) < 0 && arr[1] !== undefined) newFilterObj[arr[0]] = arr[1]; } var exp = _this.filterService.queryToJson(_this.filterService.constructQueryURL('', newFilterObj)); Object.assign(payload, { expression: exp }); } else { var exp = _this.filterService.queryToJson(_this.filterService.constructQueryURL('', newFilterObj)); Object.assign(payload, { expression: exp }); } return Observable.forkJoin(_this.lanes.map(function (lane) { return _this.getWorkItems(_this.pageSize, lane, payload); })); }) .take(1) .map(function (finalLanes) { var usersToFetch = []; _this.lanes.forEach(function (lane, index) { _this.lanes[index].cardValue = cloneDeep(finalLanes[index].cardValue); _this.lanes[index].workItems = cloneDeep(finalLanes[index].workItems); _this.lanes[index].nextLink = finalLanes[index].nextLink; _this.lanes[index].workItems .filter(function (item) { return item.relationships.assignees.data && item.relationships.assignees.data.length; }) .forEach(function (item) { item.relationships.assignees.data.forEach(function (user) { if (usersToFetch.indexOf(user.links.self) === -1) { usersToFetch.push(user.links.self); } }); }); }); return usersToFetch; }) .flatMap(function (usersToFetch) { return _this.workItemService.getUsersByURLs(usersToFetch); }) .do(function (users) { _this.lanes.forEach(function (lane, l_index) { _this.lanes[l_index].workItems.forEach(function (item, w_index) { // Resolve assignee here if (Object.keys(item.relationships.assignees).length && item.relationships.assignees.data.length) { item.relationships.assignees.data.forEach(function (assignee, a_index) { _this.lanes[l_index].workItems[w_index].relationships.assignees.data[a_index] = users.find(function (u) { return u.id === assignee.id; }); _this.lanes[l_index].cardValue[w_index].avatar = _this.lanes[l_index].workItems[w_index].relationships.assignees.data[a_index].attributes['imageURL']; }); } }); }); }) .subscribe(); })); this.eventListeners.push(this.workItemService.addWIObservable.subscribe(function (item) { if (_this.filterService.doesMatchCurrentFilter(item.wi)) { _this.onCreateWorkItem(item.wi); } })); this.eventListeners.push(this.iterationService.dropWIObservable .flatMap(function (data) { if (data.error) { return _this.workItemDataService.getItem(data.workItem.id); } return Observable.of(data.workItem); }) .map(function (WI) { var lane = _this.lanes.find(function (lane) { return lane.option === WI.attributes['system.state']; }); var index = lane.workItems.findIndex(function (item) { return item.id == WI.id; }); return [index, lane, WI]; }) .filter(function (_a) { var index = _a[0], lane = _a[1], WI = _a[2]; return index > -1; }) .map(function (_a) { var index = _a[0], lane = _a[1], WI = _a[2]; var workItem = cloneDeep(lane.workItems.splice(index, 1)[0]); var cardItem = cloneDeep(lane.cardValue.splice(index, 1)[0]); workItem.attributes['version'] = WI.attributes['version']; workItem.relationships.iteration = WI.relationships.iteration; cardItem.extraData['version'] = WI.attributes['version']; return [lane, index, cardItem, workItem]; }) .delay(0) .subscribe(function (_a) { var lane = _a[0], index = _a[1], cardItem = _a[2], workItem = _a[3]; if (_this.filterService.doesMatchCurrentFilter(workItem)) { lane.cardValue.splice(index, 0, cardItem); lane.workItems.splice(index, 0, workItem); } })); this.eventListeners.push(this.router.events .filter(function (event) { return event instanceof NavigationStart; }) .subscribe(function (event) { if (event.url.indexOf('/plan/detail/') > -1) { // It's going to the detail page var url = location.pathname; var query = location.href.split('?'); if (query.length == 2) { url = url + '?' + query[1]; } _this.urlService.recordLastListOrBoard(url); } })); // lock the ui when a complex query is starting in the background this.eventListeners.push(this.broadcaster.on('backend_query_start') .subscribe(function (context) { switch (context) { case 'workitems': _this.uiLockedBoard = true; break; case 'iterations': _this.uiLockedSidebar = true; break; case 'mixed': _this.uiLockedAll = true; break; default: break; } })); // unlock the ui when a complex query is completed in the background this.eventListeners.push(this.broadcaster.on('backend_query_end') .subscribe(function (context) { switch (context) { case 'workitems': _this.uiLockedBoard = false; break; case 'iterations': _this.uiLockedSidebar = false; break; case 'mixed': _this.uiLockedAll = false; break; default: break; } })); }; PlannerBoardComponent.prototype.listenToUrlParams = function () { var _this = this; this.urlListener = this.route.queryParams.subscribe(function (params) { _this.existingQueryParams = params; if (Object.keys(params).indexOf('iteration') > -1) { if (params['iteration'] !== _this.currentIteration.getValue()) { _this.currentIteration.next(params['iteration']); } } else if (_this.currentIteration.getValue() !== null) { _this.currentIteration.next(null); } if (Object.keys(params).indexOf('workitemtype') > -1) { if (params['workitemtype'] !== _this.currentWIType.getValue()) { console.log('[WorkItemBoardComponent] New type context selected: ' + params['workitemtype']); _this.currentWIType.next(params['workitemtype']); } } else if (_this.currentWIType.getValue() !== null) { _this.currentWIType.next(null); } }); }; PlannerBoardComponent.prototype.togglePanelState = function (event) { var _this = this; if (event === 'out') { setTimeout(function () { _this.sidePanelOpen = true; }, 200); } else { this.sidePanelOpen = false; } }; PlannerBoardComponent.prototype.togglePanel = function () { this.sidePanelRef.toggleSidePanel(); }; PlannerBoardComponent.decorators = [ { type: Component, args: [{ // tslint:disable-next-line:use-host-property-decorator selector: 'alm-board', template: require('./planner-board.component.html'), styles: [require('./planner-board.component.css').toString()] },] }, ]; /** @nocollapse */ PlannerBoardComponent.ctorParameters = function () { return [ { type: AuthenticationService, }, { type: Broadcaster, }, { type: CollaboratorService, }, { type: Notifications, }, { type: Router, }, { type: WorkItemService, }, { type: GroupTypesService, }, { type: WorkItemDataService, }, { type: DragulaService, }, { type: IterationService, }, { type: LabelService, }, { type: UserService, }, { type: UrlService, }, { type: Spaces, }, { type: AreaService, }, { type: FilterService, }, { type: ActivatedRoute, }, { type: Renderer2, }, ]; }; PlannerBoardComponent.propDecorators = { 'activeFiltersRef': [{ type: ViewChildren, args: ['activeFilters', { read: ElementRef },] },], 'activeFiltersDiv': [{ type: ViewChild, args: ['activeFiltersDiv',] },], 'associateIterationModal': [{ type: ViewChild, args: ['associateIterationModal',] },], 'sidePanelRef': [{ type: ViewChild, args: ['sidePanel',] },], 'toolbarHeight': [{ type: ViewChild, args: ['toolbarHeight',] },], 'boardContainer': [{ type: ViewChild, args: ['boardContainer',] },], 'containerHeight': [{ type: ViewChild, args: ['containerHeight',] },], }; return PlannerBoardComponent; }()); export { PlannerBoardComponent }; //# sourceMappingURL=planner-board.component.js.map