# 이슈처리 230
This commit is contained in:
parent
fc837fe441
commit
08f03b7043
|
@ -71,6 +71,7 @@ import {
|
||||||
} from '@ucap-webmessenger/ui';
|
} from '@ucap-webmessenger/ui';
|
||||||
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
||||||
import { environment } from '../../../../../environments/environment';
|
import { environment } from '../../../../../environments/environment';
|
||||||
|
import { StringUtil } from '@ucap-webmessenger/core';
|
||||||
|
|
||||||
export interface CreateChatDialogData {
|
export interface CreateChatDialogData {
|
||||||
type?: string;
|
type?: string;
|
||||||
|
@ -328,7 +329,7 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
||||||
'',
|
'',
|
||||||
[
|
[
|
||||||
Validators.required,
|
Validators.required,
|
||||||
this.checkSpecialCharacter(),
|
StringUtil.checkSpecialCharacter(),
|
||||||
this.checkBanWords(),
|
this.checkBanWords(),
|
||||||
this.checkSameName()
|
this.checkSameName()
|
||||||
]
|
]
|
||||||
|
@ -342,15 +343,6 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
||||||
this.currentTabIndex = 0;
|
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 {
|
checkBanWords(): ValidatorFn {
|
||||||
return (control: AbstractControl): { [key: string]: any } | null => {
|
return (control: AbstractControl): { [key: string]: any } | null => {
|
||||||
if (!control || !control.value) {
|
if (!control || !control.value) {
|
||||||
|
|
|
@ -26,6 +26,19 @@
|
||||||
formControlName="groupName"
|
formControlName="groupName"
|
||||||
/>
|
/>
|
||||||
<mat-hint align="end">{{ input.value?.length || 0 }}/20</mat-hint>
|
<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-error
|
||||||
|
*ngIf="inputForm.get('groupName').hasError('groupNameSamed')"
|
||||||
|
>
|
||||||
|
{{ 'group.errors.sameNameExist' | translate }}
|
||||||
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Inject } from '@angular/core';
|
import { Component, OnInit, Inject, OnDestroy } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
FormGroup,
|
FormGroup,
|
||||||
FormBuilder,
|
FormBuilder,
|
||||||
|
@ -9,6 +9,11 @@ import {
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import { GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
import { GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
||||||
import { StringUtil } from '@ucap-webmessenger/core';
|
import { StringUtil } from '@ucap-webmessenger/core';
|
||||||
|
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
||||||
|
import { take, tap } from 'rxjs/operators';
|
||||||
|
import { Store, select } from '@ngrx/store';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
import * as AppStore from '@app/store';
|
||||||
|
|
||||||
export interface EditGroupDialogData {
|
export interface EditGroupDialogData {
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -26,23 +31,75 @@ export interface EditGroupDialogResult {
|
||||||
templateUrl: './edit-group.dialog.component.html',
|
templateUrl: './edit-group.dialog.component.html',
|
||||||
styleUrls: ['./edit-group.dialog.component.scss']
|
styleUrls: ['./edit-group.dialog.component.scss']
|
||||||
})
|
})
|
||||||
export class EditGroupDialogComponent implements OnInit {
|
export class EditGroupDialogComponent implements OnInit, OnDestroy {
|
||||||
groupName: string;
|
groupName: string;
|
||||||
inputForm: FormGroup;
|
inputForm: FormGroup;
|
||||||
|
|
||||||
|
bannedWords: string[] = [];
|
||||||
|
groupListSubscription: Subscription;
|
||||||
|
groupList: GroupDetailData[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private store: Store<any>,
|
||||||
public dialogRef: MatDialogRef<EditGroupDialogData, EditGroupDialogResult>,
|
public dialogRef: MatDialogRef<EditGroupDialogData, EditGroupDialogResult>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: EditGroupDialogData,
|
@Inject(MAT_DIALOG_DATA) public data: EditGroupDialogData,
|
||||||
|
private translateService: TranslateService,
|
||||||
|
private translateParser: TranslateParser,
|
||||||
private formBuilder: FormBuilder
|
private formBuilder: FormBuilder
|
||||||
) {}
|
) {
|
||||||
|
const banKeys: string[] = [
|
||||||
|
'group.nameFavorite',
|
||||||
|
'group.nameMyDept',
|
||||||
|
'group.nameDefault'
|
||||||
|
];
|
||||||
|
|
||||||
|
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 => {},
|
||||||
|
() => {}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.inputForm = this.formBuilder.group({
|
this.inputForm = this.formBuilder.group({
|
||||||
groupName: [
|
groupName: [
|
||||||
this.data.group.name,
|
this.data.group.name,
|
||||||
[Validators.required, StringUtil.checkSpecialCharacter()]
|
[
|
||||||
|
Validators.required,
|
||||||
|
StringUtil.checkSpecialCharacter(),
|
||||||
|
this.checkBanWords(),
|
||||||
|
this.checkSameName()
|
||||||
|
]
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.groupListSubscription = this.store
|
||||||
|
.pipe(
|
||||||
|
select(AppStore.MessengerSelector.SyncSelector.selectAllGroup2),
|
||||||
|
tap(groupList => {
|
||||||
|
this.groupList = groupList;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (!!this.groupListSubscription) {
|
||||||
|
this.groupListSubscription.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickChoice(choice: boolean): void {
|
onClickChoice(choice: boolean): void {
|
||||||
|
@ -52,4 +109,31 @@ export class EditGroupDialogComponent implements OnInit {
|
||||||
group: this.data.group
|
group: this.data.group
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user