member_webapp/@overflow/member/component/member-reset-password.component.ts

59 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-05-30 07:44:21 +00:00
import {
Component,
OnInit,
Output,
EventEmitter, Input
} from '@angular/core';
import {
FormGroup,
FormBuilder,
Validators,
AbstractControl
} from '@angular/forms';
import {Member} from '@overflow/commons-typescript/model/member';
2018-05-28 05:41:56 +00:00
@Component({
selector: 'of-member-reset-password',
templateUrl: './member-reset-password.component.html',
})
export class MemberResetPasswordComponent implements OnInit {
@Output() resetPassword = new EventEmitter<string>();
2018-05-30 07:44:21 +00:00
@Output() signin = new EventEmitter();
@Output() signup = new EventEmitter();
@Input() member: Member;
2018-05-28 05:41:56 +00:00
resetPasswordForm: FormGroup;
2018-05-30 05:52:39 +00:00
email: AbstractControl;
2018-05-28 05:41:56 +00:00
constructor(
private formBuilder: FormBuilder
) {
}
ngOnInit() {
this.resetPasswordForm = this.formBuilder.group({
'email': ['', [
Validators.required,
Validators.email
]
]
});
2018-05-30 05:52:39 +00:00
this.email = this.resetPasswordForm.controls['email'];
2018-05-28 05:41:56 +00:00
}
2018-05-30 07:44:21 +00:00
resetPasswordSubmit() {
2018-05-28 05:41:56 +00:00
const formValue = Object.assign({}, this.resetPasswordForm.value);
this.resetPassword.emit(formValue.email);
}
2018-05-30 07:44:21 +00:00
onSignin() {
this.signin.emit();
}
onSignup() {
this.signup.emit();
}
2018-05-28 05:41:56 +00:00
}