123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- @using WeApp
- @using WeApp.Configuration
- @using WeApp.Helpers
- @using WeApp.Views.Shared.Modals
- @model WeApp.BaseSystem.Sessions.Dto.TenantLoginInfoDto
- <div class="text-center" style="margin-bottom: 3px;">
- <span>
- @L("CurrentTenant"):
- @if (Model!=null)
- {
- <span title="@Model.Name"><strong>@Model.TenancyName</strong></span>
- }
- else
- {
- <span>@L("NotSelected")</span>
- }
- (<a href="#" data-toggle="modal" data-target="#TenantChangeModal">@L("Change")</a>)
- </span>
- </div>
- @{
-
- }
- @using (Html.BeginScripts())
- {
- <script>
- (function () {
- // var _accountService = abp.services.app.account;
- $(function() {
- var $tenantChangeForm = $('#TenantChangeForm');
- function switchToSelectedTenant() {
- var tenancyName = $tenantChangeForm.find('input[name=TenancyName]').val();
- if (!tenancyName) {
- abp.multiTenancy.setTenantIdCookie(null);
- location.reload();
- return;
- }
- $.iwbAjax4({
- url: '@Path.Combine(ApplicationPath, IwbConsts.ApiAppUrl)account/isTenantAvailable',
- form:$tenantChangeForm,
- success: function (result) {
- switch (result.state) {
- case 1: //Available
- abp.multiTenancy.setTenantIdCookie(result.tenantId);
- //_modalManager.close();
- location.reload();
- return;
- case 2: //InActive
- abp.message.warn(abp.utils.formatString(abp.localization
- .localize("TenantIsNotActive", "WeApp"),
- tenancyName));
- break;
- case 3: //NotFound
- abp.message.warn(abp.utils.formatString(abp.localization
- .localize("ThereIsNoTenantDefinedWithName{0}", "WeApp"),
- tenancyName));
- break;
- }
- }
- });
- //_accountService.isTenantAvailable({
- // tenancyName: tenancyName
- //}).done(function (result) {
- // switch (result.state) {
- // case 1: //Available
- // abp.multiTenancy.setTenantIdCookie(result.tenantId);
- // //_modalManager.close();
- // location.reload();
- // return;
- // case 2: //InActive
- // abp.message.warn(abp.utils.formatString(abp.localization
- // .localize("TenantIsNotActive", "WeApp"),
- // tenancyName));
- // break;
- // case 3: //NotFound
- // abp.message.warn(abp.utils.formatString(abp.localization
- // .localize("ThereIsNoTenantDefinedWithName{0}", "WeApp"),
- // tenancyName));
- // break;
- // }
- //});
- }
- //Handle save button click
- $tenantChangeForm.closest('div.modal-content').find(".save-btn").click(function (e) {
- e.preventDefault();
- switchToSelectedTenant();
- });
- //Handle enter key
- $tenantChangeForm.find('input').on('keypress', function (e) {
- if (e.which === 13) {
- e.preventDefault();
- switchToSelectedTenant();
- }
- });
- $.AdminBSB.input.activate($tenantChangeForm);
- $('#TenantChangeModal').on('shown.bs.modal', function () {
- $tenantChangeForm.find('input[type=text]:first').focus();
- });
- });
-
- })();
- </script>
- @Html.Partial("Modals/_Modal", tenantModal)
- }
|