From 44bf93c54bdc8875b70ab33a5ec94094ac0cf3bf Mon Sep 17 00:00:00 2001 From: leejh Date: Mon, 21 Oct 2019 16:11:33 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=B6=94=EA=B0=80=20::?= =?UTF-8?q?=20=EA=B7=B8=EB=A3=B9=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left-sidenav/group.component.ts | 40 ++++----- .../src/app/store/messenger/sync/actions.ts | 56 ++++++++----- .../src/app/store/messenger/sync/effects.ts | 83 +++++++++++++++++-- .../src/app/store/messenger/sync/reducers.ts | 12 ++- 4 files changed, 139 insertions(+), 52 deletions(-) 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 6e8ca823..7e477bc5 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 @@ -11,7 +11,13 @@ import { map, tap } from 'rxjs/operators'; import { Store, select } from '@ngrx/store'; -import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui'; +import { + ucapAnimations, + DialogService, + ConfirmDialogData, + ConfirmDialogComponent, + ConfirmDialogResult +} from '@ucap-webmessenger/ui'; import { UserInfo, GroupDetailData } from '@ucap-webmessenger/protocol-sync'; import * as AppStore from '@app/store'; @@ -337,31 +343,21 @@ export class GroupComponent implements OnInit, OnDestroy { case 'DELETE': { const result = await this.dialogService.open< - DeleteGroupDialogComponent, - DeleteGroupDialogData, - DeleteGroupDialogResult - >(DeleteGroupDialogComponent, { + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { width: '220px', data: { - title: 'Logout', - message: 'Logout ?' - } - }); - } - break; - case 'EDIT_MEMBER': - { - const result = await this.dialogService.open< - EditGroupMemberDialogComponent, - EditGroupMemberDialogData, - EditGroupMemberDialogResult - >(EditGroupMemberDialogComponent, { - width: '220px', - data: { - title: 'Logout', - message: 'Logout ?' + title: 'Delete group', + html: `그룹(${group.name})을 삭제하시겠습니까?
그룹 멤버는 해당 그룹에서만 삭제됩니다.` } }); + + if (!!result && !!result.choice && result.choice) { + this.logger.debug('delete group', group); + this.store.dispatch(SyncStore.delGroup({ group })); + } } break; default: 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 ece508d3..53a528f2 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 @@ -17,7 +17,9 @@ import { Info } from '@ucap-webmessenger/protocol-event'; import { AddResponse as GroupAddResponse, UpdateRequest as GroupUpdateRequest, - UpdateResponse as GroupUpdateResponse + UpdateResponse as GroupUpdateResponse, + DelRequest as GroupDelRequest, + DelResponse as GroupDelResponse } from '@ucap-webmessenger/protocol-group'; import { AddRequest as BuddyAddRequest, @@ -115,24 +117,6 @@ export const updateUnreadCount = createAction( }>() ); -/** 새그룹(Only Group) 추가 */ -export const createGroup = createAction( - '[Messenger::Sync] Group Create', - props<{ - groupName: string; - }>() -); - -export const createGroupSuccess = createAction( - '[Messenger::Sync] Group Create Success', - props() -); - -export const createGroupFailure = createAction( - '[Messenger::Sync] Group Create Failure', - props<{ error: any }>() -); - /** 새그룹 추가 & 그룹원 추가 */ export const createGroupAndBuddy = createAction( '[Messenger::Sync] Group & Buddy Create', @@ -206,18 +190,46 @@ export const updateBuddyFailure = createAction( props<{ error: any }>() ); -/** 그룹원 업데이트 */ +/** 새그룹 추가 */ +export const createGroup = createAction( + '[Messenger::Sync] Group Create', + props<{ + groupName: string; + }>() +); +export const createGroupSuccess = createAction( + '[Messenger::Sync] Group Create Success', + props() +); +export const createGroupFailure = createAction( + '[Messenger::Sync] Group Create Failure', + props<{ error: any }>() +); +/** 그룹 업데이트 */ export const updateGroup = createAction( '[Messenger::Sync] Group Update', props() ); - export const updateGroupSuccess = createAction( '[Messenger::Sync] Group Update Success', props() ); - export const updateGroupFailure = createAction( '[Messenger::Sync] Group Update Failure', props<{ error: any }>() ); +/** 그룹 삭제 */ +export const delGroup = createAction( + '[Messenger::Sync] Group Del', + props<{ + group: GroupDetailData; + }>() +); +export const delGroupSuccess = createAction( + '[Messenger::Sync] Group Del Success', + props() +); +export const delGroupFailure = createAction( + '[Messenger::Sync] Group Del Failure', + props<{ error: any }>() +); 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 7c9c07bc..42368032 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 @@ -1,3 +1,4 @@ +import { GroupProtocolService } from './../../../../../../ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service'; import { Injectable } from '@angular/core'; import { Actions, ofType, createEffect } from '@ngrx/effects'; @@ -42,7 +43,10 @@ import { updateGroupFailure, updateGroupMember, updateBuddy, - delBuddySuccess + delBuddySuccess, + delGroup, + delGroupFailure, + delGroupSuccess } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -81,9 +85,9 @@ import { } from '@ucap-webmessenger/protocol-room'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { - GroupProtocolService, AddResponse as GroupAddResponse, - UpdateResponse as GroupUpdateResponse + UpdateResponse as GroupUpdateResponse, + DelResponse as GroupDelResponse } from '@ucap-webmessenger/protocol-group'; import { BuddyProtocolService, @@ -462,11 +466,9 @@ export class Effects { }); if (addBuddyList.length > 0) { - this.logger.debug('addBuddyList : ', addBuddyList); this.store.dispatch(addBuddy({ userSeqs: addBuddyList })); } - this.logger.debug('group buddy : ', action.trgtUserSeq); this.store.dispatch( updateGroup({ // 0: 동료그룹SEQ(n) @@ -534,12 +536,10 @@ export class Effects { }); if (addBuddyList.length > 0) { - this.logger.debug('addBuddyList : ', addBuddyList); this.store.dispatch(addBuddy({ userSeqs: addBuddyList })); } if (delBuddyInGroup.length > 0) { - this.logger.debug('delBuddyInGroup', delBuddyInGroup); // 즐겨찾기 해제. delBuddyInGroup.forEach(buddySeq => { this.buddyProtocolService @@ -568,6 +568,75 @@ export class Effects { { dispatch: false } ); + delGroup$ = createEffect( + () => { + return this.actions$.pipe( + ofType(delGroup), + withLatestFrom( + this.store.pipe( + select( + (state: any) => + state.messenger.sync.group2.entities as Dictionary< + GroupDetailData + > + ) + ) + ), + map(([action, groupList]) => { + // Del Buddy + const trgtBuddys = action.group.userSeqs; + // tslint:disable-next-line: no-shadowed-variable + const delBuddyList = trgtBuddys.filter(delBuddy => { + let exist = false; + // tslint:disable-next-line: forin + for (const key in groupList) { + const group: GroupDetailData = groupList[key]; + if ( + group.seq !== action.group.seq && + group.userSeqs.filter(v => v === delBuddy).length > 0 + ) { + exist = true; + break; + } + } + return !exist; + }); + + if (delBuddyList.length > 0) { + this.logger.debug('Del Buddy', delBuddyList); + // 즐겨찾기 해제. + delBuddyList.forEach(buddySeq => { + this.buddyProtocolService + .update({ + seq: buddySeq, + isFavorit: false + }) + .pipe(catchError(error => of(delBuddyFailure({ error })))); + }); + + // 동료 삭제 + this.store.dispatch(delBuddy({ userSeqs: delBuddyList })); + } + + return action.group; + }), + tap(group => { + this.groupProtocolService + .del({ + groupSeq: group.seq + }) + .pipe( + map((res: GroupDelResponse) => { + return delGroupSuccess(res); + }), + catchError(error => of(delGroupFailure({ error }))) + ); + }) + ); + }, + { dispatch: false } + ); + addBuddy$ = createEffect(() => this.actions$.pipe( ofType(addBuddy), diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts index d5704cc5..599c9790 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts @@ -16,7 +16,8 @@ import { updateUnreadCount, createGroupSuccess, addBuddySuccess, - delBuddySuccess + delBuddySuccess, + delGroupSuccess } from './actions'; import { RoomUserDetailData, @@ -204,6 +205,15 @@ export const reducer = createReducer( }) }; }), + /** 새 그룹 삭제 */ + on(delGroupSuccess, (state, action) => { + return { + ...state, + group2: adapterGroup2.removeOne(action.groupSeq, { + ...state.group2 + }) + }; + }), on(delBuddySuccess, (state, action) => { return { From 93ccbb518b0af1a0c6f0607326a135801056a278 Mon Sep 17 00:00:00 2001 From: leejh Date: Mon, 21 Oct 2019 16:32:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=B6=94=EA=B0=80=20::?= =?UTF-8?q?=20=EA=B7=B8=EB=A3=B9=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left-sidenav/group.component.ts | 19 +++++++++++++--- .../group/edit-group.dialog.component.html | 19 +++++++++++++--- .../group/edit-group.dialog.component.ts | 22 +++++++++++++++---- .../components/expansion-panel.component.html | 10 +++++++-- 4 files changed, 58 insertions(+), 12 deletions(-) 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 7e477bc5..8f477c8c 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 @@ -301,12 +301,25 @@ export class GroupComponent implements OnInit, OnDestroy { EditGroupDialogData, EditGroupDialogResult >(EditGroupDialogComponent, { - width: '220px', + width: '600px', + height: '500px', data: { - title: 'Logout', - message: 'Logout ?' + title: 'Group Name Edit', + group } }); + + if (!!result && !!result.choice && result.choice) { + if (!!result.groupName && result.groupName.trim().length > 0) { + this.store.dispatch( + SyncStore.updateGroup({ + groupSeq: result.group.seq, + groupName: result.groupName, + userSeqs: result.group.userSeqs + }) + ); + } + } } break; case 'EDIT_MEMBER': diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/group/edit-group.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/group/edit-group.dialog.component.html index 7e2dcc5e..cd8e6a7f 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/group/edit-group.dialog.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/group/edit-group.dialog.component.html @@ -1,8 +1,21 @@ - - 그룹 이름 수정 + + {{ data.title }} - + +
+ + + {{ input.value?.length || 0 }}/20 + +
+