Skip to content

Commit

Permalink
fix todo: hide recovery password box in step 3
Browse files Browse the repository at this point in the history
  • Loading branch information
kewde committed Nov 1, 2017
1 parent 8c5c836 commit e406864
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
30 changes: 20 additions & 10 deletions src/app/modals/createwallet/createwallet.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,26 @@
<!--md-form-field class="wallet-name">
<input mdInput [(ngModel)]="name" placeholder="Wallet name" readonly />
</md-form-field-->
<div *ngIf="step === 2">
<app-password
#passwordElement
label="Recovery Password (optional)"
[emitPassword]="true"
(passwordEmitter)="passwordFromEmitter($event)"
[showStakeOnly]="false">
</app-password>
</div>

<!--
<app-password
#passwordComponent
label="Recovery Password (optional)"
[emitPassword]="true"
[isDisabled]="[3,4].indexOf(step) != -1"
(passwordEmitter)="passwordFromEmitter($event)"
[showStakeOnly]="false">
</app-password> -->

<!-- @TODO: can we hide this from step 3? -->
<app-password
#passwordComponent
label="Recovery Password (optional)"
[emitPassword]="true"
[isDisabled]="[3,4].indexOf(step) != -1"
(passwordEmitter)="passwordFromEmitter($event)"
[showStakeOnly]="false">
</app-password>

<ng-template [ngIf]="[3,4].indexOf(step) != -1">
<app-passphrase
Expand All @@ -155,7 +165,7 @@
<button md-button (click)="prevStep()">
Back
</button>
<button md-raised-button color="primary" (click)="step === 2 && passwordComponent.sendPassword(); nextStep()"> <!-- TODO: Move sendPassword to .ts -->
<button md-raised-button color="primary" (click)="nextStep()"> <!-- TODO: Move sendPassword to .ts -->
Next
</button>
</div><!-- .actions -->
Expand Down
4 changes: 3 additions & 1 deletion src/app/modals/createwallet/createwallet.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
\* ------------------------------- */



.invisible {
visibility: hidden;
}



Expand Down
15 changes: 15 additions & 0 deletions src/app/modals/createwallet/createwallet.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Inject, forwardRef, ViewChild, ElementRef, ComponentRef, HostListener } from '@angular/core';
import { Log } from 'ng2-logger';

import { PasswordComponent } from '../shared/password/password.component';
import { IPassword } from '../shared/password/password.interface';

import { flyInOut, slideDown } from '../../core/core.animations';
Expand Down Expand Up @@ -37,6 +38,7 @@ export class CreateWalletComponent {
words: string[];

@ViewChild('passphraseComponent') passphraseComponent: ComponentRef<PassphraseComponent>;
@ViewChild('passwordElement') passwordElement: PasswordComponent;

// Used for verification
private wordsVerification: string[];
Expand Down Expand Up @@ -86,6 +88,11 @@ export class CreateWalletComponent {
nextStep() {
this.validating = true;

/* Recovery password entered */
if(this.step === 2) {
this.passwordElement.sendPassword();
}

if (this.validate()) {
this.animationState = 'next';
this.validating = false;
Expand All @@ -94,6 +101,7 @@ export class CreateWalletComponent {
this.doStep();
}

this.log.d(`moving to step: ${this.step}`);
}

prevStep() {
Expand Down Expand Up @@ -180,10 +188,17 @@ export class CreateWalletComponent {
return true;
}

/**
* Triggered when the password is emitted from PasswordComponent
*/
passwordFromEmitter(pass: IPassword) {
this.password = pass.password;
this.log.d(`passwordFromEmitter: ${this.password}`);
}

/**
* Triggered when the password is emitted from PassphraseComponent
*/
wordsFromEmitter(words: string) {
this.words = words.split(',');
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/modals/shared/password/password.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export class PasswordComponent {
clear() {
this.password = undefined;
}
/*
Emit password!
*/

/**
* Emit password only!
*/
sendPassword() {
const pass: IPassword = {
password: this.password,
Expand Down

0 comments on commit e406864

Please sign in to comment.