diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-07 16:59:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-07 17:05:42 +0200 |
commit | 1f20622f2b087eaf8738d60fae00a44b9c558ca3 (patch) | |
tree | 1c8554623665ca96b8a1e6f2a6bcb8c1b5a83c2e /client/src/app/+signup/+register/register-step-user.component.ts | |
parent | 1a03bea0c42fa1064ce4770157b4fd2e3edd5565 (diff) | |
download | PeerTube-1f20622f2b087eaf8738d60fae00a44b9c558ca3.tar.gz PeerTube-1f20622f2b087eaf8738d60fae00a44b9c558ca3.tar.zst PeerTube-1f20622f2b087eaf8738d60fae00a44b9c558ca3.zip |
Improve registration
* Add ability to set the user display name
* Use display name to guess the username/channel name
* Add explanations about what is the purpose of a username/channel name
* Add a loader at the "done" step
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.ts | 19 |
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 @@ | |||
1 | import { Component, EventEmitter, OnInit, Output } from '@angular/core' | 1 | import { Component, EventEmitter, OnInit, Output } from '@angular/core' |
2 | import { AuthService } from '@app/core' | 2 | import { AuthService } from '@app/core' |
3 | import { FormReactive, UserValidatorsService } from '@app/shared' | 3 | import { FormReactive, UserService, UserValidatorsService } from '@app/shared' |
4 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 4 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
5 | import { FormGroup } from '@angular/forms' | 5 | import { FormGroup } from '@angular/forms' |
6 | import { pairwise } from 'rxjs/operators' | ||
7 | import { 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 | } |