Merge branch 'master' of https://git.loafle.net/ucap-web/next-ucap-messenger
This commit is contained in:
commit
31f11ce001
|
@ -26,8 +26,17 @@
|
|||
maxlength="20"
|
||||
placeholder="{{ 'group.name' | translate }}"
|
||||
formControlName="groupName"
|
||||
(keyup)="onKeyupGroupName()"
|
||||
/>
|
||||
<mat-hint align="end">{{ input.value?.length || 0 }}/20</mat-hint>
|
||||
<mat-error
|
||||
*ngIf="inputForm.get('groupName').hasError('groupNameBanned')"
|
||||
>
|
||||
{{
|
||||
'group.errors.bannedWords'
|
||||
| translate: { bannedWords: bannedWords.join(',') }
|
||||
}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
} from '@angular/material';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { Observable, combineLatest, Subscription, of } from 'rxjs';
|
||||
import { map, tap, catchError } from 'rxjs/operators';
|
||||
import { map, tap, catchError, take } from 'rxjs/operators';
|
||||
|
||||
import { Store, select } from '@ngrx/store';
|
||||
import * as AppStore from '@app/store';
|
||||
|
@ -62,7 +62,7 @@ import {
|
|||
AlertDialogResult,
|
||||
AlertDialogData
|
||||
} from '@ucap-webmessenger/ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
import { StringUtil } from '@ucap-webmessenger/core';
|
||||
|
||||
|
@ -116,11 +116,38 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
|||
private logger: NGXLogger,
|
||||
private dialogService: DialogService,
|
||||
private translateService: TranslateService,
|
||||
private translateParser: TranslateParser,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) {
|
||||
this.sessionVerinfo = this.sessionStorageService.get<VersionInfo2Response>(
|
||||
KEY_VER_INFO
|
||||
);
|
||||
|
||||
const banKeys: string[] = [
|
||||
'group.nameFavorite',
|
||||
'group.nameMyDept',
|
||||
'group.nameDefault'
|
||||
];
|
||||
|
||||
const currentLang = this.translateService.currentLang;
|
||||
const langs = ['ko', 'en'];
|
||||
|
||||
langs.forEach(lang => {
|
||||
this.translateService
|
||||
.getTranslation(lang)
|
||||
.pipe(take(1))
|
||||
.subscribe(
|
||||
translation => {
|
||||
banKeys.forEach(banKey => {
|
||||
this.bannedWords.push(
|
||||
this.translateParser.getValue(translation, banKey)
|
||||
);
|
||||
});
|
||||
},
|
||||
error => {},
|
||||
() => {}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
currentTabIndex: number;
|
||||
|
@ -163,6 +190,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
|||
|
||||
inputForm: FormGroup;
|
||||
|
||||
bannedWords: string[] = [];
|
||||
|
||||
ngOnInit() {
|
||||
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
||||
this.companyCode = loginInfo.companyCode;
|
||||
|
@ -284,7 +313,14 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
|||
.subscribe();
|
||||
|
||||
this.inputForm = this.formBuilder.group({
|
||||
groupName: ['', [Validators.required, StringUtil.checkSpecialCharacter()]]
|
||||
groupName: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
this.checkSpecialCharacter(),
|
||||
this.checkBanWords()
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
if (this.data.type === UserSelectDialogType.EditChatMember) {
|
||||
|
@ -294,6 +330,26 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
|||
this.currentTabIndex = 0;
|
||||
}
|
||||
|
||||
checkSpecialCharacter(): ValidatorFn {
|
||||
return (control: AbstractControl): { [key: string]: any } | null => {
|
||||
const forbidden = /[\{\}\[\]\/?.;:|\)*~`!^+<>@\#$%&\\\=\(\'\"]/g.test(
|
||||
control.value
|
||||
);
|
||||
return forbidden ? { groupName: { value: control.value } } : null;
|
||||
};
|
||||
}
|
||||
|
||||
checkBanWords(): ValidatorFn {
|
||||
return (control: AbstractControl): { [key: string]: any } | null => {
|
||||
if (!control || !control.value) {
|
||||
return null;
|
||||
}
|
||||
const ban =
|
||||
-1 < this.bannedWords.indexOf((control.value as string).trim());
|
||||
return ban ? { groupNameBanned: { value: control.value } } : null;
|
||||
};
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (!!this.roomSubscription) {
|
||||
this.roomSubscription.unsubscribe();
|
||||
|
@ -746,4 +802,8 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
|||
: undefined
|
||||
});
|
||||
}
|
||||
|
||||
onKeyupGroupName() {
|
||||
this.inputForm.get('groupName').markAsTouched();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,7 +177,8 @@
|
|||
"confirmRemoveGroup": "Are you sure you want to delete the group {{nameOfGroup}}?<br/>Group members will only be deleted from that group.",
|
||||
"errors": {
|
||||
"label": "Group errors",
|
||||
"requireName": "Group name is required."
|
||||
"requireName": "Group name is required.",
|
||||
"bannedWords": "Prohibited word. [{{bannedWords}}]"
|
||||
}
|
||||
},
|
||||
"chat": {
|
||||
|
|
|
@ -177,7 +177,8 @@
|
|||
"confirmRemoveGroup": "그룹({{nameOfGroup}})을 삭제하시겠습니까?<br/>그룹 멤버는 해당 그룹에서만 삭제됩니다.",
|
||||
"errors": {
|
||||
"label": "그룹 에러",
|
||||
"requireName": "그룹명은 필수입력입니다."
|
||||
"requireName": "그룹명은 필수입력입니다.",
|
||||
"bannedWords": "금지단어 [{{bannedWords}}]"
|
||||
}
|
||||
},
|
||||
"chat": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user