로그인 페이지 validation 에러 메시지 표출방식 수정. >> 하단에 한번에 출력하는 방식으로 수정.
This commit is contained in:
parent
f00028f2b0
commit
a8a4930956
|
@ -9,33 +9,54 @@
|
||||||
<form name="loginForm" [formGroup]="loginForm" novalidate>
|
<form name="loginForm" [formGroup]="loginForm" novalidate>
|
||||||
<mat-form-field [style.display]="!!curCompanyCode ? 'none' : 'block'">
|
<mat-form-field [style.display]="!!curCompanyCode ? 'none' : 'block'">
|
||||||
<mat-label>{{ 'accounts.fieldCompany' | translate }}</mat-label>
|
<mat-label>{{ 'accounts.fieldCompany' | translate }}</mat-label>
|
||||||
<mat-select formControlName="companyCode" required>
|
<mat-select [formControl]="companyCodeFormControl">
|
||||||
<mat-option
|
<mat-option
|
||||||
*ngFor="let company of companyList"
|
*ngFor="let company of companyList"
|
||||||
[value]="company.companyCode"
|
[value]="company.companyCode"
|
||||||
>{{ company.companyName }}
|
>{{ company.companyName }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="loginForm.get('companyCode').hasError('required')">
|
|
||||||
{{ 'accounts.errors.requireCompany' | translate }}
|
|
||||||
</mat-error>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ 'accounts.fieldLoginId' | translate }}</mat-label>
|
<mat-label>{{ 'accounts.fieldLoginId' | translate }}</mat-label>
|
||||||
<input matInput formControlName="loginId" />
|
<input matInput [formControl]="loginIdFormControl" />
|
||||||
<mat-error *ngIf="loginForm.get('loginId').hasError('required')">
|
|
||||||
{{ 'accounts.errors.requireLoginId' | translate }}
|
|
||||||
</mat-error>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ 'accounts.fieldLoginPw' | translate }}</mat-label>
|
<mat-label>{{ 'accounts.fieldLoginPw' | translate }}</mat-label>
|
||||||
<input matInput type="password" formControlName="loginPw" #loginPw />
|
<input
|
||||||
<mat-error>
|
matInput
|
||||||
|
type="password"
|
||||||
|
[formControl]="loginPwFormControl"
|
||||||
|
#loginPw
|
||||||
|
/>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div class="error-container">
|
||||||
|
<mat-error
|
||||||
|
*ngIf="
|
||||||
|
companyCodeFormControl.dirty &&
|
||||||
|
companyCodeFormControl.hasError('required')
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ 'accounts.errors.requireCompany' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error
|
||||||
|
*ngIf="
|
||||||
|
loginIdFormControl.dirty && loginIdFormControl.hasError('required')
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ 'accounts.errors.requireLoginId' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error
|
||||||
|
*ngIf="
|
||||||
|
loginPwFormControl.dirty && loginPwFormControl.hasError('required')
|
||||||
|
"
|
||||||
|
>
|
||||||
{{ 'accounts.errors.requireLoginPw' | translate }}
|
{{ 'accounts.errors.requireLoginPw' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
mat-raised-button
|
mat-raised-button
|
||||||
|
|
|
@ -8,7 +8,13 @@ import {
|
||||||
ElementRef,
|
ElementRef,
|
||||||
ChangeDetectorRef
|
ChangeDetectorRef
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
import {
|
||||||
|
FormGroup,
|
||||||
|
FormBuilder,
|
||||||
|
Validators,
|
||||||
|
FormControl,
|
||||||
|
ValidatorFn
|
||||||
|
} from '@angular/forms';
|
||||||
import { Company } from '@ucap-webmessenger/api-external';
|
import { Company } from '@ucap-webmessenger/api-external';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -57,6 +63,9 @@ export class LoginComponent implements OnInit {
|
||||||
@ViewChild('loginPw', { static: true }) loginPwElementRef: ElementRef;
|
@ViewChild('loginPw', { static: true }) loginPwElementRef: ElementRef;
|
||||||
|
|
||||||
loginForm: FormGroup;
|
loginForm: FormGroup;
|
||||||
|
companyCodeFormControl = new FormControl('');
|
||||||
|
loginIdFormControl = new FormControl('');
|
||||||
|
loginPwFormControl = new FormControl('');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
|
@ -64,10 +73,23 @@ export class LoginComponent implements OnInit {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
const companyCodeValidators: ValidatorFn[] = [Validators.required];
|
||||||
|
this.companyCodeFormControl.setValidators(companyCodeValidators);
|
||||||
|
if (!!this.curCompanyCode) {
|
||||||
|
this.companyCodeFormControl.setValue(this.curCompanyCode);
|
||||||
|
}
|
||||||
|
const loginIdValidators: ValidatorFn[] = [Validators.required];
|
||||||
|
this.loginIdFormControl.setValidators(loginIdValidators);
|
||||||
|
if (!!this.loginId) {
|
||||||
|
this.loginIdFormControl.setValue(this.loginId);
|
||||||
|
}
|
||||||
|
const loginPwValidators: ValidatorFn[] = [Validators.required];
|
||||||
|
this.loginPwFormControl.setValidators(loginPwValidators);
|
||||||
|
|
||||||
this.loginForm = this.formBuilder.group({
|
this.loginForm = this.formBuilder.group({
|
||||||
companyCode: ['', [Validators.required]],
|
companyCodeFormControl: this.companyCodeFormControl,
|
||||||
loginId: ['', [Validators.required]],
|
loginIdFormControl: this.loginIdFormControl,
|
||||||
loginPw: ['', Validators.required],
|
loginPwFormControl: this.loginPwFormControl,
|
||||||
rememberMe: [false],
|
rememberMe: [false],
|
||||||
autoLogin: [false]
|
autoLogin: [false]
|
||||||
});
|
});
|
||||||
|
@ -80,13 +102,6 @@ export class LoginComponent implements OnInit {
|
||||||
this.loginForm.get('autoLogin').setValue(true);
|
this.loginForm.get('autoLogin').setValue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!this.curCompanyCode) {
|
|
||||||
this.loginForm.get('companyCode').setValue(this.curCompanyCode);
|
|
||||||
}
|
|
||||||
if (!!this.loginId) {
|
|
||||||
this.loginForm.get('loginId').setValue(this.loginId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.loginBtnText || this.loginBtnText.trim().length === 0) {
|
if (!this.loginBtnText || this.loginBtnText.trim().length === 0) {
|
||||||
this.loginBtnText = 'LOGIN';
|
this.loginBtnText = 'LOGIN';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user