Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(tree list): Set quick add context on page refresh. Also reset qui…
Browse files Browse the repository at this point in the history
…ck add context when work item has been de-selected.
  • Loading branch information
nimishamukherjee committed Oct 20, 2017
1 parent a3194c4 commit 7c58d4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/app/components/planner-list/planner-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,14 @@ export class PlannerListComponent implements OnInit, AfterViewInit, DoCheck, OnD

loadWorkItems(): void {
this.initialGroup = this.groupTypesService.getCurrentGroupType();
//if initialGroup is undefined, the page has been refreshed - find group context based on URL
if(this.initialGroup === undefined) {
let wits = this.route.snapshot.queryParams['q'].split('workitemtype:')
let collection = wits[1].replace(')','').split(',');
this.groupTypesService.findGroupConext(collection);
this.initialGroup = this.groupTypesService.getCurrentGroupType();
}

this.uiLockedList = true;
if (this.wiSubscriber) {
this.wiSubscriber.unsubscribe();
Expand Down Expand Up @@ -874,12 +882,13 @@ export class PlannerListComponent implements OnInit, AfterViewInit, DoCheck, OnD
handleSelectionChange($event): void {
if($event.item.selected === true) {
this.selectedWI = $event.item;
if(this.expandedNode != null && ($event.item.data.id !== this.expandedNode.node.item.id)) {
if(this.expandedNode != null && ($event.item.id !== this.expandedNode.node.item.id)) {
this.expandedNode = null;
}
} else {
this.selectedWI = null;
//reset the quick add context to allowed WIT for the selected group
console.log('<><><>', this.initialGroup);
this.groupTypesService.setCurrentGroupType(this.initialGroup);
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/app/services/group-types.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class GroupTypesService {
public groupTypes: GroupTypesModel[] = [];
private headers = new Headers({'Content-Type': 'application/json'});
private _currentSpace;
private selectedGroupType: GroupTypesModel;
private selectedGroupType: any;
public groupTypeSelected: Subject<string[]> = new Subject();
public workItemSelected: Subject<string[]> = new Subject();
public groupName: string = '';
Expand Down Expand Up @@ -113,6 +113,20 @@ export class GroupTypesService {
}
}

findGroupConext(collection) {
//check collection against wit_collection
let matchingGroup = this.groupTypes.find((gt, index) => {
if(gt.group === 'portfolio' && gt.level[1] === 0) {
//concat both portfolio
let arr = gt.wit_collection.concat(this.groupTypes[index + 1].wit_collection)
return arr.sort().toString() === collection.sort().toString();
} else {
return gt.wit_collection.sort().toString() === collection.sort().toString();
}
});
this.selectedGroupType = matchingGroup.wit_collection;
}

mockData(): Array<GroupTypesModel> {
//Map the json blob to what the UI needs
this.groupTypeResponse = {
Expand Down

0 comments on commit 7c58d4f

Please sign in to comment.