33
44 var _$form = $ ( 'form[name=TenantChangeForm]' ) ;
55
6- _$form . closest ( 'div.modal-content' ) . find ( ".save-button" ) . click ( function ( e ) {
7- e . preventDefault ( ) ;
6+ function switchToSelectedTenant ( ) {
87
98 var tenancyName = _$form . find ( 'input[name=TenancyName]' ) . val ( ) ;
109
1817 tenancyName : tenancyName
1918 } ) . done ( function ( result ) {
2019 switch ( result . state ) {
21- case 1 : //Available
22- abp . multiTenancy . setTenantIdCookie ( result . tenantId ) ;
23- //_modalManager.close();
24- location . reload ( ) ;
25- return ;
26- case 2 : //InActive
27- abp . message . warn ( abp . utils . formatString ( abp . localization
28- . localize ( "TenantIsNotActive" , "AbpProjectName" ) ,
29- this . tenancyName ) ) ;
30- break ;
31- case 3 : //NotFound
32- abp . message . warn ( abp . utils . formatString ( abp . localization
33- . localize ( "ThereIsNoTenantDefinedWithName{0}" , "AbpProjectName" ) ,
34- this . tenancyName ) ) ;
35- break ;
20+ case 1 : //Available
21+ abp . multiTenancy . setTenantIdCookie ( result . tenantId ) ;
22+ //_modalManager.close();
23+ location . reload ( ) ;
24+ return ;
25+ case 2 : //InActive
26+ abp . message . warn ( abp . utils . formatString ( abp . localization
27+ . localize ( "TenantIsNotActive" , "AbpProjectName" ) ,
28+ this . tenancyName ) ) ;
29+ break ;
30+ case 3 : //NotFound
31+ abp . message . warn ( abp . utils . formatString ( abp . localization
32+ . localize ( "ThereIsNoTenantDefinedWithName{0}" , "AbpProjectName" ) ,
33+ this . tenancyName ) ) ;
34+ break ;
3635 }
3736 } ) ;
37+ }
38+
39+ //Handle save button click
40+ _$form . closest ( 'div.modal-content' ) . find ( ".save-button" ) . click ( function ( e ) {
41+ e . preventDefault ( ) ;
42+ switchToSelectedTenant ( ) ;
43+ } ) ;
44+
45+ //Handle enter key
46+ _$form . find ( 'input' ) . on ( 'keypress' , function ( e ) {
47+ if ( e . which === 13 ) {
48+ e . preventDefault ( ) ;
49+ switchToSelectedTenant ( ) ;
50+ }
3851 } ) ;
3952} ) ( jQuery ) ;
0 commit comments