Skip to content

Commit 54ea872

Browse files
committed
Angular Forms Course
1 parent 273a412 commit 54ea872

11 files changed

+20
-31
lines changed

src/app/address-form/address-form.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export class AddressFormComponent implements ControlValueAccessor, OnDestroy, Va
9595
errors = this.addControlErrors(errors, "zipCode");
9696
errors = this.addControlErrors(errors, "city");
9797

98-
console.log("errors", errors);
99-
10098
return errors;
10199
}
102100

src/app/app.module.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ import {CoursesService} from "./services/courses.service";
2828
import {HttpClientModule} from "@angular/common/http";
2929
import {CourseResolver} from "./services/course.resolver";
3030
import { CourseDialogComponent } from './course-dialog/course-dialog.component';
31-
import {FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule} from '@angular/forms';
32-
import {MatMomentDateModule} from "@angular/material-moment-adapter";
31+
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
3332
import {LoginComponent} from './login/login.component';
3433
import { CreateCourseComponent } from './create-course/create-course.component';
3534
import {MatNativeDateModule} from '@angular/material/core';
3635
import {PasswordStrengthDirective} from './directives/password-strength.directive';
3736
import {OnlyOneErrorPipe} from './pipes/only-one-error.pipe';
3837
import {MatRadioModule} from '@angular/material/radio';
3938
import {MatCheckboxModule} from '@angular/material/checkbox';
40-
import {CreateCourseStepTwoComponent} from './create-course/create-course-step-two/create-course-step-two.component';
39+
import {CreateCourseStep2Component} from './create-course/create-course-step-2/create-course-step-2.component';
4140
import {MatStepperModule} from '@angular/material/stepper';
4241
import { AddressFormComponent } from './address-form/address-form.component';
43-
import {CreateCourseStepThreeComponent} from './create-course/create-course-step-three/create-course-step-three.component';
42+
import {CreateCourseStep3Component} from './create-course/create-course-step-3/create-course-step-3.component';
4443
import {CreateCourseStep1Component} from './create-course/create-course-step-1/create-course-step-1.component';
4544

4645
@NgModule({
@@ -56,8 +55,8 @@ import {CreateCourseStep1Component} from './create-course/create-course-step-1/c
5655
PasswordStrengthDirective,
5756
OnlyOneErrorPipe,
5857
CreateCourseStep1Component,
59-
CreateCourseStepTwoComponent,
60-
CreateCourseStepThreeComponent,
58+
CreateCourseStep2Component,
59+
CreateCourseStep3Component,
6160
AddressFormComponent
6261
],
6362
imports: [

src/app/create-course/create-course-step-two/create-course-step-two.component.ts renamed to src/app/create-course/create-course-step-2/create-course-step-2.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import {createPromoRangeValidator} from '../../validators/date-range.validator';
44

55

66
@Component({
7-
selector: 'create-course-step-two',
8-
templateUrl: 'create-course-step-two.component.html',
9-
styleUrls: ['create-course-step-two.component.scss']
7+
selector: 'create-course-step-2',
8+
templateUrl: 'create-course-step-2.component.html',
9+
styleUrls: ['create-course-step-2.component.scss']
1010
})
11-
export class CreateCourseStepTwoComponent implements OnInit {
11+
export class CreateCourseStep2Component implements OnInit {
1212

1313
form: FormGroup;
1414

src/app/create-course/create-course-step-three/create-course-step-three.component.ts renamed to src/app/create-course/create-course-step-3/create-course-step-3.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
33

44

55
@Component({
6-
selector: 'create-course-step-three',
7-
templateUrl: 'create-course-step-three.component.html',
8-
styleUrls: ['create-course-step-three.component.scss']
6+
selector: 'create-course-step-3',
7+
templateUrl: 'create-course-step-3.component.html',
8+
styleUrls: ['create-course-step-3.component.scss']
99
})
10-
export class CreateCourseStepThreeComponent {
10+
export class CreateCourseStep3Component {
1111

1212
form: FormGroup = this.fb.group({
1313
lessons: this.fb.array([])

src/app/create-course/create-course.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ <h2 class="title">Create New Course</h2>
1818

1919
</mat-step>
2020

21-
<mat-step [stepControl]="stepTwo.form" errorMessage="Course pricing in error">
21+
<mat-step [stepControl]="step2.form" errorMessage="Course pricing in error">
2222

2323
<ng-template matStepLabel>course pricing details</ng-template>
2424

25-
<create-course-step-two #stepTwo></create-course-step-two>
25+
<create-course-step-2 #step2></create-course-step-2>
2626

2727
<div class="stepper-buttons">
2828
<button mat-raised-button matStepperPrevious>Back</button>
29-
<button mat-raised-button color="primary" matStepperNext [disabled]="!stepTwo.form.valid">Continue to Step 3</button>
29+
<button mat-raised-button color="primary" matStepperNext [disabled]="!step2.form.valid">Continue to Step 3</button>
3030
</div>
3131

3232
</mat-step>
3333

34-
<mat-step [stepControl]="stepThree.form" errorMessage="Course lessons in error">
34+
<mat-step [stepControl]="step3.form" errorMessage="Course lessons in error">
3535

3636
<ng-template matStepLabel>course lessons</ng-template>
3737

38-
<create-course-step-three #stepThree></create-course-step-three>
38+
<create-course-step-3 #step3></create-course-step-3>
3939

4040
<div class="stepper-buttons">
4141
<button mat-raised-button matStepperPrevious>Back</button>
42-
<button mat-raised-button color="primary" matStepperNext [disabled]="!stepThree.form.valid"
43-
(click)="submit(step1.form.value, stepTwo.form.value, stepThree.form.value)">
42+
<button mat-raised-button color="primary" matStepperNext [disabled]="!step3.form.valid"
43+
(click)="submit(step1.form.value, step2.form.value, step3.form.value)">
4444
Create Course
4545
</button>
4646
</div>

src/app/pipes/only-one-error.pipe.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ export class OnlyOneErrorPipe implements PipeTransform {
99

1010
transform(allErrors: any, errorsPriority: string[]): any {
1111

12-
console.log("allErrors", allErrors);
13-
1412
if (!allErrors) {
1513
return null;
1614
}
@@ -24,8 +22,6 @@ export class OnlyOneErrorPipe implements PipeTransform {
2422
}
2523
}
2624

27-
console.log("onlyOneError", onlyOneError);
28-
2925
return onlyOneError;
3026

3127
}

src/app/validators/password-strength.validator.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export function createPasswordStrengthValidator(): ValidatorFn {
1010
return null;
1111
}
1212

13-
console.log("Checking password strength: " + value);
14-
1513
const hasUpperCase = /[A-Z]+/.test(value);
1614

1715
const hasLowerCase = /[a-z]+/.test(value);
@@ -20,8 +18,6 @@ export function createPasswordStrengthValidator(): ValidatorFn {
2018

2119
const passwordValid = hasLowerCase && hasUpperCase && hasNumeric;
2220

23-
console.log("passwordValid: ", passwordValid);
24-
2521
return !passwordValid ? {passwordStrength: true} : null;
2622
};
2723

0 commit comments

Comments
 (0)