From 1fb8b4864fe5952ccf023177e6518f6b91834c85 Mon Sep 17 00:00:00 2001
From: richard-loafle <44828666+richard-loafle@users.noreply.github.com>
Date: Fri, 7 Feb 2020 17:48:52 +0900
Subject: [PATCH] [ISSUE 225] fixed
---
.../chat/create-chat.dialog.component.html | 40 +++++++++++--------
.../chat/create-chat.dialog.component.ts | 34 +++++++++++++++-
.../src/assets/i18n/en.json | 3 +-
.../src/assets/i18n/ko.json | 3 +-
4 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html
index 612457ef..1fbdeae7 100644
--- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html
+++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.html
@@ -37,6 +37,11 @@
| translate: { bannedWords: bannedWords.join(',') }
}}
+
+ {{ 'group.errors.sameNameExist' | translate }}
+
@@ -99,6 +104,7 @@
[selectedUserList]="selectedUserList"
[ignoreUserList]="data.curRoomUser"
[checkable]="true"
+ [activate$]="groupTreeActivatedSubject.asObservable()"
(checkGroup)="onCheckGroup($event)"
class="group-expansion"
>
@@ -194,23 +200,23 @@
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts
index e2d6a751..1c74473f 100644
--- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts
+++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/chat/create-chat.dialog.component.ts
@@ -19,7 +19,13 @@ import {
MatTabChangeEvent
} from '@angular/material';
import { NGXLogger } from 'ngx-logger';
-import { Observable, combineLatest, Subscription, of } from 'rxjs';
+import {
+ Observable,
+ combineLatest,
+ Subscription,
+ of,
+ BehaviorSubject
+} from 'rxjs';
import { map, tap, catchError, take } from 'rxjs/operators';
import { Store, select } from '@ngrx/store';
@@ -170,6 +176,7 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
{ group: GroupDetailData; buddyList: UserInfo[] }[]
>;
favoritBuddyList$: Observable;
+ groupList: GroupDetailData[];
// 대화방
roomList: RoomInfo[];
@@ -192,6 +199,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
bannedWords: string[] = [];
+ groupTreeActivatedSubject = new BehaviorSubject(false);
+
ngOnInit() {
const loginInfo = this.sessionStorageService.get(KEY_LOGIN_INFO);
this.companyCode = loginInfo.companyCode;
@@ -256,6 +265,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
groupList = tempOrderArr;
}
+ this.groupList = groupList;
+
const groupBuddyList: {
group: GroupDetailData;
buddyList: UserInfo[];
@@ -318,7 +329,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
[
Validators.required,
this.checkSpecialCharacter(),
- this.checkBanWords()
+ this.checkBanWords(),
+ this.checkSameName()
]
]
});
@@ -350,6 +362,22 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
};
}
+ checkSameName(): ValidatorFn {
+ return (control: AbstractControl): { [key: string]: any } | null => {
+ if (
+ !control ||
+ !control.value ||
+ !this.groupList ||
+ 0 === this.groupList.length
+ ) {
+ return null;
+ }
+ const v = (control.value as string).trim();
+ const ban = -1 < this.groupList.findIndex(g => g.name === v);
+ return ban ? { groupNameSamed: { value: control.value } } : null;
+ };
+ }
+
ngOnDestroy(): void {
if (!!this.roomSubscription) {
this.roomSubscription.unsubscribe();
@@ -403,6 +431,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
this.selectedRoom = null;
}
+ this.groupTreeActivatedSubject.next(0 === tabChangeEvent.index);
+
this.store.dispatch(
SettingsStore.organizationTreeActivated({
activate: 1 === tabChangeEvent.index
diff --git a/projects/ucap-webmessenger-app/src/assets/i18n/en.json b/projects/ucap-webmessenger-app/src/assets/i18n/en.json
index 183b2763..c7adc3db 100644
--- a/projects/ucap-webmessenger-app/src/assets/i18n/en.json
+++ b/projects/ucap-webmessenger-app/src/assets/i18n/en.json
@@ -178,7 +178,8 @@
"errors": {
"label": "Group errors",
"requireName": "Group name is required.",
- "bannedWords": "Prohibited word. [{{bannedWords}}]"
+ "bannedWords": "Prohibited word. [{{bannedWords}}]",
+ "sameNameExist": "Group name already exists."
}
},
"chat": {
diff --git a/projects/ucap-webmessenger-app/src/assets/i18n/ko.json b/projects/ucap-webmessenger-app/src/assets/i18n/ko.json
index d5f4d8e8..8225fbb8 100644
--- a/projects/ucap-webmessenger-app/src/assets/i18n/ko.json
+++ b/projects/ucap-webmessenger-app/src/assets/i18n/ko.json
@@ -178,7 +178,8 @@
"errors": {
"label": "그룹 에러",
"requireName": "그룹명은 필수입력입니다.",
- "bannedWords": "금지단어 [{{bannedWords}}]"
+ "bannedWords": "금지단어 [{{bannedWords}}]",
+ "sameNameExist": "이미 존재하는 그룹명입니다."
}
},
"chat": {