aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+signup/+register/register-step-user.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+signup/+register/register-step-user.component.ts')
-rw-r--r--client/src/app/+signup/+register/register-step-user.component.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/client/src/app/+signup/+register/register-step-user.component.ts b/client/src/app/+signup/+register/register-step-user.component.ts
index 3825ae371..3b71fd3c4 100644
--- a/client/src/app/+signup/+register/register-step-user.component.ts
+++ b/client/src/app/+signup/+register/register-step-user.component.ts
@@ -1,8 +1,10 @@
1import { Component, EventEmitter, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, OnInit, Output } from '@angular/core'
2import { AuthService } from '@app/core' 2import { AuthService } from '@app/core'
3import { FormReactive, UserValidatorsService } from '@app/shared' 3import { FormReactive, UserService, UserValidatorsService } from '@app/shared'
4import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 4import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
5import { FormGroup } from '@angular/forms' 5import { FormGroup } from '@angular/forms'
6import { pairwise } from 'rxjs/operators'
7import { concat, of } from 'rxjs'
6 8
7@Component({ 9@Component({
8 selector: 'my-register-step-user', 10 selector: 'my-register-step-user',
@@ -15,6 +17,7 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
15 constructor ( 17 constructor (
16 protected formValidatorService: FormValidatorService, 18 protected formValidatorService: FormValidatorService,
17 private authService: AuthService, 19 private authService: AuthService,
20 private userService: UserService,
18 private userValidatorsService: UserValidatorsService 21 private userValidatorsService: UserValidatorsService
19 ) { 22 ) {
20 super() 23 super()
@@ -26,6 +29,7 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
26 29
27 ngOnInit () { 30 ngOnInit () {
28 this.buildForm({ 31 this.buildForm({
32 displayName: this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED,
29 username: this.userValidatorsService.USER_USERNAME, 33 username: this.userValidatorsService.USER_USERNAME,
30 password: this.userValidatorsService.USER_PASSWORD, 34 password: this.userValidatorsService.USER_PASSWORD,
31 email: this.userValidatorsService.USER_EMAIL, 35 email: this.userValidatorsService.USER_EMAIL,
@@ -33,5 +37,18 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
33 }) 37 })
34 38
35 setTimeout(() => this.formBuilt.emit(this.form)) 39 setTimeout(() => this.formBuilt.emit(this.form))
40
41 concat(
42 of(''),
43 this.form.get('displayName').valueChanges
44 ).pipe(pairwise())
45 .subscribe(([ oldValue, newValue ]) => this.onDisplayNameChange(oldValue, newValue))
46 }
47
48 private onDisplayNameChange (oldDisplayName: string, newDisplayName: string) {
49 const username = this.form.value['username'] || ''
50
51 const newUsername = this.userService.getNewUsername(oldDisplayName, newDisplayName, username)
52 this.form.patchValue({ username: newUsername })
36 } 53 }
37} 54}