1
1
import { Component , ViewChild , Injector , Output , EventEmitter , ElementRef , OnInit } from '@angular/core' ;
2
2
import { ModalDirective } from 'ngx-bootstrap' ;
3
- import { RoleServiceProxy , CreateRoleDto , RoleDto , ListResultDtoOfPermissionDto } from '@shared/service-proxies/service-proxies' ;
3
+ import { RoleServiceProxy , CreateRoleDto , ListResultDtoOfPermissionDto } from '@shared/service-proxies/service-proxies' ;
4
4
import { AppComponentBase } from '@shared/app-component-base' ;
5
5
6
6
@Component ( {
@@ -35,29 +35,22 @@ export class CreateRoleComponent extends AppComponentBase implements OnInit {
35
35
36
36
show ( ) : void {
37
37
this . active = true ;
38
- this . modal . show ( ) ;
39
- this . role = new CreateRoleDto ( { isStatic :false ,
40
- description :'' ,
41
- isActive :false ,
42
- name :'' } ) ;
38
+ this . role = new CreateRoleDto ( { isActive : true , isStatic : false } ) ;
43
39
44
- // // shouldn't have to do this!
45
- // this.role.description = "";
46
- // this.role.isActive = false;
47
- // this.role.name = "";
40
+ this . modal . show ( ) ;
48
41
}
49
42
50
43
onShown ( ) : void {
51
44
( $ as any ) . AdminBSB . input . activate ( $ ( this . modalContent . nativeElement ) ) ;
52
45
53
46
$ ( '#frm_create_role' ) . validate ( {
54
- highlight : function ( input ) {
47
+ highlight : input => {
55
48
$ ( input ) . parents ( '.form-line' ) . addClass ( 'error' ) ;
56
49
} ,
57
- unhighlight : function ( input ) {
50
+ unhighlight : input => {
58
51
$ ( input ) . parents ( '.form-line' ) . removeClass ( 'error' ) ;
59
52
} ,
60
- errorPlacement : function ( error , element ) {
53
+ errorPlacement : ( error , element ) => {
61
54
$ ( element ) . parents ( '.form-group' ) . append ( error ) ;
62
55
}
63
56
} ) ;
@@ -66,12 +59,12 @@ export class CreateRoleComponent extends AppComponentBase implements OnInit {
66
59
save ( ) : void {
67
60
var permissions = [ ] ;
68
61
$ ( this . modalContent . nativeElement ) . find ( "[name=permission]" ) . each (
69
- function ( index :number , elem : Element ) {
70
- if ( $ ( elem ) . is ( ":checked" ) == true ) {
62
+ ( index : number , elem : Element ) => {
63
+ if ( $ ( elem ) . is ( ":checked" ) == true ) {
71
64
permissions . push ( elem . getAttribute ( "value" ) . valueOf ( ) ) ;
72
65
}
73
66
}
74
- )
67
+ ) ;
75
68
76
69
this . role . permissions = permissions ;
77
70
this . saving = true ;
0 commit comments