1
- import { Component , ViewEncapsulation , Renderer2 , ViewChild , ElementRef , Input } from '@angular/core' ;
1
+ import { Component , ViewEncapsulation , Renderer2 , ViewChild , ElementRef , LOCALE_ID , Inject } from '@angular/core' ;
2
2
import { faTimes , IconDefinition } from '@fortawesome/free-solid-svg-icons' ;
3
3
import { PanelAnimation } from 'src/app/modules/animations/panel.animation' ;
4
4
import { OverlayAnimation } from 'src/app/modules/animations/overlay.animation' ;
@@ -18,7 +18,7 @@ import { DateValidation } from 'src/app/modules/validations/date.validation';
18
18
} )
19
19
export class UsersEditComponent {
20
20
@ViewChild ( 'panel' ) panel : ElementRef ;
21
-
21
+
22
22
public visible = new BehaviorSubject < Boolean > ( false ) ;
23
23
public form : FormGroup ;
24
24
public user : User = new User ;
@@ -29,7 +29,8 @@ export class UsersEditComponent {
29
29
private formBuilder : FormBuilder ,
30
30
private renderer : Renderer2 ,
31
31
private location : Location ,
32
- private router : Router ) {
32
+ private router : Router ,
33
+ @Inject ( LOCALE_ID ) private locale : string ) {
33
34
34
35
this . visible . subscribe ( ( visible : Boolean ) => {
35
36
if ( visible ) {
@@ -45,11 +46,11 @@ export class UsersEditComponent {
45
46
Document : this . formBuilder . control ( {
46
47
value : this . user . Document ,
47
48
disabled : true
48
- } , [ Validators . required , Validators . minLength ( 6 ) ] ) ,
49
+ } ) ,
49
50
Birthdate : this . formBuilder . control ( {
50
- value : this . user . Birthdate . toLocaleDateString ( ) ,
51
+ value : this . user . Birthdate . toLocaleDateString ( locale ) ,
51
52
disabled : false
52
- } , [ Validators . required , Validators . pattern ( DateValidation ) ] ) ,
53
+ } , [ Validators . required , DateValidation ] ) ,
53
54
Country : this . formBuilder . control ( {
54
55
value : this . user . Country ,
55
56
disabled : false
@@ -63,12 +64,12 @@ export class UsersEditComponent {
63
64
disabled : false
64
65
} ) ,
65
66
} ) ;
66
-
67
+
67
68
this . renderer . addClass ( document . body , 'overflow' ) ;
68
69
this . renderer . setProperty ( this . panel . nativeElement , 'scrollTop' , '0' ) ;
69
70
this . location . go ( this . router . url . split ( '/' ) [ 1 ] + '/' + this . user . Id ) ;
70
71
} else {
71
- this . renderer . removeClass ( document . body , 'overflow' ) ;
72
+ this . renderer . removeClass ( document . body , 'overflow' ) ;
72
73
this . location . go ( this . router . url . split ( '/' ) [ 1 ] ) ;
73
74
}
74
75
} ) ;
0 commit comments