From b3c649c393a316153a449e1de84b4a5d49c55fb7 Mon Sep 17 00:00:00 2001 From: leejinho Date: Thu, 21 Nov 2019 11:46:49 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20>=20=EB=8F=99=EB=A3=8C?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20context=20menu=20>=20=EC=9D=B4=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=EC=97=90=EC=84=9C=20=EC=82=AD=EC=A0=9C,=20?= =?UTF-8?q?=EB=8C=80=ED=99=94=20=EC=83=81=EB=8C=80,=20=EB=8C=80=ED=99=94?= =?UTF-8?q?=20=EC=83=81=EB=8C=80=20=EC=9D=B4=EB=8F=99=20::=20=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left-sidenav/group.component.html | 26 ++-- .../left-sidenav/group.component.ts | 134 +++++++++++++++++- .../src/app/store/messenger/sync/actions.ts | 17 +++ .../src/app/store/messenger/sync/effects.ts | 66 ++++++++- .../components/expansion-panel.component.html | 6 +- .../components/expansion-panel.component.ts | 1 + 6 files changed, 227 insertions(+), 23 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html index 2233b690..0a350246 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html @@ -33,13 +33,13 @@ (more)="onMoreGroup($event)" > @@ -121,7 +121,7 @@ [hasBackdrop]="false" (ucapClickOutside)="profileContextMenuTrigger.closeMenu()" > - + - + --> 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 47994c83..50f3b366 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 @@ -56,6 +56,11 @@ import { EditGroupDialogData, EditGroupDialogResult } from '@app/layouts/messenger/dialogs/group/edit-group.dialog.component'; +import { + SelectGroupDialogComponent, + SelectGroupDialogResult, + SelectGroupDialogData +} from '../../dialogs/group/select-group.dialog.component'; @Component({ selector: 'app-layout-chat-left-sidenav-group', @@ -281,20 +286,42 @@ export class GroupComponent implements OnInit, OnDestroy { this.searchUserInfos = []; } - getShowContextMenu(userInfo: UserInfo | UserInfoF) { + getShowContextMenu( + menuType: string, + userInfo: UserInfo | UserInfoF, + group?: GroupDetailData + ) { if (userInfo.seq === this.loginRes.userSeq) { return false; - } else { - return true; } + + if (!group || group === undefined) { + if ( + menuType === 'REGISTER_FAVORITE' || + menuType === 'SEND_NOTE' || + menuType === 'REGISTER_NICKNAME' + ) { + // continue; + } else { + return false; + } + } + + return true; } - onClickProfileContextMenu(menuType: string, userInfo: UserInfo | UserInfoF) { + async onClickProfileContextMenu( + menuType: string, + userInfo: UserInfo | UserInfoF, + group?: GroupDetailData + ) { this.logger.debug( 'onClickProfileContextMenu', 'menuType', menuType, 'userInfo', - userInfo + userInfo, + 'group', + group ); switch (menuType) { case 'VIEW_PROFILE': @@ -303,6 +330,98 @@ export class GroupComponent implements OnInit, OnDestroy { case 'CHAT': this.onSelectBuddy(userInfo); break; + case 'REMOVE_FROM_GROUP': + { + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + width: '360px', + data: { + title: 'Delete Member in Group', + html: `[${userInfo.name} ${userInfo.grade}]를 [${group.name}]그룹에서 삭제하시겠습니까?` + } + }); + + if (!!result && !!result.choice && result.choice) { + const trgtUserSeq = group.userSeqs.filter( + user => user !== userInfo.seq + ); + this.store.dispatch( + SyncStore.updateGroupMember({ + oldGroup: group, + trgtUserSeq + }) + ); + } + } + break; + case 'COPY_BUDDY': + { + const result = await this.dialogService.open< + SelectGroupDialogComponent, + SelectGroupDialogData, + SelectGroupDialogResult + >(SelectGroupDialogComponent, { + width: '600px', + data: { + title: 'Group Select' + } + }); + + if (!!result && !!result.choice && result.choice) { + if (!!result.group) { + const oldGroup: GroupDetailData = result.group; + const trgtUserSeq: number[] = []; + let exist = false; + result.group.userSeqs.map(seq => { + trgtUserSeq.push(seq); + if (seq === userInfo.seq) { + exist = true; + } + }); + + if (!exist) { + trgtUserSeq.push(userInfo.seq); + } + + this.store.dispatch( + SyncStore.updateGroupMember({ + oldGroup, + trgtUserSeq + }) + ); + } + } + } + break; + case 'MOVE_BUDDY': + { + const result = await this.dialogService.open< + SelectGroupDialogComponent, + SelectGroupDialogData, + SelectGroupDialogResult + >(SelectGroupDialogComponent, { + width: '600px', + data: { + title: 'Group Select' + } + }); + + if (!!result && !!result.choice && result.choice) { + if (!!result.group) { + this.store.dispatch( + SyncStore.moveGroupMember({ + fromGroup: group, + toGroup: result.group, + trgtUserSeq: [userInfo.seq] + }) + ); + } + } + } + break; case 'REGISTER_FAVORITE': this.store.dispatch( SyncStore.updateBuddy({ @@ -320,7 +439,8 @@ export class GroupComponent implements OnInit, OnDestroy { onContextMenuProfile( event: MouseEvent, - userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN + userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN, + group: GroupDetailData ) { event.preventDefault(); event.stopPropagation(); @@ -328,7 +448,7 @@ export class GroupComponent implements OnInit, OnDestroy { this.profileContextMenuPosition.x = event.clientX + 'px'; this.profileContextMenuPosition.y = event.clientY + 'px'; this.profileContextMenuTrigger.menu.focusFirstItem('mouse'); - this.profileContextMenuTrigger.menuData = { userInfo }; + this.profileContextMenuTrigger.menuData = { userInfo, group }; this.profileContextMenuTrigger.openMenu(); } diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts index 31d326b9..340d503c 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts @@ -149,6 +149,23 @@ export const updateGroupMemberFailure = createAction( '[Messenger::Sync] Update Group Member Failure', props<{ error: any }>() ); +/** 그룹원 이동 */ +export const moveGroupMember = createAction( + '[Messenger::Sync] Move Group Member', + props<{ + fromGroup: GroupDetailData; + toGroup: GroupDetailData; + trgtUserSeq: number[]; + }>() +); +export const moveGroupToFailure = createAction( + '[Messenger::Sync] Move Group Member / To', + props<{ error: any }>() +); +export const moveGroupFromFailure = createAction( + '[Messenger::Sync] Move Group Member / From', + props<{ error: any }>() +); /** 동료 추가 */ export const addBuddy = createAction( diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts index a279bc19..2edcc0df 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts @@ -48,7 +48,10 @@ import { delGroup, delGroupFailure, delGroupSuccess, - delBuddyAndClear + delBuddyAndClear, + moveGroupMember, + moveGroupFromFailure, + moveGroupToFailure } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -623,6 +626,67 @@ export class Effects { { dispatch: false } ); + moveGroupMember$ = createEffect(() => + this.actions$.pipe( + ofType(moveGroupMember), + withLatestFrom( + this.store.pipe( + select( + (state: any) => + state.messenger.sync.group2.entities as Dictionary< + GroupDetailData + > + ) + ), + this.store.pipe( + select((state: any) => state.messenger.sync.group2.syncDate as string) + ) + ), + exhaustMap(([action, groupList, syncDate]) => { + // copy to + let toTrgtUserSeqs = groupList[action.toGroup.seq].userSeqs; + action.trgtUserSeq.forEach(trgtSeq => { + if (toTrgtUserSeqs.indexOf(trgtSeq) > -1) { + // ignore + } else { + toTrgtUserSeqs = toTrgtUserSeqs.concat(trgtSeq); + } + }); + + return this.groupProtocolService + .update2({ + groupSeq: action.toGroup.seq, + groupName: action.toGroup.name, + userSeqs: toTrgtUserSeqs + }) + .pipe( + exhaustMap((resTo: GroupUpdateResponse) => { + // del from + const fromTrgtUserSeqs = groupList[action.fromGroup.seq].userSeqs; + + return this.groupProtocolService + .update2({ + groupSeq: action.fromGroup.seq, + groupName: action.fromGroup.name, + userSeqs: fromTrgtUserSeqs.filter( + trgtSeq => action.trgtUserSeq.indexOf(trgtSeq) < 0 + ) + }) + .pipe( + map((resFrom: GroupUpdateResponse) => { + return group2({ + syncDate + }); + }), + catchError(error => of(moveGroupFromFailure({ error }))) + ); + }), + catchError(error => of(moveGroupToFailure({ error }))) + ); + }) + ) + ); + delGroup$ = createEffect(() => this.actions$.pipe( ofType(delGroup), diff --git a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html index 17441145..dc832a61 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html +++ b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.html @@ -19,10 +19,12 @@
-
diff --git a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts index ad5f1b2b..4d2382c6 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts +++ b/projects/ucap-webmessenger-ui-group/src/lib/components/expansion-panel.component.ts @@ -119,6 +119,7 @@ export class ExpansionPanelComponent item.buddyList.forEach(userInfo => { groupNode.children.push({ nodeType: NodeType.Buddy, + groupDetail: item.group, userInfo }); });