Skip to content

Commit 7012215

Browse files
committed
Handle enter key on tenant switch.
1 parent 0590ddf commit 7012215

File tree

1 file changed

+30
-17
lines changed
  • aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Shared/Components/TenantChange

1 file changed

+30
-17
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Shared/Components/TenantChange/_ChangeModal.js

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
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

@@ -18,22 +17,36 @@
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

Comments
 (0)