닉네임 중복체크
This commit is contained in:
parent
71876494d5
commit
152994e63b
|
@ -36,6 +36,8 @@ import { Router } from '@angular/router';
|
|||
import { RegistComposeComponent } from '../compose/regist-compose.component';
|
||||
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
|
||||
import { Site } from 'app/modules/protobuf/models/domain/site_pb';
|
||||
@Component({
|
||||
selector: 'partner-list',
|
||||
templateUrl: './list.component.html',
|
||||
|
@ -77,6 +79,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
searchInputControl = new FormControl();
|
||||
selectedPartner?: Partner;
|
||||
pagination?: PartnerPagination;
|
||||
sites!: Site[];
|
||||
|
||||
private _unsubscribeAll: Subject<any> = new Subject<any>();
|
||||
|
||||
|
@ -88,6 +91,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
private _fuseConfirmationService: FuseConfirmationService,
|
||||
private _formBuilder: FormBuilder,
|
||||
private _partnerService: PartnerService,
|
||||
private _siteService: SiteService,
|
||||
private router: Router,
|
||||
private _matDialog: MatDialog
|
||||
) {}
|
||||
|
@ -113,6 +117,13 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
|
||||
// Get the products
|
||||
this.partners$ = this._partnerService.partners$;
|
||||
|
||||
this._siteService
|
||||
.listSites()
|
||||
.then((result) => {
|
||||
this.sites = result.getSitesList();
|
||||
})
|
||||
.catch((reson) => console.log(reson));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,7 +214,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
|
||||
__onClickRegist(event: MouseEvent): void {
|
||||
const dialogRef = this._matDialog.open(RegistComposeComponent, {
|
||||
data: { title: '대본', parentId: 'kgon2' },
|
||||
data: { title: '대본', parentId: 'kgon2', sites: this.sites },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<input matInput [formControlName]="'partnerId'" />
|
||||
</mat-form-field>
|
||||
|
||||
<!-- <div *ngFor="let f of sites">{{ f.getUrl() }}</div> -->
|
||||
<!-- Cc -->
|
||||
<mat-form-field>
|
||||
<mat-label>사이트명</mat-label>
|
||||
|
@ -32,6 +33,18 @@
|
|||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<!-- <mat-form-field>
|
||||
<mat-label>사이트명</mat-label>
|
||||
<mat-select [formControlName]="'siteName'" placeholder="사이트 선택">
|
||||
<mat-option *ngFor="let site of sites" [value]="site.getId()">
|
||||
{{ site.getUrl() }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="composeForm.get('siteName')?.hasError('required')">
|
||||
사이트명은 필수 입력입니다.
|
||||
</mat-error>
|
||||
</mat-form-field> -->
|
||||
|
||||
<!-- Bcc -->
|
||||
<mat-form-field>
|
||||
<mat-label>회원 아이디</mat-label>
|
||||
|
@ -69,10 +82,19 @@
|
|||
|
||||
<mat-form-field>
|
||||
<mat-label>닉네임</mat-label>
|
||||
<input matInput [formControlName]="'nickname'" />
|
||||
<input
|
||||
matInput
|
||||
[formControlName]="'nickname'"
|
||||
(focusout)="__checkNickname($event)"
|
||||
/>
|
||||
<mat-error *ngIf="composeForm.get('nickname')?.hasError('required')">
|
||||
닉네임은 필수 입력입니다.
|
||||
</mat-error>
|
||||
<mat-error
|
||||
*ngIf="composeForm.get('nickname')?.hasError('nicknameDuplicate')"
|
||||
>
|
||||
닉네임이 중복됩니다.
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
|
@ -127,13 +149,9 @@
|
|||
class="flex flex-col sm:flex-row sm:items-center justify-between mt-4 sm:mt-6"
|
||||
>
|
||||
<div class="flex items-center mt-4 sm:mt-0">
|
||||
<!-- Discard -->
|
||||
<button class="ml-auto sm:ml-0" mat-stroked-button (click)="discard()">
|
||||
Discard
|
||||
</button>
|
||||
<!-- Save as draft -->
|
||||
<button class="sm:mx-3" mat-stroked-button (click)="saveAsDraft()">
|
||||
<span>Save as draft</span>
|
||||
<span>취소</span>
|
||||
</button>
|
||||
<!-- Send -->
|
||||
<button
|
||||
|
@ -142,7 +160,7 @@
|
|||
[color]="'primary'"
|
||||
(click)="send()"
|
||||
>
|
||||
Send
|
||||
등록
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,11 +7,14 @@ import {
|
|||
} from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
|
||||
import { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
|
||||
import { Site } from 'app/modules/protobuf/models/domain/site_pb';
|
||||
|
||||
export interface RegistComposeData {
|
||||
title: string;
|
||||
parentId: string;
|
||||
sites: Site[];
|
||||
}
|
||||
export interface RegistComposeResult {
|
||||
parentId: string;
|
||||
|
@ -34,10 +37,7 @@ export interface RegistComposeResult {
|
|||
})
|
||||
export class RegistComposeComponent implements OnInit {
|
||||
composeForm!: FormGroup;
|
||||
copyFields: { cc: boolean; bcc: boolean } = {
|
||||
cc: false,
|
||||
bcc: false,
|
||||
};
|
||||
sites: any[] = [];
|
||||
// quillModules: any = {
|
||||
// toolbar: [
|
||||
// ['bold', 'italic', 'underline'],
|
||||
|
@ -55,7 +55,12 @@ export class RegistComposeComponent implements OnInit {
|
|||
private _formBuilder: FormBuilder,
|
||||
private _identityService: IdentityService,
|
||||
private _changeDetectorRef: ChangeDetectorRef
|
||||
) {}
|
||||
) {
|
||||
this.data.sites.map((v) => {
|
||||
const a = v.toObject();
|
||||
this.sites.push(a);
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Lifecycle hooks
|
||||
|
@ -85,21 +90,6 @@ export class RegistComposeComponent implements OnInit {
|
|||
// @ Public methods
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show the copy field with the given field name
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
showCopyField(name: string): void {
|
||||
// Return if the name is not one of the available names
|
||||
if (name !== 'cc' && name !== 'bcc') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show the field
|
||||
this.copyFields[name] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save and close
|
||||
*/
|
||||
|
@ -141,6 +131,21 @@ export class RegistComposeComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
__checkNickname(event: FocusEvent): void {
|
||||
const nickname = this.composeForm.get('nickname')?.value;
|
||||
|
||||
this._identityService
|
||||
.checkNicknameForDuplication(nickname)
|
||||
.then((isUse: boolean) => {
|
||||
if (!!isUse) {
|
||||
this.composeForm
|
||||
.get('nickname')
|
||||
?.setErrors({ nicknameDuplicate: true });
|
||||
}
|
||||
this._changeDetectorRef.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
// checkSameName(): ValidatorFn {
|
||||
// return (control: AbstractControl): { [key: string]: any } | null => {
|
||||
// if (
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
||||
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
|
@ -29,6 +31,9 @@ import { partnerRoutes } from './partner.routing';
|
|||
TranslocoModule,
|
||||
SharedModule,
|
||||
RouterModule.forChild(partnerRoutes),
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
FormsModule,
|
||||
|
||||
MatButtonModule,
|
||||
MatFormFieldModule,
|
||||
|
|
|
@ -7,11 +7,14 @@ import { Error } from 'app/modules/protobuf/protobuf/rpc/error_pb';
|
|||
import {
|
||||
CheckUsernameForDuplicationRequest,
|
||||
CheckUsernameForDuplicationResponse,
|
||||
CheckNicknameForDuplicationRequest,
|
||||
CheckNicknameForDuplicationResponse,
|
||||
CaptchaRequest,
|
||||
CaptchaResponse,
|
||||
} from 'app/modules/protobuf/c2se/common/identity_pb';
|
||||
import {
|
||||
SUBJECT_CHECK_USERNAME_FOR_DUPLICATION,
|
||||
SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION,
|
||||
SUBJECT_CAPTCHA,
|
||||
SUBJECT_SIGNIN,
|
||||
SigninRequest,
|
||||
|
@ -57,6 +60,28 @@ export class IdentityService {
|
|||
});
|
||||
}
|
||||
|
||||
checkNicknameForDuplication(nickname: string): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let req = new CheckNicknameForDuplicationRequest();
|
||||
req.setNickname(nickname);
|
||||
|
||||
this.__natsService
|
||||
.request<CheckNicknameForDuplicationResponse.Result>(
|
||||
SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION,
|
||||
req.serializeBinary(),
|
||||
CheckNicknameForDuplicationResponse.deserializeBinary
|
||||
)
|
||||
.then((result) => {
|
||||
console.log('success', result, result.getDuplicated());
|
||||
resolve(result.getDuplicated());
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
console.log('failed', e);
|
||||
reject(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
captcha(): Promise<CaptchaResponse.Result> {
|
||||
return new Promise<CaptchaResponse.Result>((resolve, reject) => {
|
||||
let req = new CaptchaRequest();
|
||||
|
|
Loading…
Reference in New Issue
Block a user