view-update-profile.component.ts
6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import { Component, AfterViewInit, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ApplicationService } from '../services/application.service';
import { FormGroup, FormControl, FormBuilder, Validators } from '@angular/forms';
//import { patternValidator } from 'app/shared/pattern-validator';
import { State, Country } from '../model/db-tables'; //, AccountNumber
//import {UpdateLicenseeProfile} from '../model/update-profile.interface';
declare var jQuery: any;
@Component({
templateUrl: '../components/view-update-profile.component.html'
})
export class ViewUpdateProfileComponent implements AfterViewInit, OnInit {
//public updateProfile: UpdateLicenseeProfile;
//viewUpdateProfileForm: FormGroup;
allStates: State[];
allCountries: Country[];
//allAccountNumbers: AccountNumber[];
//viewUpdateProfileForm = new FormGroup({
// accountNo: new FormControl(),
// licenseeFirstName: new FormControl(),
// licenseeLastName: new FormControl(),
// institutionName: new FormControl(),
// email: new FormControl(),
// address1: new FormControl(),
// address2: new FormControl(),
// city: new FormControl(),
// zip: new FormControl(),
// state: new FormControl(),
// country: new FormControl(),
// phone: new FormControl()
//});
constructor(private application: ApplicationService, private router: Router) { //, private formBuilder: FormBuilder
//this.updateProfile = {
// accountNumber: '',
// licenseeFirstName: '',
// licenseeLastName: '',
// institutionName: '',
// email: '',
// address1: '',
// address2: '',
// city: '',
// zip: 0,
// state: '',
// country: '',
// phone: 0
//}
}
ngAfterViewInit(): void {
this.initializeUIElements();
}
initializeUIElements(): void {
}
ngOnInit(): void {
/*if (this.application.currentUser == null) {
this.router.navigate(['/login']);
}*/
//this.createForm();
}
//private createForm() {
// this.viewUpdateProfileForm = this.formBuilder.group({
// accountNo: ['', Validators.compose([Validators.required, Validators.maxLength(50)])],
// licenseeFirstName: ['', Validators.compose([Validators.required, Validators.maxLength(50)])],
// licenseeLastName: ['', Validators.compose([Validators.required, Validators.maxLength(50)])],
// institutionName: ['', Validators.compose([Validators.required, Validators.maxLength(100)])],
// email: ['', Validators.compose([Validators.required, Validators.pattern(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)])],
// address1: ['', Validators.compose([Validators.required, Validators.maxLength(100)])],
// address2: ['', Validators.compose([Validators.required, Validators.maxLength(100)])],
// city: ['', Validators.compose([Validators.required, Validators.maxLength(50)])],
// zip: ['', Validators.compose([(Validators.required, Validators.pattern(/^\d{5}$/))])], // -- Working (5) numbers
// state: ['', Validators.required],
// country: ['', Validators.required],
// phone: ['', Validators.compose([(Validators.required, Validators.pattern(/^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/))])]
// });
// //this.viewUpdateProfileForm.getRawValue()
// // .subscribe(data => this.onValueChanged(data));
// //this.onValueChanged(); // (re)set validation messages now
//}
showAlert(id: string): void {
jQuery('#' + id).modal('show');
}
//onValueChanged(data ?: any) {
// if (!this.viewUpdateProfileForm) { return; }
// const form = this.viewUpdateProfileForm;
// for (const field in this.formErrors) {
// // clear previous error message (if any)
// this.formErrors[field] = '';
// const control = form.get(field);
// if (control && control.dirty && !control.valid) {
// const messages = this.validationMessages[field];
// for (const key in control.errors) {
// this.formErrors[field] += messages[key] + ' ';
// }
// }
// }
//}
formErrors = {
'accountNo': '',
'licenseeFirstName': '',
'licenseeLastName': '',
'institutionName': '',
'email': '',
'address1': '',
'address2': '',
'city': '',
'state': '',
'country': '',
'zip': '',
'phone': ''
};
validationMessages = {
'accountNo': {
'required': 'Account Number is required.'
},
'licenseeFirstName': {
'required': 'LicenseeFirstName is required.'
},
'licenseeLastName': {
'required': 'LicenseeLastName is required.'
},
'institutionName': {
'required': 'InstitutionName is required.'
},
'address1': {
'required': 'Address1 is required.'
},
'address2': {
'required': 'Address2 is required.'
},
'city': {
'required': 'City is required.'
},
'state': {
'required': 'State is required.'
},
'country': {
'required': 'Country is required.'
},
'zip': {
'required': 'Zip is required.',
'pattern': 'Only 5 digited numbers (US zip) are allowed.'
},
'phone': {
'required': 'Phone is required.',
'pattern': 'Not a valid US pattern.'
},
'email': {
'required': 'Email is required.',
'pattern': 'Email pattern is not valid.'
}
};
}