조직도에서 부서원 선택시 해당 부서원의 부서를 트리에 표현해 주는 로직 추가.

This commit is contained in:
leejinho 2020-03-09 13:27:15 +09:00
parent a6f1386c98
commit 906bbdcf2c
14 changed files with 106 additions and 8 deletions

View File

@ -28,6 +28,7 @@
" "
> >
<app-layout-chat-left-sidenav-organization-tree <app-layout-chat-left-sidenav-organization-tree
[gotoDeptTree]="gotoDeptTree"
class="organization-side" class="organization-side"
></app-layout-chat-left-sidenav-organization-tree> ></app-layout-chat-left-sidenav-organization-tree>
<!-- <app-layout-chat-left-sidenav-organization <!-- <app-layout-chat-left-sidenav-organization

View File

@ -8,7 +8,8 @@ import {
QueryList, QueryList,
ElementRef, ElementRef,
OnDestroy, OnDestroy,
ViewChild ViewChild,
Input
} from '@angular/core'; } from '@angular/core';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui'; import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
@ -58,6 +59,9 @@ import { TranslateService } from '@ngx-translate/core';
animations: ucapAnimations animations: ucapAnimations
}) })
export class LeftSideComponent implements OnInit, OnDestroy { export class LeftSideComponent implements OnInit, OnDestroy {
@Input()
gotoDeptTree: number;
@Output() @Output()
openProfile = new EventEmitter<{ openProfile = new EventEmitter<{
userSeq: number; userSeq: number;

View File

@ -15,6 +15,7 @@
<ucap-organization-tree <ucap-organization-tree
[oraganizationList]="departmentInfoList$ | async" [oraganizationList]="departmentInfoList$ | async"
[loginRes]="loginRes" [loginRes]="loginRes"
[gotoDept]="gotoDeptTree"
[activate$]="organizationTreeActivatedSubject.asObservable()" [activate$]="organizationTreeActivatedSubject.asObservable()"
(selected)="onSelectedOrganization($event)" (selected)="onSelectedOrganization($event)"
class="tab-tree-frame" class="tab-tree-frame"

View File

@ -1,4 +1,10 @@
import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core'; import {
Component,
OnInit,
OnDestroy,
ChangeDetectorRef,
Input
} from '@angular/core';
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui'; import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
import { Observable, Subscription, BehaviorSubject, combineLatest } from 'rxjs'; import { Observable, Subscription, BehaviorSubject, combineLatest } from 'rxjs';
import { import {
@ -29,6 +35,9 @@ import { OrganizationService } from '@ucap-webmessenger/ui-organization';
animations: ucapAnimations animations: ucapAnimations
}) })
export class OrganizationTreeComponent implements OnInit, OnDestroy { export class OrganizationTreeComponent implements OnInit, OnDestroy {
@Input()
gotoDeptTree: number;
companyList$: Observable<Company[]>; companyList$: Observable<Company[]>;
companyCode: string; companyCode: string;

View File

@ -16,6 +16,7 @@
<app-layout-messenger-organization <app-layout-messenger-organization
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(createConference)="onClickConferenceCreate($event)" (createConference)="onClickConferenceCreate($event)"
(gotoDeptTree)="onClickGotoDeptTree($event)"
[style.display]=" [style.display]="
MainMenu.Organization === (this.gnbMenuIndex$ | async) ? 'block' : 'none' MainMenu.Organization === (this.gnbMenuIndex$ | async) ? 'block' : 'none'
" "

View File

@ -20,6 +20,8 @@ export class MainContentsComponent implements OnInit {
openProfile = new EventEmitter<{ openProfile = new EventEmitter<{
userSeq: number; userSeq: number;
}>(); }>();
@Output()
gotoDeptTree = new EventEmitter<number>();
@Output() @Output()
closeRightDrawer = new EventEmitter(); closeRightDrawer = new EventEmitter();
@ -47,6 +49,10 @@ export class MainContentsComponent implements OnInit {
this.openProfile.emit({ userSeq }); this.openProfile.emit({ userSeq });
} }
onClickGotoDeptTree(deptSeq: number) {
this.gotoDeptTree.emit(deptSeq);
}
onCloseRightDrawer() { onCloseRightDrawer() {
this.closeRightDrawer.emit(); this.closeRightDrawer.emit();
} }

View File

@ -161,6 +161,7 @@
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(toggleAllUser)="onToggleAllUser($event)" (toggleAllUser)="onToggleAllUser($event)"
(toggleUser)="onToggleUser($event)" (toggleUser)="onToggleUser($event)"
(gotoDeptTree)="onClickGotoDeptTree($event)"
class="detail-table" class="detail-table"
></ucap-organization-detail-table> ></ucap-organization-detail-table>
</div> </div>

View File

@ -50,6 +50,10 @@ import { MatOption } from '@angular/material/core';
export class OrganizationComponent implements OnInit, OnDestroy { export class OrganizationComponent implements OnInit, OnDestroy {
@Output() @Output()
openProfile = new EventEmitter<number>(); openProfile = new EventEmitter<number>();
@Output()
gotoDeptTree = new EventEmitter<number>();
@Output() @Output()
createConference = new EventEmitter<number[]>(); createConference = new EventEmitter<number[]>();
@ -323,6 +327,9 @@ export class OrganizationComponent implements OnInit, OnDestroy {
onClickOpenProfile(userSeq: number) { onClickOpenProfile(userSeq: number) {
this.openProfile.emit(userSeq); this.openProfile.emit(userSeq);
} }
onClickGotoDeptTree(deptSeq: number) {
this.gotoDeptTree.emit(deptSeq);
}
/** Handling Filters */ /** Handling Filters */
setFilterOptions(list: UserInfoSS[]) { setFilterOptions(list: UserInfoSS[]) {

View File

@ -7,6 +7,7 @@
<mat-drawer #leftSideDrawer mode="side" [disableClose]="true" opened> <mat-drawer #leftSideDrawer mode="side" [disableClose]="true" opened>
<app-layout-messenger-left-side <app-layout-messenger-left-side
#leftSideContainer #leftSideContainer
[gotoDeptTree]="gotoDeptTree"
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(sendCall)="sendClickToCall($event)" (sendCall)="sendClickToCall($event)"
(sendSms)="openSms($event)" (sendSms)="openSms($event)"
@ -28,6 +29,7 @@
<app-layout-messenger-main-contents <app-layout-messenger-main-contents
[selectedChat]="this.selectedChat$ | async" [selectedChat]="this.selectedChat$ | async"
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(gotoDeptTree)="onClickGotoDeptTree($event)"
(closeRightDrawer)="onCloseRightDrawer()" (closeRightDrawer)="onCloseRightDrawer()"
(createConference)="conferenceCreate($event)" (createConference)="conferenceCreate($event)"
> >

View File

@ -85,6 +85,8 @@ export class MainPageComponent implements OnInit, OnDestroy {
loginResSubscription: Subscription; loginResSubscription: Subscription;
environmentsInfo: EnvironmentsInfo; environmentsInfo: EnvironmentsInfo;
gotoDeptTree: number;
showLeftDrawer = true; showLeftDrawer = true;
showLeftDrawerIndicator = false; showLeftDrawerIndicator = false;
onLeftDrawerIndicator = false; onLeftDrawerIndicator = false;
@ -466,6 +468,10 @@ export class MainPageComponent implements OnInit, OnDestroy {
} }
} }
onClickGotoDeptTree(deptSeq: number) {
this.gotoDeptTree = deptSeq;
}
onCloseRightDrawer() { onCloseRightDrawer() {
this.rightDrawer.close(); this.rightDrawer.close();
} }

View File

@ -50,7 +50,12 @@
{{ 'search.fieldDeptartment' | translate }} {{ 'search.fieldDeptartment' | translate }}
</div> </div>
</th> </th>
<td mat-cell *matCellDef="let element" class="profileInfo"> <td
mat-cell
*matCellDef="let element"
class="profileInfo"
(click)="onClickGotoDeptTree($event, element.deptSeq)"
>
<div class="baseInfo"> <div class="baseInfo">
<span <span
*ngIf="getWorkstatusInfo(element, 'style').length > 0" *ngIf="getWorkstatusInfo(element, 'style').length > 0"

View File

@ -41,6 +41,8 @@ export class DetailTableComponent implements OnInit, OnDestroy {
@Output() @Output()
openProfile = new EventEmitter<number>(); openProfile = new EventEmitter<number>();
@Output() @Output()
gotoDeptTree = new EventEmitter<number>();
@Output()
toggleAllUser = new EventEmitter<{ toggleAllUser = new EventEmitter<{
isChecked: boolean; isChecked: boolean;
userInfos: UserInfoSS[]; userInfos: UserInfoSS[];
@ -280,4 +282,9 @@ export class DetailTableComponent implements OnInit, OnDestroy {
event.stopPropagation(); event.stopPropagation();
this.openProfile.emit(userSeq); this.openProfile.emit(userSeq);
} }
onClickGotoDeptTree(event: MouseEvent, deptSeq: number) {
event.preventDefault();
event.stopPropagation();
this.gotoDeptTree.emit(Number(deptSeq));
}
} }

View File

@ -39,7 +39,11 @@
></div> ></div>
</div> </div>
<li (click)="onClickNode(node)" matRipple> <li
(click)="onClickNode(node)"
matRipple
[ngClass]="currentDeptSeq === node.deptInfo.seq ? 'current' : ''"
>
<div class="tree-node-body"> <div class="tree-node-body">
{{ node.deptInfo | ucapTranslate: 'name' }} {{ node.deptInfo | ucapTranslate: 'name' }}
</div> </div>
@ -71,7 +75,10 @@
></div> ></div>
</div> </div>
<li (click)="onClickNode(node)" matRipple> <li (click)="onClickNode(node)" matRipple>
<div class="tree-node-body"> <div
class="tree-node-body"
[ngClass]="currentDeptSeq === node.deptInfo.seq ? 'current' : ''"
>
<span class="horizontal-line"></span> <span class="horizontal-line"></span>
<button <button
mat-icon-button mat-icon-button

View File

@ -95,6 +95,8 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
} }
}); });
this.deptInfoList = deptInfoList;
remainChildNodeList.forEach(node => { remainChildNodeList.forEach(node => {
if (nodeMap.has(node.deptInfo.parentSeq)) { if (nodeMap.has(node.deptInfo.parentSeq)) {
nodeMap.get(node.deptInfo.parentSeq).children.push(node); nodeMap.get(node.deptInfo.parentSeq).children.push(node);
@ -104,7 +106,7 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
// 내부서 트리 오픈 // 내부서 트리 오픈
if (!this.myDeptRoot) { if (!this.myDeptRoot) {
this.myDeptRoot = this.getMyRoot( this.myDeptRoot = this.getDeptRoot(
deptInfoList, deptInfoList,
this.loginRes.departmentCode, this.loginRes.departmentCode,
[] []
@ -112,6 +114,8 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
} }
if (!!this.myDeptRoot) { if (!!this.myDeptRoot) {
this.currentDeptSeq = this.loginRes.departmentCode;
this.myDeptRoot.reverse().forEach(seq => { this.myDeptRoot.reverse().forEach(seq => {
this.treeControl.dataNodes.some(dn => { this.treeControl.dataNodes.some(dn => {
if (dn.deptInfo.seq === seq) { if (dn.deptInfo.seq === seq) {
@ -123,6 +127,40 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
} }
} }
@Input()
set gotoDept(deptSeq: number) {
if (!deptSeq || !this.deptInfoList || this.deptInfoList.length === 0) {
return;
}
const deptRoot = this.getDeptRoot(this.deptInfoList, deptSeq, []);
if (!!deptRoot) {
this.treeControl.collapseAll();
this.currentDeptSeq = deptSeq;
deptRoot.reverse().forEach(seq => {
this.treeControl.dataNodes.some(dn => {
if (dn.deptInfo.seq === seq) {
this.treeControl.expand(dn);
return;
}
});
});
// scroll index
if (!!this.cvsvOrganization) {
const curIndex = this.dataSource.expandedDataSubject.value.findIndex(
node => node.deptInfo.seq === this.currentDeptSeq
);
if (curIndex > -1) {
this.cvsvOrganization.scrollToIndex(curIndex);
this.psDirectiveRef.update();
}
}
}
}
@Input() @Input()
activate$: Observable<boolean>; activate$: Observable<boolean>;
@ -138,6 +176,8 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild(PerfectScrollbarDirective, { static: false }) @ViewChild(PerfectScrollbarDirective, { static: false })
psDirectiveRef?: PerfectScrollbarDirective; psDirectiveRef?: PerfectScrollbarDirective;
currentDeptSeq: number;
deptInfoList: DeptInfo[];
myDeptRoot: number[]; myDeptRoot: number[];
treeControl: FlatTreeControl<FlatNode>; treeControl: FlatTreeControl<FlatNode>;
treeFlattener: MatTreeFlattener<OrganizationNode, FlatNode>; treeFlattener: MatTreeFlattener<OrganizationNode, FlatNode>;
@ -249,6 +289,7 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
} }
onClickNode(node: OrganizationNode) { onClickNode(node: OrganizationNode) {
this.currentDeptSeq = node.deptInfo.seq;
this.selected.emit(node.deptInfo); this.selected.emit(node.deptInfo);
} }
@ -278,7 +319,7 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
return undefined; return undefined;
} }
private getMyRoot( private getDeptRoot(
deptInfoList: DeptInfo[], deptInfoList: DeptInfo[],
srcDeptSeq: number, srcDeptSeq: number,
data: number[] data: number[]
@ -291,7 +332,7 @@ export class TreeComponent implements OnInit, OnDestroy, AfterViewInit {
if (info.type === DeptType.Root) { if (info.type === DeptType.Root) {
return data; return data;
} else { } else {
return this.getMyRoot(deptInfoList, info.parentSeq, data); return this.getDeptRoot(deptInfoList, info.parentSeq, data);
} }
} else { } else {
return data; return data;