tree 에 loginRes 객체 주입 > 내 부서 열어주기 위한 전처리.

This commit is contained in:
leejh 2019-10-31 11:58:39 +09:00
parent fa214fc01d
commit 9d0f6bdd8a
3 changed files with 28 additions and 2 deletions

View File

@ -5,6 +5,7 @@
<div class="oraganization-tab-tree" >
<ucap-organization-tree
[oraganizationList]="departmentInfoList$ | async"
[loginRes]="loginRes"
(selected)="onSelectedOrganization($event)"
></ucap-organization-tree>
</div>

View File

@ -35,6 +35,7 @@ import {
SelectGroupDialogData,
SelectGroupDialogResult
} from '../../dialogs/group/select-group.dialog.component';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
@Component({
selector: 'app-layout-chat-left-sidenav-organization',
@ -71,6 +72,7 @@ export class OrganizationComponent implements OnInit, OnDestroy {
selectedDepartmentName: string;
loginInfo: LoginInfo;
loginRes: LoginResponse;
sessionVerinfo: VersionInfo2Response;
constructor(
@ -137,6 +139,7 @@ export class OrganizationComponent implements OnInit, OnDestroy {
return loginRes;
}),
map(loginRes => {
this.loginRes = loginRes;
this.selectedDepartmentName = loginRes.userInfo.deptName;
})
)

View File

@ -8,12 +8,14 @@ import {
EventEmitter,
AfterViewInit
} from '@angular/core';
import { DeptInfo } from '@ucap-webmessenger/protocol-query';
import { MatTreeNestedDataSource, MatTree } from '@angular/material';
import { NestedTreeControl } from '@angular/cdk/tree';
import { BehaviorSubject } from 'rxjs';
import { NGXLogger } from 'ngx-logger';
import { DeptInfo } from '@ucap-webmessenger/protocol-query';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
export class OraganizationNode {
private childNodeBehaviorSubject: BehaviorSubject<OraganizationNode[]>;
private childNodeList: OraganizationNode[];
@ -50,11 +52,14 @@ export class TreeComponent implements OnInit, AfterViewInit {
@Output()
selected = new EventEmitter<DeptInfo>();
@Input()
loginRes: LoginResponse;
@Input()
set oraganizationList(deptInfo: DeptInfo[]) {
const nodeMap = new Map<number, OraganizationNode>();
const rootNodeList: OraganizationNode[] = [];
const remainChildNodeList: OraganizationNode[] = [];
let myNode: OraganizationNode;
deptInfo.forEach(value => {
const node = new OraganizationNode(value);
@ -64,6 +69,10 @@ export class TreeComponent implements OnInit, AfterViewInit {
}
nodeMap.set(value.seq, node);
if (value.seq === this.loginRes.departmentCode) {
myNode = node;
}
if (0 === value.parentSeq) {
rootNodeList.push(node);
return;
@ -83,7 +92,20 @@ export class TreeComponent implements OnInit, AfterViewInit {
});
this.dataSource.data = rootNodeList;
this.treeControl.expand(this.dataSource.data[0]);
// console.log('myNode', myNode);
// console.log('this.dataSource.data', this.dataSource.data[0]);
// this.treeControl.expandDescendants(this.dataSource.data[2]);
// console.log('this.dataSource', this.dataSource);
// console.log('this.dataSource.data', this.dataSource.data);
// console.log('this.treeControl', this.treeControl);
// console.log('this.treeControl.dataNodes', this.treeControl.dataNodes);
// const myNode = this.treeControl.dataNodes.filter(
// node => node.deptInfo.seq === this.loginRes.departmentCode
// );
// if (!!myNode && myNode.length > 0) {
// this.treeControl.expand(myNode[0]);
// }
}
@ViewChild('orgranizationTree', { static: true })