diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts index 68786c44..9388544b 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts @@ -60,11 +60,10 @@ export class GroupComponent implements OnInit, OnDestroy { @ViewChild('profileContextMenuTrigger', { static: true }) profileContextMenuTrigger: MatMenuTrigger; + profileContextMenuPosition = { x: '0px', y: '0px' }; @ViewChild('groupContextMenuTrigger', { static: true }) groupContextMenuTrigger: MatMenuTrigger; - - profileContextMenuPosition = { x: '0px', y: '0px' }; groupContextMenuPosition = { x: '0px', y: '0px' }; groupBuddyList$: Observable< diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index 4dab8b5c..0329993b 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -5,20 +5,37 @@
-
- - @@ -31,7 +48,10 @@
- +
@@ -39,9 +59,16 @@ - +
@@ -56,3 +83,49 @@
+ +
+ + + + + + + + + + + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index 68fd6ebe..76d8591e 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -10,7 +10,13 @@ import { ucapAnimations } from '@ucap-webmessenger/ui'; import { Store, select } from '@ngrx/store'; import { NGXLogger } from 'ngx-logger'; import { Observable, Subscription } from 'rxjs'; -import { Info, EventType } from '@ucap-webmessenger/protocol-event'; +import { + Info, + EventType, + isRecalled, + isCopyable, + isRecallable +} from '@ucap-webmessenger/protocol-event'; import * as AppStore from '@app/store'; import * as EventStore from '@app/store/messenger/event'; @@ -24,6 +30,7 @@ import { tap } from 'rxjs/operators'; import { FileInfo } from '@ucap-webmessenger/ui-chat'; import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; +import { MatMenuTrigger } from '@angular/material'; @Component({ selector: 'app-layout-messenger-messages', @@ -35,6 +42,10 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { @ViewChild('messageBoxContainer', { static: true }) private messageBoxContainer: ElementRef; + @ViewChild('messageContextMenuTrigger', { static: true }) + messageContextMenuTrigger: MatMenuTrigger; + messageContextMenuPosition = { x: '0px', y: '0px' }; + loginRes: LoginResponse; loginResSubscription: Subscription; eventList$: Observable; @@ -46,6 +57,10 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { KEY_VER_INFO ); + isRecalledMessage = isRecalled; + isCopyableMessage = isCopyable; + isRecallableMessage = isRecallable; + constructor( private store: Store, private sessionStorageService: SessionStorageService, @@ -143,4 +158,46 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked { onSave(value: { fileInfo: FileInfo; type: string }) { this.logger.debug('fileSave', value); } + + onContextMenuMessage(params: { event: MouseEvent; message: Info }) { + params.event.preventDefault(); + params.event.stopPropagation(); + + this.messageContextMenuPosition.x = params.event.clientX + 'px'; + this.messageContextMenuPosition.y = params.event.clientY + 'px'; + this.messageContextMenuTrigger.menu.focusFirstItem('mouse'); + this.messageContextMenuTrigger.menuData = { + message: params.message, + loginRes: this.loginRes + }; + this.messageContextMenuTrigger.openMenu(); + } + + onClickMessageContextMenu(menuType: string, message: Info) { + switch (menuType) { + case 'COPY': + { + this.logger.debug('onClickMessageContextMenu', menuType, message); + } + break; + case 'REPLAY': + { + } + break; + case 'REPLAY_TO_ME': + { + } + break; + case 'DELETE': + { + } + break; + case 'RECALL': + { + } + break; + default: + break; + } + } } diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts index fa28fc20..6f1b9ca9 100644 --- a/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/info.ts @@ -14,3 +14,19 @@ export interface Info { // 수신자수 receiverCount: number; } + +export function isCopyable(eventType: EventType): boolean { + return ( + EventType.Character === eventType || EventType.Translation === eventType + ); +} + +export function isRecalled(eventType: EventType): boolean { + return EventType.RecalledMessage === eventType; +} + +export function isRecallable(event: Info, userSeq: number): boolean { + return ( + event.senderSeq === userSeq && event.type !== EventType.RecalledMessage + ); +} diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html index 80bec251..522791c0 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html @@ -92,9 +92,7 @@
@@ -120,23 +118,3 @@
- -
- - - - - - - - - - - diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index e43b886f..7587dc46 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -43,10 +43,11 @@ export class MessagesComponent implements OnInit { @Output() save = new EventEmitter<{ fileInfo: FileInfo; type: string }>(); - @ViewChildren(MatMenuTrigger) menuTriggerList: QueryList; - @ViewChild('messageContextMenu', { static: true }) - messageContextMenu: MatMenu; - messageContextMenuPosition = { x: '0px', y: '0px' }; + @Output() + contextMenu = new EventEmitter<{ + event: MouseEvent; + message: Info; + }>(); EventType = EventType; profileImageRoot: string; @@ -126,23 +127,6 @@ export class MessagesComponent implements OnInit { return false; } - isCopyableMessage(eventType: EventType): boolean { - return ( - EventType.Character === eventType || EventType.Translation === eventType - ); - } - - isRecalledMessage(eventType: EventType): boolean { - return EventType.RecalledMessage === eventType; - } - - isRecallable(message: Info): boolean { - return ( - message.senderSeq === this.loginRes.userSeq && - message.type !== EventType.RecalledMessage - ); - } - /** [Event] MassTalk Detail View */ onMassDetail(value: number) { this.massDetail.emit(value); @@ -158,15 +142,7 @@ export class MessagesComponent implements OnInit { this.save.emit(value); } - onContextMenuMessage(event: MouseEvent, eventType: EventType, message: Info) { - event.preventDefault(); - - this.messageContextMenu.focusFirstItem('mouse'); - - this.messageContextMenuPosition.x = event.clientX + 'px'; - this.messageContextMenuPosition.y = event.clientY + 'px'; - const messageContextMenuTrigger = this.menuTriggerList.toArray()[0]; - messageContextMenuTrigger.menuData = { eventType, message }; - messageContextMenuTrigger.openMenu(); + onContextMenuMessage(event: MouseEvent, message: Info) { + this.contextMenu.emit({ event, message }); } }