leejinho 187efa67ab [20 전달 탭 사용자 선택 통일성 없음] 이슈처리.
이벤트 꼬이는 문제 수정 및 대화방 리스트 클릭시 체크박스 토글되도록 수정.
2019-11-27 14:39:43 +09:00

116 lines
2.8 KiB
TypeScript

import {
Component,
OnInit,
Input,
Output,
EventEmitter,
ViewEncapsulation
} from '@angular/core';
import { UserInfo } from '@ucap-webmessenger/protocol-sync';
import {
UserInfoSS,
UserInfoF,
UserInfoDN
} from '@ucap-webmessenger/protocol-query';
import { StatusBulkInfo, StatusInfo } from '@ucap-webmessenger/protocol-status';
import { NGXLogger } from 'ngx-logger';
import { StatusCode } from '@ucap-webmessenger/core';
import { PresenceType } from '../types/presence-type.type';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
@Component({
selector: 'ucap-profile-user-list-item',
templateUrl: './user-list-item.component.html',
styleUrls: ['./user-list-item.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class UserListItemComponent implements OnInit {
@Input()
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
@Input()
profileImageRoot?: string;
@Input()
presence: StatusBulkInfo | StatusInfo;
@Input()
checkable = false;
@Input()
isChecked = false;
@Input()
compactable = false;
@Input()
sessionVerinfo: VersionInfo2Response;
@Input()
/** 선택된 사용자의 리스트 */
selectedUserList?: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[] = [];
@Output()
checkUser = new EventEmitter<{
isChecked: boolean;
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
}>();
@Output()
openProfile = new EventEmitter<
UserInfo | UserInfoSS | UserInfoF | UserInfoDN
>();
PresenceType = PresenceType;
constructor(private logger: NGXLogger) {}
ngOnInit() {
this.profileImageRoot =
this.profileImageRoot || this.sessionVerinfo.profileRoot;
}
getPresence(type: string): string {
let status: string;
let rtnClass = '';
switch (type) {
case 'pc':
status = !!this.presence ? this.presence.pcStatus : undefined;
break;
}
if (!!status) {
switch (status) {
case StatusCode.OnLine:
rtnClass = type + 'On';
break;
case StatusCode.Away:
rtnClass = type + 'Out';
break;
case StatusCode.Busy:
rtnClass = type + 'Other';
break;
default:
rtnClass = type + 'Off';
break;
}
}
return rtnClass;
}
/** 리스트가 checkable 할 경우 checkbox 의 change 이벤트를 상위 컴포넌트로 전달한다. */
onChangeCheck(
value: boolean,
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
) {
this.checkUser.emit({
isChecked: value,
userInfo
});
}
onClickOpenProfile(
event: MouseEvent,
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN
) {
event.preventDefault();
event.stopPropagation();
this.openProfile.emit(userInfo);
}
}